[PATCH 5/8] Revert "wined3d: Restore the pixel format of the window whose pixel format was actually changed."
Ken Thomases
ken at codeweavers.com
Mon Nov 2 14:37:47 CST 2015
This reverts commit 4c4552c5a1910a9d5adf8eccff0ac62d89ffe376.
For:
https://bugs.winehq.org/show_bug.cgi?id=35655
https://bugs.winehq.org/show_bug.cgi?id=35718
https://bugs.winehq.org/show_bug.cgi?id=35950
https://bugs.winehq.org/show_bug.cgi?id=35975
https://bugs.winehq.org/show_bug.cgi?id=36900
---
dlls/wined3d/context.c | 87 +++++++++++-------------------------------
dlls/wined3d/wined3d_private.h | 1 -
2 files changed, 22 insertions(+), 66 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 1480058..e11ce9d 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -781,38 +781,8 @@ void context_surface_update(struct wined3d_context *context, const struct wined3
}
}
-static void context_restore_pixel_format(struct wined3d_context *ctx)
+static BOOL context_set_pixel_format(const struct wined3d_gl_info *gl_info, HDC dc, int format)
{
- const struct wined3d_gl_info *gl_info = ctx->gl_info;
-
- if (ctx->restore_pf && IsWindow(ctx->restore_pf_win))
- {
- if (ctx->gl_info->supported[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH])
- {
- HDC dc = GetDC(ctx->restore_pf_win);
- if (dc)
- {
- if (!GL_EXTCALL(wglSetPixelFormatWINE(dc, ctx->restore_pf)))
- {
- ERR("wglSetPixelFormatWINE failed to restore pixel format %d on window %p.\n",
- ctx->restore_pf, ctx->restore_pf_win);
- }
- ReleaseDC(ctx->restore_pf_win, dc);
- }
- }
- else
- {
- ERR("can't restore pixel format %d on window %p\n", ctx->restore_pf, ctx->restore_pf_win);
- }
- }
-
- ctx->restore_pf = 0;
- ctx->restore_pf_win = NULL;
-}
-
-static BOOL context_set_pixel_format(struct wined3d_context *context, HDC dc, int format)
-{
- const struct wined3d_gl_info *gl_info = context->gl_info;
int current = GetPixelFormat(dc);
if (current == format) return TRUE;
@@ -826,9 +796,6 @@ static BOOL context_set_pixel_format(struct wined3d_context *context, HDC dc, in
format, dc, GetLastError());
return FALSE;
}
-
- context->restore_pf = 0;
- context->restore_pf_win = WindowFromDC(dc);
return TRUE;
}
@@ -838,24 +805,12 @@ static BOOL context_set_pixel_format(struct wined3d_context *context, HDC dc, in
* when really needed. */
if (gl_info->supported[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH])
{
- HWND win;
-
if (!GL_EXTCALL(wglSetPixelFormatWINE(dc, format)))
{
ERR("wglSetPixelFormatWINE failed to set pixel format %d on device context %p.\n",
format, dc);
return FALSE;
}
-
- win = WindowFromDC(dc);
- if (win != context->restore_pf_win)
- {
- context_restore_pixel_format(context);
-
- context->restore_pf = current;
- context->restore_pf_win = win;
- }
-
return TRUE;
}
@@ -873,7 +828,7 @@ static BOOL context_set_gl_context(struct wined3d_context *ctx)
struct wined3d_swapchain *swapchain = ctx->swapchain;
BOOL backup = FALSE;
- if (!context_set_pixel_format(ctx, ctx->hdc, ctx->pixel_format))
+ if (!context_set_pixel_format(ctx->gl_info, ctx->hdc, ctx->pixel_format))
{
WARN("Failed to set pixel format %d on device context %p.\n",
ctx->pixel_format, ctx->hdc);
@@ -906,7 +861,7 @@ static BOOL context_set_gl_context(struct wined3d_context *ctx)
return FALSE;
}
- if (!context_set_pixel_format(ctx, dc, ctx->pixel_format))
+ if (!context_set_pixel_format(ctx->gl_info, dc, ctx->pixel_format))
{
ERR("Failed to set pixel format %d on device context %p.\n",
ctx->pixel_format, dc);
@@ -928,8 +883,15 @@ static BOOL context_set_gl_context(struct wined3d_context *ctx)
return TRUE;
}
-static void context_restore_gl_context(const struct wined3d_gl_info *gl_info, HDC dc, HGLRC gl_ctx)
+static void context_restore_gl_context(const struct wined3d_gl_info *gl_info, HDC dc, HGLRC gl_ctx, int pf)
{
+ if (!context_set_pixel_format(gl_info, dc, pf))
+ {
+ ERR("Failed to restore pixel format %d on device context %p.\n", pf, dc);
+ context_set_current(NULL);
+ return;
+ }
+
if (!wglMakeCurrent(dc, gl_ctx))
{
ERR("Failed to restore GL context %p on device context %p, last error %#x.\n",
@@ -970,9 +932,11 @@ static void context_destroy_gl_resources(struct wined3d_context *context)
HGLRC restore_ctx;
HDC restore_dc;
unsigned int i;
+ int restore_pf;
restore_ctx = wglGetCurrentContext();
restore_dc = wglGetCurrentDC();
+ restore_pf = GetPixelFormat(restore_dc);
if (restore_ctx == context->glCtx)
restore_ctx = NULL;
@@ -1061,10 +1025,9 @@ static void context_destroy_gl_resources(struct wined3d_context *context)
HeapFree(GetProcessHeap(), 0, context->free_occlusion_queries);
HeapFree(GetProcessHeap(), 0, context->free_event_queries);
- context_restore_pixel_format(context);
if (restore_ctx)
{
- context_restore_gl_context(gl_info, restore_dc, restore_ctx);
+ context_restore_gl_context(gl_info, restore_dc, restore_ctx, restore_pf);
}
else if (wglGetCurrentContext() && !wglMakeCurrent(NULL, NULL))
{
@@ -1160,16 +1123,12 @@ void context_release(struct wined3d_context *context)
WARN("Context %p is not the current context.\n", context);
}
- if (!--context->level)
+ if (!--context->level && context->restore_ctx)
{
- context_restore_pixel_format(context);
- if (context->restore_ctx)
- {
- TRACE("Restoring GL context %p on device context %p.\n", context->restore_ctx, context->restore_dc);
- context_restore_gl_context(context->gl_info, context->restore_dc, context->restore_ctx);
- context->restore_ctx = NULL;
- context->restore_dc = NULL;
- }
+ TRACE("Restoring GL context %p on device context %p.\n", context->restore_ctx, context->restore_dc);
+ context_restore_gl_context(context->gl_info, context->restore_dc, context->restore_ctx, context->restore_pf);
+ context->restore_ctx = NULL;
+ context->restore_dc = NULL;
}
}
@@ -1202,10 +1161,9 @@ static void context_enter(struct wined3d_context *context)
current_gl, wglGetCurrentDC());
context->restore_ctx = current_gl;
context->restore_dc = wglGetCurrentDC();
+ context->restore_pf = GetPixelFormat(context->restore_dc);
context->needs_set = 1;
}
- else if (context->pixel_format != GetPixelFormat(context->hdc))
- context->needs_set = 1;
}
}
@@ -1568,9 +1526,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
context_enter(ret);
- ret->gl_info = gl_info;
-
- if (!context_set_pixel_format(ret, hdc, pixel_format))
+ if (!context_set_pixel_format(gl_info, hdc, pixel_format))
{
ERR("Failed to set pixel format %d on device context %p.\n", pixel_format, hdc);
context_release(ret);
@@ -1611,6 +1567,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
goto out;
}
+ ret->gl_info = gl_info;
ret->d3d_info = &device->adapter->d3d_info;
ret->state_table = device->StateTable;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 4bbb709..581ee41 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1209,7 +1209,6 @@ struct wined3d_context
HGLRC restore_ctx;
HDC restore_dc;
int restore_pf;
- HWND restore_pf_win;
HGLRC glCtx;
HWND win_handle;
HDC hdc;
--
2.6.0
More information about the wine-patches
mailing list