Commit 05c32b9b authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Move the SwapBuffers entry point to the OpenGL driver.

parent 9713a54b
......@@ -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 */
......
......@@ -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 */
}
};
......
......@@ -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 */
......
......@@ -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 */
......
......@@ -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 */
......
......@@ -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 */
......
......@@ -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;
}
......
......@@ -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 */
......
......@@ -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 =
......
......@@ -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,
......
......@@ -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
......@@ -600,6 +596,17 @@ BOOL WINAPI wglSetPixelFormat( HDC hdc, INT format, const PIXELFORMATDESCRIPTOR
}
/***********************************************************************
* 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.@)
*/
HGLRC WINAPI wglCreateLayerContext(HDC hdc,
......@@ -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;
}
......@@ -1560,14 +1567,6 @@ const GLubyte * WINAPI wine_glGetString( GLenum name )
}
/***********************************************************************
* wglSwapBuffers (OPENGL32.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH wglSwapBuffers( HDC hdc )
{
return GdiSwapBuffers(hdc);
}
/***********************************************************************
* OpenGL initialisation routine
*/
BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
......
......@@ -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 */
......
......@@ -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 */
......
......@@ -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;
TRACE("(%p)\n", dev->hdc);
if (!ctx)
{
WARN("Using a NULL context, skipping\n");
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
struct wgl_context *ctx = NtCurrentTeb()->glContext;
HWND hwnd = WindowFromDC( hdc );
BOOL ret = FALSE;
sync_context(ctx);
TRACE("(%p)\n", hdc);
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 */
}
};
......
......@@ -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 */
......
......@@ -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 */
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment