From: Rémi Bernon rbernon@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58448 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58459 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58488 --- dlls/win32u/opengl.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 5ac9fd72147..b800806623b 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -904,17 +904,13 @@ struct opengl_drawable *get_window_opengl_drawable( HWND hwnd ) return drawable; }
-static void set_dc_opengl_drawable( HDC hdc, struct opengl_drawable *new_drawable ) +void set_dc_opengl_drawable( HDC hdc, struct opengl_drawable *new_drawable ) { void *old_drawable = NULL; - HWND hwnd; DC *dc;
TRACE( "hdc %p, new_drawable %s\n", hdc, debugstr_opengl_drawable( new_drawable ) );
- /* update the current window drawable to the last used draw surface */ - if ((hwnd = NtUserWindowFromDC( hdc ))) set_window_opengl_drawable( hwnd, new_drawable ); - if ((dc = get_dc_ptr( hdc ))) { old_drawable = dc->opengl_drawable; @@ -925,15 +921,11 @@ static void set_dc_opengl_drawable( HDC hdc, struct opengl_drawable *new_drawabl if (old_drawable) opengl_drawable_release( old_drawable ); }
-static struct opengl_drawable *get_dc_opengl_drawable( HDC hdc, BOOL read ) +static struct opengl_drawable *get_dc_opengl_drawable( HDC hdc ) { void *drawable = NULL; - HWND hwnd; DC *dc;
- /* get the last used window drawable when reading */ - if ((hwnd = NtUserWindowFromDC( hdc )) && read) return get_window_opengl_drawable( hwnd ); - if ((dc = get_dc_ptr( hdc ))) { if ((drawable = dc->opengl_drawable)) opengl_drawable_add_ref( drawable ); @@ -1036,9 +1028,13 @@ static BOOL set_dc_pixel_format( HDC hdc, int new_format, BOOL internal )
if ((old_format = get_window_pixel_format( hwnd, FALSE )) && !internal) return old_format == new_format;
- drawable = get_dc_opengl_drawable( hdc, FALSE ); + drawable = get_dc_opengl_drawable( hdc ); if ((ret = driver_funcs->p_surface_create( hwnd, hdc, new_format, &drawable ))) + { + /* update the current window drawable to the last used draw surface */ + if ((hwnd = NtUserWindowFromDC( hdc ))) set_window_opengl_drawable( hwnd, drawable ); set_dc_opengl_drawable( hdc, drawable ); + } if (drawable) opengl_drawable_release( drawable );
if (!ret) return FALSE; @@ -1128,8 +1124,11 @@ static BOOL context_set_drawables( struct wgl_context *context, void *private, H HWND hwnd;
flush = create_memory_pbuffer( draw_hdc, context->pixel_format ); - new_draw = get_dc_opengl_drawable( draw_hdc, FALSE ); - new_read = get_dc_opengl_drawable( read_hdc, read_hdc != draw_hdc ); + new_draw = get_dc_opengl_drawable( draw_hdc ); + + /* get the last used window drawable when reading */ + if ((hwnd = NtUserWindowFromDC( read_hdc ))) new_read = get_window_opengl_drawable( hwnd ); + else new_read = get_dc_opengl_drawable( read_hdc );
TRACE( "context %p, new_draw %s, new_read %s\n", context, debugstr_opengl_drawable( new_draw ), debugstr_opengl_drawable( new_read ) );
@@ -1662,7 +1661,7 @@ static BOOL win32u_wgl_context_flush( struct wgl_context *context, void (*flush) if (flush) flush(); if (flush == funcs->p_glFinish) flags |= GL_FLUSH_FINISHED;
- if (!(draw = get_dc_opengl_drawable( draw_hdc, FALSE ))) return FALSE; + if (!(draw = get_dc_opengl_drawable( draw_hdc ))) return FALSE; opengl_drawable_flush( draw, interval, flags ); opengl_drawable_release( draw );
@@ -1685,7 +1684,7 @@ static BOOL win32u_wglSwapBuffers( HDC hdc ) context_set_drawables( context, context->driver_private, draw_hdc, read_hdc, FALSE ); if (flush_memory_dc( context, hdc, FALSE, funcs->p_glFlush )) return TRUE;
- if (!(draw = get_dc_opengl_drawable( draw_hdc, FALSE ))) return FALSE; + if (!(draw = get_dc_opengl_drawable( draw_hdc ))) return FALSE; opengl_drawable_flush( draw, interval, 0 ); if (!draw->client) ret = FALSE; /* pbuffer, nothing to do */ else ret = draw->funcs->swap( draw );