[PATCH v3 0/2] MR10190: winu32: Try harder to replace the old drawable everywhere.
-- v3: win32u: Also try to use DC own drawable in get_updated_drawable() when context is flushed. https://gitlab.winehq.org/wine/wine/-/merge_requests/10190
From: Paul Gofman <pgofman@codeweavers.com> wgl_context_flush() may recreate the drawable and release the old one. --- dlls/opengl32/unix_wgl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index 6d73b1cd735..1d0c995e7fe 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -1376,6 +1376,7 @@ static void flush_context( TEB *teb, void (*flush)(void) ) { struct opengl_drawable *read, *draw; struct context *ctx = get_current_context( teb, &read, &draw ); + HWND draw_hwnd = ctx && draw && draw->client ? draw->client->hwnd : NULL; const struct opengl_funcs *funcs = teb->glTable; UINT flags = 0; @@ -1395,7 +1396,7 @@ static void flush_context( TEB *teb, void (*flush)(void) ) WARN( "Front buffer rendering emulation, copying front buffer back\n" ); - NtUserGetClientRect( draw->client->hwnd, &rect, NtUserGetDpiForWindow( draw->client->hwnd ) ); + NtUserGetClientRect( draw_hwnd, &rect, NtUserGetDpiForWindow( draw_hwnd ) ); if (ctx->read_fbo) funcs->p_glBindFramebuffer( GL_READ_FRAMEBUFFER, 0 ); funcs->p_glReadBuffer( GL_FRONT_LEFT ); funcs->p_glBlitFramebuffer( 0, 0, rect.right, rect.bottom, 0, 0, rect.right, rect.bottom, mask, GL_NEAREST ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10190
From: Paul Gofman <pgofman@codeweavers.com> --- dlls/win32u/opengl.c | 10 ++++++++-- include/wine/opengl_driver.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 486c3f45c2a..7b2f8c9524b 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -1429,7 +1429,7 @@ static struct opengl_drawable *get_window_unused_drawable( HWND hwnd, int format static void set_dc_opengl_drawable( HDC hdc, struct opengl_drawable *new_drawable ) { - void *old_drawable = NULL; + struct opengl_drawable *old_drawable = NULL; DC *dc; TRACE( "hdc %p, new_drawable %s\n", hdc, debugstr_opengl_drawable( new_drawable ) ); @@ -1437,7 +1437,12 @@ static void set_dc_opengl_drawable( HDC hdc, struct opengl_drawable *new_drawabl if ((dc = get_dc_ptr( hdc ))) { old_drawable = dc->opengl_drawable; - if ((dc->opengl_drawable = new_drawable)) opengl_drawable_add_ref( new_drawable ); + if ((dc->opengl_drawable = new_drawable)) + { + new_drawable->owner_hdc = hdc; + opengl_drawable_add_ref( new_drawable ); + } + if (old_drawable) old_drawable->owner_hdc = 0; release_dc_ptr( dc ); } @@ -1806,6 +1811,7 @@ static struct opengl_drawable *get_updated_drawable( HDC hdc, int format, struct } /* retrieve D3D internal drawables from the DCs if they have any */ + if (!hdc && drawable) hdc = drawable->owner_hdc; if (hdc && (drawable = get_dc_opengl_drawable( hdc ))) return drawable; /* get an updated drawable with the desired format */ diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index 470850c9d49..7b2cea0a87b 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -191,6 +191,7 @@ struct opengl_drawable LONG ref; /* reference count */ struct list entry; /* entry in cleanup lists */ struct client_surface *client; /* underlying client surface */ + HDC owner_hdc; /* HDC owning the drawable, if any (for pbuffer / D3D swapchains) */ int format; /* pixel format of the drawable */ int interval; /* last set surface swap interval */ BOOL doublebuffer; /* pixel format is double buffered */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10190
v3: - remove patch 2 (it looks like it is still off). -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10190#note_130630
This merge request was approved by Rémi Bernon. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10190
participants (3)
-
Paul Gofman -
Paul Gofman (@gofman) -
Rémi Bernon (@rbernon)