wined3d: Change calls of GetDC() to GetDCEx() with DCX_CACHE so the HDC is not shared with other threads.

Windows created by the app may use the CS_CLASSDC or CS_OWNDC class styles.  In
that case, GetDC() would return the same HDC to all callers.  It's not safe,
though, for multiple threads to use the same HDC without synchronization.  The
app may be using that HDC from multiple threads and using some synchronization
scheme to make that safe, but wined3d is not able to cooperate in such a scheme.

Using GetDCEx() with DCX_CACHE ensures that wined3d gets an independent HDC.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Ken Thomases 2016-02-15 14:48:27 -06:00 committed by Alexandre Julliard
parent 86c4790721
commit 52a99f2ead
2 changed files with 5 additions and 5 deletions

View File

@ -790,7 +790,7 @@ static BOOL context_restore_pixel_format(struct wined3d_context *ctx)
{
if (ctx->gl_info->supported[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH])
{
HDC dc = GetDC(ctx->restore_pf_win);
HDC dc = GetDCEx(ctx->restore_pf_win, 0, DCX_USESTYLE | DCX_CACHE);
if (dc)
{
if (!(ret = GL_EXTCALL(wglSetPixelFormatWINE(dc, ctx->restore_pf))))
@ -966,7 +966,7 @@ static void context_update_window(struct wined3d_context *context)
context->needs_set = 1;
context->valid = 1;
if (!(context->hdc = GetDC(context->win_handle)))
if (!(context->hdc = GetDCEx(context->win_handle, 0, DCX_USESTYLE | DCX_CACHE)))
{
ERR("Failed to get a device context for window %p.\n", context->win_handle);
context->valid = 0;
@ -1526,7 +1526,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
}
}
if (!(hdc = GetDC(swapchain->win_handle)))
if (!(hdc = GetDCEx(swapchain->win_handle, 0, DCX_USESTYLE | DCX_CACHE)))
{
WARN("Failed to retrieve device context, trying swapchain backup.\n");

View File

@ -257,7 +257,7 @@ HRESULT CDECL wined3d_swapchain_set_gamma_ramp(const struct wined3d_swapchain *s
if (flags)
FIXME("Ignoring flags %#x.\n", flags);
dc = GetDC(swapchain->device_window);
dc = GetDCEx(swapchain->device_window, 0, DCX_USESTYLE | DCX_CACHE);
SetDeviceGammaRamp(dc, (void *)ramp);
ReleaseDC(swapchain->device_window, dc);
@ -277,7 +277,7 @@ HRESULT CDECL wined3d_swapchain_get_gamma_ramp(const struct wined3d_swapchain *s
TRACE("swapchain %p, ramp %p.\n", swapchain, ramp);
dc = GetDC(swapchain->device_window);
dc = GetDCEx(swapchain->device_window, 0, DCX_USESTYLE | DCX_CACHE);
GetDeviceGammaRamp(dc, ramp);
ReleaseDC(swapchain->device_window, dc);