From 05c32b9b89b2abebde2d665863b4c959b064d064 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 7 Sep 2012 21:11:55 +0200 Subject: [PATCH] gdi32: Move the SwapBuffers entry point to the OpenGL driver. --- dlls/gdi32/dibdrv/dc.c | 2 -- dlls/gdi32/dibdrv/opengl.c | 9 +++++++++ dlls/gdi32/driver.c | 6 ------ dlls/gdi32/enhmfdrv/init.c | 1 - dlls/gdi32/freetype.c | 1 - dlls/gdi32/mfdrv/init.c | 1 - dlls/gdi32/painting.c | 15 ++------------- dlls/gdi32/path.c | 1 - dlls/opengl32/make_opengl | 1 + dlls/opengl32/opengl_norm.c | 2 ++ dlls/opengl32/wgl.c | 27 +++++++++++++-------------- dlls/wineps.drv/init.c | 1 - dlls/winex11.drv/init.c | 1 - dlls/winex11.drv/opengl.c | 31 +++++++++++++------------------ dlls/winex11.drv/xrender.c | 1 - include/wine/gdi_driver.h | 3 +-- include/wine/wgl_driver.h | 3 ++- 17 files changed, 43 insertions(+), 63 deletions(-) diff --git a/dlls/gdi32/dibdrv/dc.c b/dlls/gdi32/dibdrv/dc.c index 97fb33ba7ae..00e2229a2a9 100644 --- a/dlls/gdi32/dibdrv/dc.c +++ b/dlls/gdi32/dibdrv/dc.c @@ -531,7 +531,6 @@ const struct gdi_dc_funcs dib_driver = NULL, /* pStretchDIBits */ NULL, /* pStrokeAndFillPath */ NULL, /* pStrokePath */ - NULL, /* pSwapBuffers */ NULL, /* pUnrealizePalette */ NULL, /* pWidenPath */ dibdrv_wine_get_wgl_driver, /* wine_get_wgl_driver */ @@ -1139,7 +1138,6 @@ static const struct gdi_dc_funcs window_driver = windrv_StretchDIBits, /* pStretchDIBits */ NULL, /* pStrokeAndFillPath */ NULL, /* pStrokePath */ - NULL, /* pSwapBuffers */ NULL, /* pUnrealizePalette */ NULL, /* pWidenPath */ windrv_wine_get_wgl_driver, /* wine_get_wgl_driver */ diff --git a/dlls/gdi32/dibdrv/opengl.c b/dlls/gdi32/dibdrv/opengl.c index 7956484f806..740dc5068b3 100644 --- a/dlls/gdi32/dibdrv/opengl.c +++ b/dlls/gdi32/dibdrv/opengl.c @@ -304,6 +304,14 @@ static BOOL dibdrv_wglShareLists( struct wgl_context *org, struct wgl_context *d return FALSE; } +/*********************************************************************** + * dibdrv_wglSwapBuffers + */ +static BOOL dibdrv_wglSwapBuffers( HDC hdc ) +{ + return TRUE; +} + static struct opengl_funcs opengl_funcs = { { @@ -316,6 +324,7 @@ static struct opengl_funcs opengl_funcs = dibdrv_wglMakeCurrent, /* p_wglMakeCurrent */ dibdrv_wglSetPixelFormat, /* p_wglSetPixelFormat */ dibdrv_wglShareLists, /* p_wglShareLists */ + dibdrv_wglSwapBuffers, /* p_wglSwapBuffers */ } }; diff --git a/dlls/gdi32/driver.c b/dlls/gdi32/driver.c index 4cf868f2455..b60f0cfe593 100644 --- a/dlls/gdi32/driver.c +++ b/dlls/gdi32/driver.c @@ -640,11 +640,6 @@ static INT nulldrv_StartPage( PHYSDEV dev ) return 1; } -static BOOL nulldrv_SwapBuffers( PHYSDEV dev ) -{ - return TRUE; -} - static BOOL nulldrv_UnrealizePalette( HPALETTE palette ) { return FALSE; @@ -781,7 +776,6 @@ const struct gdi_dc_funcs null_driver = nulldrv_StretchDIBits, /* pStretchDIBits */ nulldrv_StrokeAndFillPath, /* pStrokeAndFillPath */ nulldrv_StrokePath, /* pStrokePath */ - nulldrv_SwapBuffers, /* pSwapBuffers */ nulldrv_UnrealizePalette, /* pUnrealizePalette */ nulldrv_WidenPath, /* pWidenPath */ nulldrv_wine_get_wgl_driver, /* wine_get_wgl_driver */ diff --git a/dlls/gdi32/enhmfdrv/init.c b/dlls/gdi32/enhmfdrv/init.c index 489a9ae7a0c..bd4c90644b8 100644 --- a/dlls/gdi32/enhmfdrv/init.c +++ b/dlls/gdi32/enhmfdrv/init.c @@ -160,7 +160,6 @@ static const struct gdi_dc_funcs EMFDRV_Funcs = EMFDRV_StretchDIBits, /* pStretchDIBits */ EMFDRV_StrokeAndFillPath, /* pStrokeAndFillPath */ EMFDRV_StrokePath, /* pStrokePath */ - NULL, /* pSwapBuffers */ NULL, /* pUnrealizePalette */ EMFDRV_WidenPath, /* pWidenPath */ NULL, /* wine_get_wgl_driver */ diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index 20d6f9ea0c9..28ca6161238 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -7851,7 +7851,6 @@ static const struct gdi_dc_funcs freetype_funcs = NULL, /* pStretchDIBits */ NULL, /* pStrokeAndFillPath */ NULL, /* pStrokePath */ - NULL, /* pSwapBuffers */ NULL, /* pUnrealizePalette */ NULL, /* pWidenPath */ NULL, /* wine_get_wgl_driver */ diff --git a/dlls/gdi32/mfdrv/init.c b/dlls/gdi32/mfdrv/init.c index c44c932c98d..f75637c1a7a 100644 --- a/dlls/gdi32/mfdrv/init.c +++ b/dlls/gdi32/mfdrv/init.c @@ -223,7 +223,6 @@ static const struct gdi_dc_funcs MFDRV_Funcs = MFDRV_StretchDIBits, /* pStretchDIBits */ MFDRV_StrokeAndFillPath, /* pStrokeAndFillPath */ MFDRV_StrokePath, /* pStrokePath */ - NULL, /* pSwapBuffers */ NULL, /* pUnrealizePalette */ MFDRV_WidenPath, /* pWidenPath */ NULL, /* wine_get_wgl_driver */ diff --git a/dlls/gdi32/painting.c b/dlls/gdi32/painting.c index e0edd72178e..023e183b0f6 100644 --- a/dlls/gdi32/painting.c +++ b/dlls/gdi32/painting.c @@ -525,19 +525,8 @@ INT WINAPI GdiDescribePixelFormat( HDC hdc, INT format, UINT size, PIXELFORMATDE */ BOOL WINAPI GdiSwapBuffers( HDC hdc ) { - INT bRet = FALSE; - DC * dc = get_dc_ptr( hdc ); - - TRACE("(%p)\n",hdc); - - if (dc) - { - PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSwapBuffers ); - update_dc( dc ); - bRet = physdev->funcs->pSwapBuffers( physdev ); - release_dc_ptr( dc ); - } - return bRet; + FIXME( "(%p): stub\n", hdc ); + return FALSE; } diff --git a/dlls/gdi32/path.c b/dlls/gdi32/path.c index 11e5e07ef90..38210cad792 100644 --- a/dlls/gdi32/path.c +++ b/dlls/gdi32/path.c @@ -2344,7 +2344,6 @@ const struct gdi_dc_funcs path_driver = NULL, /* pStretchDIBits */ NULL, /* pStrokeAndFillPath */ NULL, /* pStrokePath */ - NULL, /* pSwapBuffers */ NULL, /* pUnrealizePalette */ NULL, /* pWidenPath */ NULL, /* wine_get_wgl_driver */ diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 500a150d58e..0651904b78e 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -637,6 +637,7 @@ my %wgl_functions = [ "const PIXELFORMATDESCRIPTOR *", "descr" ] ] ], "wglShareLists" => [ "BOOL", [ [ "struct wgl_context *", "org" ], [ "struct wgl_context *", "dst" ] ] ], + "wglSwapBuffers" => [ "BOOL", [ [ "HDC", "hdc" ] ] ], ); my %supported_wgl_extensions = diff --git a/dlls/opengl32/opengl_norm.c b/dlls/opengl32/opengl_norm.c index dad27395ce3..a6beba4b067 100644 --- a/dlls/opengl32/opengl_norm.c +++ b/dlls/opengl32/opengl_norm.c @@ -3034,6 +3034,7 @@ static PROC null_wglGetProcAddress( LPCSTR name ) { return 0; } static BOOL null_wglMakeCurrent( HDC hdc, struct wgl_context * context ) { return 0; } static BOOL null_wglSetPixelFormat( HDC hdc, INT format, const PIXELFORMATDESCRIPTOR * descr ) { return 0; } static BOOL null_wglShareLists( struct wgl_context * org, struct wgl_context * dst ) { return 0; } +static BOOL null_wglSwapBuffers( HDC hdc ) { return 0; } static void null_glAccum( GLenum op, GLfloat value ) { } static void null_glAlphaFunc( GLenum func, GLfloat ref ) { } static GLboolean null_glAreTexturesResident( GLsizei n, const GLuint* textures, GLboolean* residences ) { return 0; } @@ -5524,6 +5525,7 @@ struct opengl_funcs null_opengl_funcs = null_wglMakeCurrent, null_wglSetPixelFormat, null_wglShareLists, + null_wglSwapBuffers, }, { null_glAccum, diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index e5a1bae6df4..8ed2a0e110b 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -41,7 +41,6 @@ #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(wgl); -WINE_DECLARE_DEBUG_CHANNEL(opengl); static HMODULE opengl32_handle; @@ -49,9 +48,6 @@ extern struct opengl_funcs null_opengl_funcs; const GLubyte * WINAPI wine_glGetString( GLenum name ); -/* internal GDI functions */ -extern BOOL WINAPI GdiSwapBuffers( HDC hdc ); - /* handle management */ #define MAX_WGL_HANDLES 1024 @@ -599,6 +595,17 @@ BOOL WINAPI wglSetPixelFormat( HDC hdc, INT format, const PIXELFORMATDESCRIPTOR return funcs->wgl.p_wglSetPixelFormat( hdc, format, descr ); } +/*********************************************************************** + * wglSwapBuffers (OPENGL32.@) + */ +BOOL WINAPI DECLSPEC_HOTPATCH wglSwapBuffers( HDC hdc ) +{ + const struct opengl_funcs *funcs = get_dc_funcs( hdc ); + + if (!funcs || !funcs->wgl.p_wglSwapBuffers) return FALSE; + return funcs->wgl.p_wglSwapBuffers( hdc ); +} + /*********************************************************************** * wglCreateLayerContext (OPENGL32.@) */ @@ -814,10 +821,10 @@ int WINAPI wglSetLayerPaletteEntries(HDC hdc, */ BOOL WINAPI wglSwapLayerBuffers(HDC hdc, UINT fuPlanes) { - TRACE_(opengl)("(%p, %08x)\n", hdc, fuPlanes); + TRACE("(%p, %08x)\n", hdc, fuPlanes); if (fuPlanes & WGL_SWAP_MAIN_PLANE) { - if (!GdiSwapBuffers(hdc)) return FALSE; + if (!wglSwapBuffers( hdc )) return FALSE; fuPlanes &= ~WGL_SWAP_MAIN_PLANE; } @@ -1559,14 +1566,6 @@ const GLubyte * WINAPI wine_glGetString( GLenum name ) return ret; } -/*********************************************************************** - * wglSwapBuffers (OPENGL32.@) - */ -BOOL WINAPI DECLSPEC_HOTPATCH wglSwapBuffers( HDC hdc ) -{ - return GdiSwapBuffers(hdc); -} - /*********************************************************************** * OpenGL initialisation routine */ diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index 9a4889cd951..3f31f45e883 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -834,7 +834,6 @@ static const struct gdi_dc_funcs psdrv_funcs = NULL, /* pStretchDIBits */ PSDRV_StrokeAndFillPath, /* pStrokeAndFillPath */ PSDRV_StrokePath, /* pStrokePath */ - NULL, /* pSwapBuffers */ NULL, /* pUnrealizePalette */ NULL, /* pWidenPath */ NULL, /* wine_get_wgl_driver */ diff --git a/dlls/winex11.drv/init.c b/dlls/winex11.drv/init.c index 8124ab58cc4..3a464d380f8 100644 --- a/dlls/winex11.drv/init.c +++ b/dlls/winex11.drv/init.c @@ -538,7 +538,6 @@ static const struct gdi_dc_funcs x11drv_funcs = NULL, /* pStretchDIBits */ NULL, /* pStrokeAndFillPath */ NULL, /* pStrokePath */ - NULL, /* pSwapBuffers */ X11DRV_UnrealizePalette, /* pUnrealizePalette */ NULL, /* pWidenPath */ NULL, /* wine_get_wgl_driver */ diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 32a10ac0799..281c17e74ab 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -3026,33 +3026,25 @@ static void X11DRV_WineGL_LoadExtensions(void) * * Swap the buffers of this DC */ -static BOOL glxdrv_SwapBuffers(PHYSDEV dev) +static BOOL glxdrv_wglSwapBuffers( HDC hdc ) { enum x11drv_escape_codes code = X11DRV_FLUSH_GL_DRAWABLE; struct gl_drawable *gl; - HWND hwnd; - struct wgl_context *ctx = NtCurrentTeb()->glContext; + struct wgl_context *ctx = NtCurrentTeb()->glContext; + HWND hwnd = WindowFromDC( hdc ); + BOOL ret = FALSE; - TRACE("(%p)\n", dev->hdc); + TRACE("(%p)\n", hdc); - if (!ctx) - { - WARN("Using a NULL context, skipping\n"); - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - - sync_context(ctx); - - 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 )) + !XFindContext( gdi_display, (XID)hdc, gl_pbuffer_context, (char **)&gl )) { switch (gl->type) { case DC_GL_PIXMAP_WIN: + if (ctx) sync_context( ctx ); if (pglXCopySubBufferMESA) { /* (glX)SwapBuffers has an implicit glFlush effect, however * GLX_MESA_copy_sub_buffer doesn't. Make sure GL is flushed before @@ -3067,10 +3059,13 @@ static BOOL glxdrv_SwapBuffers(PHYSDEV dev) pglXSwapBuffers(gdi_display, gl->drawable); break; } + ret = TRUE; } + else SetLastError( ERROR_INVALID_HANDLE ); + LeaveCriticalSection( &context_section ); - ExtEscape( dev->hdc, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code, 0, NULL ); + ExtEscape( hdc, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code, 0, NULL ); /* FPS support */ if (TRACE_ON(fps)) @@ -3091,7 +3086,7 @@ static BOOL glxdrv_SwapBuffers(PHYSDEV dev) } } - return TRUE; + return ret; } static BOOL create_glx_dc( PHYSDEV *pdev ) @@ -3341,7 +3336,6 @@ static const struct gdi_dc_funcs glxdrv_funcs = NULL, /* pStretchDIBits */ NULL, /* pStrokeAndFillPath */ NULL, /* pStrokePath */ - glxdrv_SwapBuffers, /* pSwapBuffers */ NULL, /* pUnrealizePalette */ NULL, /* pWidenPath */ glxdrv_wine_get_wgl_driver, /* wine_get_wgl_driver */ @@ -3360,6 +3354,7 @@ static struct opengl_funcs opengl_funcs = glxdrv_wglMakeCurrent, /* p_wglMakeCurrent */ glxdrv_wglSetPixelFormat, /* p_wglSetPixelFormat */ glxdrv_wglShareLists, /* p_wglShareLists */ + glxdrv_wglSwapBuffers, /* p_wglSwapBuffers */ } }; diff --git a/dlls/winex11.drv/xrender.c b/dlls/winex11.drv/xrender.c index 5d884509ca8..e2ecbf5cad1 100644 --- a/dlls/winex11.drv/xrender.c +++ b/dlls/winex11.drv/xrender.c @@ -2486,7 +2486,6 @@ static const struct gdi_dc_funcs xrender_funcs = NULL, /* pStretchDIBits */ NULL, /* pStrokeAndFillPath */ NULL, /* pStrokePath */ - NULL, /* pSwapBuffers */ NULL, /* pUnrealizePalette */ NULL, /* pWidenPath */ NULL, /* wine_get_wgl_driver */ diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index 21145fbd238..c58803ddf5a 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -188,7 +188,6 @@ struct gdi_dc_funcs INT (*pStretchDIBits)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT,const void*,BITMAPINFO*,UINT,DWORD); BOOL (*pStrokeAndFillPath)(PHYSDEV); BOOL (*pStrokePath)(PHYSDEV); - BOOL (*pSwapBuffers)(PHYSDEV); BOOL (*pUnrealizePalette)(HPALETTE); BOOL (*pWidenPath)(PHYSDEV); struct opengl_funcs * (*wine_get_wgl_driver)(PHYSDEV,UINT); @@ -198,7 +197,7 @@ struct gdi_dc_funcs }; /* increment this when you change the DC function table */ -#define WINE_GDI_DRIVER_VERSION 43 +#define WINE_GDI_DRIVER_VERSION 44 #define GDI_PRIORITY_NULL_DRV 0 /* null driver */ #define GDI_PRIORITY_FONT_DRV 100 /* any font driver */ diff --git a/include/wine/wgl_driver.h b/include/wine/wgl_driver.h index e2065dd515d..a9385e6030f 100644 --- a/include/wine/wgl_driver.h +++ b/include/wine/wgl_driver.h @@ -7,7 +7,7 @@ #define WINE_GLAPI #endif -#define WINE_WGL_DRIVER_VERSION 7 +#define WINE_WGL_DRIVER_VERSION 8 struct wgl_context; struct wgl_pbuffer; @@ -25,6 +25,7 @@ struct opengl_funcs BOOL (WINE_GLAPI *p_wglMakeCurrent)(HDC,struct wgl_context *); BOOL (WINE_GLAPI *p_wglSetPixelFormat)(HDC,INT,const PIXELFORMATDESCRIPTOR *); BOOL (WINE_GLAPI *p_wglShareLists)(struct wgl_context *,struct wgl_context *); + BOOL (WINE_GLAPI *p_wglSwapBuffers)(HDC); } wgl; struct