Alexandre Julliard : opengl32: Move GetPixelFormat to the WGL driver.
Alexandre Julliard
julliard at winehq.org
Thu Jun 28 13:55:16 CDT 2012
Module: wine
Branch: master
Commit: 8a13afedd6970ecccc64f105d7a459bc4292604c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8a13afedd6970ecccc64f105d7a459bc4292604c
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Jun 28 15:51:44 2012 +0200
opengl32: Move GetPixelFormat to the WGL driver.
---
dlls/gdi32/opengl.c | 15 +++++++++++
dlls/gdi32/painting.c | 29 ---------------------
dlls/opengl32/wgl.c | 4 +--
dlls/winex11.drv/opengl.c | 61 +++++++++++++++++++++++---------------------
include/wine/gdi_driver.h | 3 +-
5 files changed, 50 insertions(+), 62 deletions(-)
diff --git a/dlls/gdi32/opengl.c b/dlls/gdi32/opengl.c
index f8e5de7..95db11d 100644
--- a/dlls/gdi32/opengl.c
+++ b/dlls/gdi32/opengl.c
@@ -42,6 +42,7 @@ static const WCHAR opengl32W[] = {'o','p','e','n','g','l','3','2','.','d','l','l
static HMODULE opengl32;
static INT (WINAPI *wglChoosePixelFormat)(HDC,const PIXELFORMATDESCRIPTOR *);
static INT (WINAPI *wglDescribePixelFormat)(HDC,INT,UINT,PIXELFORMATDESCRIPTOR*);
+static INT (WINAPI *wglGetPixelFormat)(HDC);
static BOOL (WINAPI *wglSetPixelFormat)(HDC,INT,const PIXELFORMATDESCRIPTOR*);
static BOOL (WINAPI *wglSwapBuffers)(HDC);
@@ -131,6 +132,20 @@ INT WINAPI DescribePixelFormat( HDC hdc, INT fmt, UINT size, PIXELFORMATDESCRIPT
}
/******************************************************************************
+ * GetPixelFormat (GDI32.@)
+ */
+INT WINAPI GetPixelFormat( HDC hdc )
+{
+ if (!wglGetPixelFormat)
+ {
+ if (!opengl32) opengl32 = LoadLibraryW( opengl32W );
+ if (!(wglGetPixelFormat = (void *)GetProcAddress( opengl32, "wglGetPixelFormat" )))
+ return 0;
+ }
+ return wglGetPixelFormat( hdc );
+}
+
+/******************************************************************************
* SetPixelFormat (GDI32.@)
*/
BOOL WINAPI SetPixelFormat( HDC hdc, INT fmt, const PIXELFORMATDESCRIPTOR *pfd )
diff --git a/dlls/gdi32/painting.c b/dlls/gdi32/painting.c
index 571a96b..822c86a 100644
--- a/dlls/gdi32/painting.c
+++ b/dlls/gdi32/painting.c
@@ -509,35 +509,6 @@ BOOL WINAPI GdiSetPixelFormat( HDC hdc, INT iPixelFormat, const PIXELFORMATDESCR
/******************************************************************************
- * GetPixelFormat [GDI32.@]
- * Gets index of pixel format of DC
- *
- * PARAMETERS
- * hdc [I] Device context whose pixel format index is sought
- *
- * RETURNS
- * Success: Currently selected pixel format
- * Failure: 0
- */
-INT WINAPI GetPixelFormat( HDC hdc )
-{
- INT ret = 0;
- DC * dc = get_dc_ptr( hdc );
-
- TRACE("(%p)\n",hdc);
-
- if (dc)
- {
- PHYSDEV physdev = GET_DC_PHYSDEV( dc, pGetPixelFormat );
- update_dc( dc );
- ret = physdev->funcs->pGetPixelFormat( physdev );
- release_dc_ptr( dc );
- }
- return ret;
-}
-
-
-/******************************************************************************
* GdiDescribePixelFormat [GDI32.@]
*
* Probably not the correct semantics, it's supposed to be an internal backend for DescribePixelFormat.
diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c
index c604774..0a19506 100644
--- a/dlls/opengl32/wgl.c
+++ b/dlls/opengl32/wgl.c
@@ -49,7 +49,6 @@ WINE_DECLARE_DEBUG_CHANNEL(opengl);
static struct
{
PROC (WINAPI *p_wglGetProcAddress)(LPCSTR lpszProc);
- INT (WINAPI *p_GetPixelFormat)(HDC hdc);
/* internal WGL functions */
void (WINAPI *p_wglFinish)(void);
@@ -361,7 +360,7 @@ INT WINAPI wglDescribePixelFormat(HDC hdc, INT iPixelFormat, UINT nBytes,
*/
INT WINAPI wglGetPixelFormat(HDC hdc)
{
- return wine_wgl.p_GetPixelFormat(hdc);
+ return wgl_driver->p_GetPixelFormat( hdc );
}
/***********************************************************************
@@ -1129,7 +1128,6 @@ static BOOL process_attach(void)
}
wine_wgl.p_wglGetProcAddress = (void *)GetProcAddress(mod_gdi32, "wglGetProcAddress");
- wine_wgl.p_GetPixelFormat = (void *)GetProcAddress(mod_gdi32, "GetPixelFormat");
/* internal WGL functions */
wine_wgl.p_wglFinish = (void *)wine_wgl.p_wglGetProcAddress("wglFinish");
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index df625d3..5f7c3d7 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -1281,41 +1281,43 @@ static int glxdrv_DescribePixelFormat(PHYSDEV dev, int iPixelFormat,
return ret;
}
-/**
- * glxdrv_GetPixelFormat
- *
- * Get the pixel-format id used by this DC
+/***********************************************************************
+ * glxdrv_GetPixelFormat
*/
-static int glxdrv_GetPixelFormat(PHYSDEV dev)
+static int glxdrv_GetPixelFormat( HDC hdc )
{
- struct glx_physdev *physdev = get_glxdrv_dev( dev );
- WineGLPixelFormat *fmt;
- int tmp;
+ struct x11drv_escape_get_drawable escape;
+ WineGLPixelFormat *fmt;
+ int tmp;
- if (!physdev->pixel_format) return 0; /* not set yet */
+ TRACE( "(%p)\n", hdc );
- fmt = ConvertPixelFormatWGLtoGLX(gdi_display, physdev->pixel_format, TRUE, &tmp);
- if(!fmt)
- {
- ERR("Unable to find a WineGLPixelFormat for iPixelFormat=%d\n", physdev->pixel_format);
- return 0;
- }
- else if(fmt->offscreenOnly)
- {
- /* Offscreen formats can't be used with traditional WGL calls.
- * As has been verified on Windows GetPixelFormat doesn't fail but returns iPixelFormat=1. */
- TRACE("Returning iPixelFormat=1 for offscreen format: %d\n", fmt->iPixelFormat);
- return 1;
- }
+ escape.code = X11DRV_GET_DRAWABLE;
+ if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape.code), (LPCSTR)&escape.code,
+ sizeof(escape), (LPSTR)&escape ))
+ return 0;
- TRACE("(%p): returns %d\n", dev->hdc, physdev->pixel_format);
- return physdev->pixel_format;
+ if (!escape.pixel_format) return 0; /* not set yet */
+
+ fmt = ConvertPixelFormatWGLtoGLX(gdi_display, escape.pixel_format, TRUE, &tmp);
+ if (!fmt)
+ {
+ ERR("Unable to find a WineGLPixelFormat for iPixelFormat=%d\n", escape.pixel_format);
+ return 0;
+ }
+ if (fmt->offscreenOnly)
+ {
+ /* Offscreen formats can't be used with traditional WGL calls.
+ * As has been verified on Windows GetPixelFormat doesn't fail but returns iPixelFormat=1. */
+ TRACE("Returning iPixelFormat=1 for offscreen format: %d\n", fmt->iPixelFormat);
+ return 1;
+ }
+ TRACE("(%p): returns %d\n", hdc, escape.pixel_format);
+ return escape.pixel_format;
}
-/**
- * glxdrv_SetPixelFormat
- *
- * Set the pixel-format id used by this DC
+/***********************************************************************
+ * glxdrv_SetPixelFormat
*/
static BOOL glxdrv_SetPixelFormat(PHYSDEV dev, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd)
{
@@ -3513,7 +3515,7 @@ static const struct gdi_dc_funcs glxdrv_funcs =
NULL, /* pGetNearestColor */
NULL, /* pGetOutlineTextMetrics */
NULL, /* pGetPixel */
- glxdrv_GetPixelFormat, /* pGetPixelFormat */
+ NULL, /* pGetPixelFormat */
NULL, /* pGetSystemPaletteEntries */
NULL, /* pGetTextCharsetInfo */
NULL, /* pGetTextExtentExPoint */
@@ -3601,6 +3603,7 @@ static const struct gdi_dc_funcs glxdrv_funcs =
static const struct wgl_funcs glxdrv_wgl_funcs =
{
+ glxdrv_GetPixelFormat, /* p_GetPixelFormat */
glxdrv_wglCopyContext, /* p_wglCopyContext */
glxdrv_wglCreateContext, /* p_wglCreateContext */
glxdrv_wglCreateContextAttribsARB, /* p_wglCreateContextAttribsARB */
diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h
index 796d4fa..4f8d0f1 100644
--- a/include/wine/gdi_driver.h
+++ b/include/wine/gdi_driver.h
@@ -203,7 +203,7 @@ struct gdi_dc_funcs
};
/* increment this when you change the DC function table */
-#define WINE_GDI_DRIVER_VERSION 36
+#define WINE_GDI_DRIVER_VERSION 37
#define GDI_PRIORITY_NULL_DRV 0 /* null driver */
#define GDI_PRIORITY_FONT_DRV 100 /* any font driver */
@@ -233,6 +233,7 @@ static inline void push_dc_driver( PHYSDEV *dev, PHYSDEV physdev, const struct g
struct wgl_funcs
{
+ INT (*p_GetPixelFormat)(HDC);
BOOL (*p_wglCopyContext)(HGLRC,HGLRC,UINT);
HGLRC (*p_wglCreateContext)(HDC);
HGLRC (*p_wglCreateContextAttribsARB)(HDC,HGLRC,const int*);
More information about the wine-cvs
mailing list