From b4e3674747230f215ed63f2d536039c1dff9956e Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 7 Sep 2012 21:00:46 +0200 Subject: [PATCH] winex11: Get the information from the drawable structure in SwapBuffers. --- dlls/winex11.drv/opengl.c | 59 ++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 6e0c0b7384c..32a10ac0799 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -3028,7 +3028,9 @@ static void X11DRV_WineGL_LoadExtensions(void) */ static BOOL glxdrv_SwapBuffers(PHYSDEV dev) { - struct glx_physdev *physdev = get_glxdrv_dev( dev ); + enum x11drv_escape_codes code = X11DRV_FLUSH_GL_DRAWABLE; + struct gl_drawable *gl; + HWND hwnd; struct wgl_context *ctx = NtCurrentTeb()->glContext; TRACE("(%p)\n", dev->hdc); @@ -3040,36 +3042,35 @@ static BOOL glxdrv_SwapBuffers(PHYSDEV dev) return FALSE; } - if (!physdev->drawable) - { - WARN("Using an invalid drawable, skipping\n"); - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - sync_context(ctx); - switch (physdev->type) - { - case DC_GL_PIXMAP_WIN: - if(pglXCopySubBufferMESA) { - int w = physdev->x11dev->dc_rect.right - physdev->x11dev->dc_rect.left; - int h = physdev->x11dev->dc_rect.bottom - physdev->x11dev->dc_rect.top; - - /* (glX)SwapBuffers has an implicit glFlush effect, however - * GLX_MESA_copy_sub_buffer doesn't. Make sure GL is flushed before - * copying */ - pglFlush(); - if(w > 0 && h > 0) - pglXCopySubBufferMESA(gdi_display, physdev->drawable, 0, 0, w, h); - break; - } - /* fall through */ - default: - pglXSwapBuffers(gdi_display, physdev->drawable); - break; - } - flush_gl_drawable( physdev ); + hwnd = WindowFromDC( dev->hdc ); + EnterCriticalSection( &context_section ); + + if (!XFindContext( gdi_display, (XID)hwnd, gl_hwnd_context, (char **)&gl ) || + !XFindContext( gdi_display, (XID)dev->hdc, gl_pbuffer_context, (char **)&gl )) + { + switch (gl->type) + { + case DC_GL_PIXMAP_WIN: + if (pglXCopySubBufferMESA) { + /* (glX)SwapBuffers has an implicit glFlush effect, however + * GLX_MESA_copy_sub_buffer doesn't. Make sure GL is flushed before + * copying */ + pglFlush(); + pglXCopySubBufferMESA( gdi_display, gl->drawable, 0, 0, + gl->rect.right - gl->rect.left, gl->rect.bottom - gl->rect.top ); + break; + } + /* fall through */ + default: + pglXSwapBuffers(gdi_display, gl->drawable); + break; + } + } + LeaveCriticalSection( &context_section ); + + ExtEscape( dev->hdc, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code, 0, NULL ); /* FPS support */ if (TRACE_ON(fps)) -- 2.11.4.GIT