Commit 27287382 authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

wined3d: Track if a context's hdc is private so we never need to restore its pixel format.

This currently only applies to the swapchain backup DC, but it will soon be used for surfaces created using the WGL_WINE_surface extension. Also, there are a couple of cases where ddraw creates private windows and passes them in. It could be extended to those.
parent 57c51710
...@@ -750,7 +750,7 @@ static BOOL context_restore_pixel_format(struct wined3d_context *ctx) ...@@ -750,7 +750,7 @@ static BOOL context_restore_pixel_format(struct wined3d_context *ctx)
return ret; return ret;
} }
static BOOL context_set_pixel_format(struct wined3d_context *context, HDC dc, int format) static BOOL context_set_pixel_format(struct wined3d_context *context, HDC dc, BOOL private, int format)
{ {
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
int current = GetPixelFormat(dc); int current = GetPixelFormat(dc);
...@@ -768,7 +768,7 @@ static BOOL context_set_pixel_format(struct wined3d_context *context, HDC dc, in ...@@ -768,7 +768,7 @@ static BOOL context_set_pixel_format(struct wined3d_context *context, HDC dc, in
} }
context->restore_pf = 0; context->restore_pf = 0;
context->restore_pf_win = WindowFromDC(dc); context->restore_pf_win = private ? NULL : WindowFromDC(dc);
return TRUE; return TRUE;
} }
...@@ -787,12 +787,12 @@ static BOOL context_set_pixel_format(struct wined3d_context *context, HDC dc, in ...@@ -787,12 +787,12 @@ static BOOL context_set_pixel_format(struct wined3d_context *context, HDC dc, in
return FALSE; return FALSE;
} }
win = WindowFromDC(dc); win = private ? NULL : WindowFromDC(dc);
if (win != context->restore_pf_win) if (win != context->restore_pf_win)
{ {
context_restore_pixel_format(context); context_restore_pixel_format(context);
context->restore_pf = current; context->restore_pf = private ? 0 : current;
context->restore_pf_win = win; context->restore_pf_win = win;
} }
...@@ -813,7 +813,7 @@ static BOOL context_set_gl_context(struct wined3d_context *ctx) ...@@ -813,7 +813,7 @@ static BOOL context_set_gl_context(struct wined3d_context *ctx)
struct wined3d_swapchain *swapchain = ctx->swapchain; struct wined3d_swapchain *swapchain = ctx->swapchain;
BOOL backup = FALSE; BOOL backup = FALSE;
if (!context_set_pixel_format(ctx, ctx->hdc, ctx->pixel_format)) if (!context_set_pixel_format(ctx, ctx->hdc, ctx->hdc_is_private, ctx->pixel_format))
{ {
WARN("Failed to set pixel format %d on device context %p.\n", WARN("Failed to set pixel format %d on device context %p.\n",
ctx->pixel_format, ctx->hdc); ctx->pixel_format, ctx->hdc);
...@@ -846,7 +846,7 @@ static BOOL context_set_gl_context(struct wined3d_context *ctx) ...@@ -846,7 +846,7 @@ static BOOL context_set_gl_context(struct wined3d_context *ctx)
return FALSE; return FALSE;
} }
if (!context_set_pixel_format(ctx, dc, ctx->pixel_format)) if (!context_set_pixel_format(ctx, dc, TRUE, ctx->pixel_format))
{ {
ERR("Failed to set pixel format %d on device context %p.\n", ERR("Failed to set pixel format %d on device context %p.\n",
ctx->pixel_format, dc); ctx->pixel_format, dc);
...@@ -890,6 +890,7 @@ static void context_update_window(struct wined3d_context *context) ...@@ -890,6 +890,7 @@ static void context_update_window(struct wined3d_context *context)
wined3d_release_dc(context->win_handle, context->hdc); wined3d_release_dc(context->win_handle, context->hdc);
context->win_handle = context->swapchain->win_handle; context->win_handle = context->swapchain->win_handle;
context->hdc_is_private = FALSE;
context->needs_set = 1; context->needs_set = 1;
context->valid = 1; context->valid = 1;
...@@ -1328,6 +1329,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, ...@@ -1328,6 +1329,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
int swap_interval; int swap_interval;
DWORD state; DWORD state;
HDC hdc; HDC hdc;
BOOL hdc_is_private = FALSE;
TRACE("swapchain %p, target %p, window %p.\n", swapchain, target, swapchain->win_handle); TRACE("swapchain %p, target %p, window %p.\n", swapchain, target, swapchain->win_handle);
...@@ -1388,7 +1390,9 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, ...@@ -1388,7 +1390,9 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
{ {
WARN("Failed to retireve device context, trying swapchain backup.\n"); WARN("Failed to retireve device context, trying swapchain backup.\n");
if (!(hdc = swapchain_get_backup_dc(swapchain))) if ((hdc = swapchain_get_backup_dc(swapchain)))
hdc_is_private = TRUE;
else
{ {
ERR("Failed to retrieve a device context.\n"); ERR("Failed to retrieve a device context.\n");
goto out; goto out;
...@@ -1439,7 +1443,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, ...@@ -1439,7 +1443,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
ret->gl_info = gl_info; ret->gl_info = gl_info;
if (!context_set_pixel_format(ret, hdc, pixel_format)) if (!context_set_pixel_format(ret, hdc, hdc_is_private, pixel_format))
{ {
ERR("Failed to set pixel format %d on device context %p.\n", pixel_format, hdc); ERR("Failed to set pixel format %d on device context %p.\n", pixel_format, hdc);
context_release(ret); context_release(ret);
...@@ -1516,6 +1520,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, ...@@ -1516,6 +1520,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
ret->glCtx = ctx; ret->glCtx = ctx;
ret->win_handle = swapchain->win_handle; ret->win_handle = swapchain->win_handle;
ret->hdc = hdc; ret->hdc = hdc;
ret->hdc_is_private = hdc_is_private;
ret->pixel_format = pixel_format; ret->pixel_format = pixel_format;
ret->needs_set = 1; ret->needs_set = 1;
......
...@@ -1086,7 +1086,8 @@ struct wined3d_context ...@@ -1086,7 +1086,8 @@ struct wined3d_context
DWORD lowest_disabled_stage : 4; /* Max MAX_TEXTURES, 8 */ DWORD lowest_disabled_stage : 4; /* Max MAX_TEXTURES, 8 */
DWORD rebind_fbo : 1; DWORD rebind_fbo : 1;
DWORD needs_set : 1; DWORD needs_set : 1;
DWORD padding : 18; DWORD hdc_is_private : 1;
DWORD padding : 17;
DWORD shader_update_mask; DWORD shader_update_mask;
DWORD constant_update_mask; DWORD constant_update_mask;
DWORD numbered_array_mask; DWORD numbered_array_mask;
......
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