Commit 52a99f2e authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

wined3d: Change calls of GetDC() to GetDCEx() with DCX_CACHE so the HDC is not…

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: 's avatarKen Thomases <ken@codeweavers.com> Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 86c47907
......@@ -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");
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment