opengl32: Move GetPixelFormat to the WGL driver.

oldstable
Alexandre Julliard 2012-06-28 15:51:44 +02:00
parent bbdf77a311
commit 8a13afedd6
5 changed files with 50 additions and 62 deletions

View File

@ -42,6 +42,7 @@ static const WCHAR opengl32W[] = {'o','p','e','n','g','l','3','2','.','d','l','l
static HMODULE opengl32; static HMODULE opengl32;
static INT (WINAPI *wglChoosePixelFormat)(HDC,const PIXELFORMATDESCRIPTOR *); static INT (WINAPI *wglChoosePixelFormat)(HDC,const PIXELFORMATDESCRIPTOR *);
static INT (WINAPI *wglDescribePixelFormat)(HDC,INT,UINT,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 *wglSetPixelFormat)(HDC,INT,const PIXELFORMATDESCRIPTOR*);
static BOOL (WINAPI *wglSwapBuffers)(HDC); static BOOL (WINAPI *wglSwapBuffers)(HDC);
@ -130,6 +131,20 @@ INT WINAPI DescribePixelFormat( HDC hdc, INT fmt, UINT size, PIXELFORMATDESCRIPT
return wglDescribePixelFormat( hdc, fmt, size, pfd ); return wglDescribePixelFormat( hdc, fmt, size, pfd );
} }
/******************************************************************************
* 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.@) * SetPixelFormat (GDI32.@)
*/ */

View File

@ -508,35 +508,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.@] * GdiDescribePixelFormat [GDI32.@]
* *

View File

@ -49,7 +49,6 @@ WINE_DECLARE_DEBUG_CHANNEL(opengl);
static struct static struct
{ {
PROC (WINAPI *p_wglGetProcAddress)(LPCSTR lpszProc); PROC (WINAPI *p_wglGetProcAddress)(LPCSTR lpszProc);
INT (WINAPI *p_GetPixelFormat)(HDC hdc);
/* internal WGL functions */ /* internal WGL functions */
void (WINAPI *p_wglFinish)(void); void (WINAPI *p_wglFinish)(void);
@ -361,7 +360,7 @@ INT WINAPI wglDescribePixelFormat(HDC hdc, INT iPixelFormat, UINT nBytes,
*/ */
INT WINAPI wglGetPixelFormat(HDC hdc) 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_wglGetProcAddress = (void *)GetProcAddress(mod_gdi32, "wglGetProcAddress");
wine_wgl.p_GetPixelFormat = (void *)GetProcAddress(mod_gdi32, "GetPixelFormat");
/* internal WGL functions */ /* internal WGL functions */
wine_wgl.p_wglFinish = (void *)wine_wgl.p_wglGetProcAddress("wglFinish"); wine_wgl.p_wglFinish = (void *)wine_wgl.p_wglGetProcAddress("wglFinish");

View File

@ -1281,41 +1281,43 @@ static int glxdrv_DescribePixelFormat(PHYSDEV dev, int iPixelFormat,
return ret; return ret;
} }
/** /***********************************************************************
* glxdrv_GetPixelFormat * glxdrv_GetPixelFormat
*
* Get the pixel-format id used by this DC
*/ */
static int glxdrv_GetPixelFormat(PHYSDEV dev) static int glxdrv_GetPixelFormat( HDC hdc )
{ {
struct glx_physdev *physdev = get_glxdrv_dev( dev ); struct x11drv_escape_get_drawable escape;
WineGLPixelFormat *fmt; WineGLPixelFormat *fmt;
int tmp; int tmp;
if (!physdev->pixel_format) return 0; /* not set yet */ TRACE( "(%p)\n", hdc );
fmt = ConvertPixelFormatWGLtoGLX(gdi_display, physdev->pixel_format, TRUE, &tmp); escape.code = X11DRV_GET_DRAWABLE;
if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape.code), (LPCSTR)&escape.code,
sizeof(escape), (LPSTR)&escape ))
return 0;
if (!escape.pixel_format) return 0; /* not set yet */
fmt = ConvertPixelFormatWGLtoGLX(gdi_display, escape.pixel_format, TRUE, &tmp);
if (!fmt) if (!fmt)
{ {
ERR("Unable to find a WineGLPixelFormat for iPixelFormat=%d\n", physdev->pixel_format); ERR("Unable to find a WineGLPixelFormat for iPixelFormat=%d\n", escape.pixel_format);
return 0; return 0;
} }
else if(fmt->offscreenOnly) if (fmt->offscreenOnly)
{ {
/* Offscreen formats can't be used with traditional WGL calls. /* Offscreen formats can't be used with traditional WGL calls.
* As has been verified on Windows GetPixelFormat doesn't fail but returns iPixelFormat=1. */ * 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); TRACE("Returning iPixelFormat=1 for offscreen format: %d\n", fmt->iPixelFormat);
return 1; return 1;
} }
TRACE("(%p): returns %d\n", hdc, escape.pixel_format);
TRACE("(%p): returns %d\n", dev->hdc, physdev->pixel_format); return escape.pixel_format;
return physdev->pixel_format;
} }
/** /***********************************************************************
* glxdrv_SetPixelFormat * glxdrv_SetPixelFormat
*
* Set the pixel-format id used by this DC
*/ */
static BOOL glxdrv_SetPixelFormat(PHYSDEV dev, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd) 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, /* pGetNearestColor */
NULL, /* pGetOutlineTextMetrics */ NULL, /* pGetOutlineTextMetrics */
NULL, /* pGetPixel */ NULL, /* pGetPixel */
glxdrv_GetPixelFormat, /* pGetPixelFormat */ NULL, /* pGetPixelFormat */
NULL, /* pGetSystemPaletteEntries */ NULL, /* pGetSystemPaletteEntries */
NULL, /* pGetTextCharsetInfo */ NULL, /* pGetTextCharsetInfo */
NULL, /* pGetTextExtentExPoint */ NULL, /* pGetTextExtentExPoint */
@ -3601,6 +3603,7 @@ static const struct gdi_dc_funcs glxdrv_funcs =
static const struct wgl_funcs glxdrv_wgl_funcs = static const struct wgl_funcs glxdrv_wgl_funcs =
{ {
glxdrv_GetPixelFormat, /* p_GetPixelFormat */
glxdrv_wglCopyContext, /* p_wglCopyContext */ glxdrv_wglCopyContext, /* p_wglCopyContext */
glxdrv_wglCreateContext, /* p_wglCreateContext */ glxdrv_wglCreateContext, /* p_wglCreateContext */
glxdrv_wglCreateContextAttribsARB, /* p_wglCreateContextAttribsARB */ glxdrv_wglCreateContextAttribsARB, /* p_wglCreateContextAttribsARB */

View File

@ -203,7 +203,7 @@ struct gdi_dc_funcs
}; };
/* increment this when you change the DC function table */ /* 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_NULL_DRV 0 /* null driver */
#define GDI_PRIORITY_FONT_DRV 100 /* any font 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 struct wgl_funcs
{ {
INT (*p_GetPixelFormat)(HDC);
BOOL (*p_wglCopyContext)(HGLRC,HGLRC,UINT); BOOL (*p_wglCopyContext)(HGLRC,HGLRC,UINT);
HGLRC (*p_wglCreateContext)(HDC); HGLRC (*p_wglCreateContext)(HDC);
HGLRC (*p_wglCreateContextAttribsARB)(HDC,HGLRC,const int*); HGLRC (*p_wglCreateContextAttribsARB)(HDC,HGLRC,const int*);