From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/opengl.c | 84 ++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 45 deletions(-)
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 3fcad8a4a00..f8e220df1f0 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1822,58 +1822,57 @@ static BOOL glxdrv_wglShareLists(struct wgl_context *org, struct wgl_context *de return TRUE; }
+static void present_gl_drawable( HWND hwnd, HDC hdc, struct gl_drawable *gl, BOOL flush ) +{ + struct x11drv_escape_flush_gl_drawable escape = + { + .code = X11DRV_FLUSH_GL_DRAWABLE, + .flush = flush, + }; + Drawable drawable; + + if (!gl) return; + switch (gl->type) + { + case DC_GL_PIXMAP_WIN: drawable = gl->pixmap; break; + case DC_GL_CHILD_WIN: drawable = gl->window; break; + default: drawable = 0; break; + } + if (!(escape.gl_drawable = drawable)) return; + + NtGdiExtEscape( hdc, NULL, 0, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL ); +} + static void wglFinish(void) { - struct x11drv_escape_flush_gl_drawable escape; struct gl_drawable *gl; struct wgl_context *ctx = NtCurrentTeb()->glContext; + HWND hwnd = NtUserWindowFromDC( ctx->hdc );
- escape.code = X11DRV_FLUSH_GL_DRAWABLE; - escape.gl_drawable = 0; - escape.flush = FALSE; - - if ((gl = get_gl_drawable( NtUserWindowFromDC( ctx->hdc ), 0 ))) + if (!(gl = get_gl_drawable( hwnd, 0 ))) pglFinish(); + else { - switch (gl->type) - { - case DC_GL_PIXMAP_WIN: escape.gl_drawable = gl->pixmap; break; - case DC_GL_CHILD_WIN: escape.gl_drawable = gl->window; break; - default: break; - } sync_context(ctx); + pglFinish(); + present_gl_drawable( hwnd, ctx->hdc, gl, FALSE ); release_gl_drawable( gl ); } - - pglFinish(); - if (escape.gl_drawable) - NtGdiExtEscape( ctx->hdc, NULL, 0, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL ); }
static void wglFlush(void) { - struct x11drv_escape_flush_gl_drawable escape; struct gl_drawable *gl; struct wgl_context *ctx = NtCurrentTeb()->glContext; + HWND hwnd = NtUserWindowFromDC( ctx->hdc );
- escape.code = X11DRV_FLUSH_GL_DRAWABLE; - escape.gl_drawable = 0; - escape.flush = FALSE; - - if ((gl = get_gl_drawable( NtUserWindowFromDC( ctx->hdc ), 0 ))) + if (!(gl = get_gl_drawable( hwnd, 0 ))) pglFlush(); + else { - switch (gl->type) - { - case DC_GL_PIXMAP_WIN: escape.gl_drawable = gl->pixmap; break; - case DC_GL_CHILD_WIN: escape.gl_drawable = gl->window; break; - default: break; - } sync_context(ctx); + pglFlush(); + present_gl_drawable( hwnd, ctx->hdc, gl, FALSE ); release_gl_drawable( gl ); } - - pglFlush(); - if (escape.gl_drawable) - NtGdiExtEscape( ctx->hdc, NULL, 0, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL ); }
static const GLubyte *wglGetString(GLenum name) @@ -2731,18 +2730,15 @@ static void X11DRV_WineGL_LoadExtensions(void) */ static BOOL glxdrv_wglSwapBuffers( HDC hdc ) { - struct x11drv_escape_flush_gl_drawable escape; struct gl_drawable *gl; struct wgl_context *ctx = NtCurrentTeb()->glContext; INT64 ust, msc, sbc, target_sbc = 0; + HWND hwnd = NtUserWindowFromDC( hdc ); + Drawable drawable = 0;
TRACE("(%p)\n", hdc);
- escape.code = X11DRV_FLUSH_GL_DRAWABLE; - escape.gl_drawable = 0; - escape.flush = !pglXWaitForSbcOML; - - if (!(gl = get_gl_drawable( NtUserWindowFromDC( hdc ), hdc ))) + if (!(gl = get_gl_drawable( hwnd, hdc ))) { RtlSetLastWin32Error( ERROR_INVALID_HANDLE ); return FALSE; @@ -2760,7 +2756,7 @@ static BOOL glxdrv_wglSwapBuffers( HDC hdc ) { case DC_GL_PIXMAP_WIN: if (ctx) sync_context( ctx ); - escape.gl_drawable = gl->pixmap; + drawable = gl->pixmap; if (ctx && pglXCopySubBufferMESA) { /* (glX)SwapBuffers has an implicit glFlush effect, however * GLX_MESA_copy_sub_buffer doesn't. Make sure GL is flushed before @@ -2781,10 +2777,10 @@ static BOOL glxdrv_wglSwapBuffers( HDC hdc ) case DC_GL_WINDOW: case DC_GL_CHILD_WIN: if (ctx) sync_context( ctx ); - if (gl->type == DC_GL_CHILD_WIN) escape.gl_drawable = gl->window; + if (gl->type == DC_GL_CHILD_WIN) drawable = gl->window; /* fall through */ default: - if (ctx && escape.gl_drawable && pglXSwapBuffersMscOML) + if (ctx && drawable && pglXSwapBuffersMscOML) { pglFlush(); target_sbc = pglXSwapBuffersMscOML( gdi_display, gl->drawable, 0, 0, 0 ); @@ -2794,13 +2790,11 @@ static BOOL glxdrv_wglSwapBuffers( HDC hdc ) break; }
- if (ctx && escape.gl_drawable && pglXWaitForSbcOML) + if (ctx && drawable && pglXWaitForSbcOML) pglXWaitForSbcOML( gdi_display, gl->drawable, target_sbc, &ust, &msc, &sbc );
+ present_gl_drawable( hwnd, ctx ? ctx->hdc : hdc, gl, !pglXWaitForSbcOML ); release_gl_drawable( gl ); - - if (escape.gl_drawable) - NtGdiExtEscape( ctx ? ctx->hdc : hdc, NULL, 0, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL ); return TRUE; }