From: Paul Gofman <pgofman@codeweavers.com> --- dlls/win32u/opengl.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 486c3f45c2a..3617712a4ae 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -1789,10 +1789,13 @@ static BOOL context_unset_current( struct opengl_context *context ) } /* return an updated drawable, recreating one if the window drawables have been invalidated (mostly wineandroid) */ -static struct opengl_drawable *get_updated_drawable( HDC hdc, int format, struct opengl_drawable *drawable ) +static struct opengl_drawable *get_updated_drawable( HDC hdc, int format, struct opengl_drawable *drawable, + BOOL *updated ) { HWND hwnd = NULL; + *updated = FALSE; + /* return the memory DCs drawables directly */ if (hdc && !(hwnd = NtUserWindowFromDC( hdc ))) return get_dc_opengl_drawable( hdc ); if (!hdc && drawable && drawable->client) hwnd = drawable->client->hwnd; @@ -1809,6 +1812,7 @@ static struct opengl_drawable *get_updated_drawable( HDC hdc, int format, struct if (hdc && (drawable = get_dc_opengl_drawable( hdc ))) return drawable; /* get an updated drawable with the desired format */ + *updated = TRUE; return get_window_unused_drawable( hwnd, format ); } @@ -1816,12 +1820,13 @@ static BOOL context_sync_drawables( struct opengl_context *context, HDC draw_hdc { struct opengl_drawable *new_draw, *new_read, *old_draw = NULL, *old_read = NULL; struct opengl_context *previous = NtCurrentTeb()->glContext; - BOOL ret = FALSE; + BOOL ret = FALSE, draw_updated, read_updated; - if (!(new_draw = get_updated_drawable( draw_hdc, context->format, context->draw ))) return FALSE; + if (!(new_draw = get_updated_drawable( draw_hdc, context->format, context->draw, &draw_updated ))) return FALSE; + read_updated = draw_updated; if (!draw_hdc && context->draw == context->read) opengl_drawable_add_ref( (new_read = new_draw) ); else if (draw_hdc && draw_hdc == read_hdc) opengl_drawable_add_ref( (new_read = new_draw) ); - else new_read = get_updated_drawable( read_hdc, context->format, context->read ); + else new_read = get_updated_drawable( read_hdc, context->format, context->read, &read_updated ); TRACE( "context %p, new_draw %s, new_read %s\n", context, debugstr_opengl_drawable( new_draw ), debugstr_opengl_drawable( new_read ) ); @@ -1843,9 +1848,9 @@ static BOOL context_sync_drawables( struct opengl_context *context, HDC draw_hdc { NtCurrentTeb()->glContext = context; - if (old_draw && old_draw != new_draw && old_draw != new_read && old_draw->client) + if (!draw_updated && old_draw && old_draw != new_draw && old_draw != new_read && old_draw->client) set_window_opengl_drawable( old_draw->client->hwnd, old_draw, FALSE ); - if (old_read && old_read != new_draw && old_read != new_read && old_read->client) + if (!read_updated && old_read && old_read != new_draw && old_read != new_read && old_read->client) set_window_opengl_drawable( old_read->client->hwnd, old_read, FALSE ); /* all good, release previous context drawables if any */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10190