winex11: Simplify wglSetPixelFormatWINE and export it as a standard extension function.
This commit is contained in:
parent
02b00ffb27
commit
db25d4022a
|
@ -101,27 +101,6 @@ static HGLRC WINAPI wglCreateContextAttribsARB(HDC hdc, HGLRC hShareContext, con
|
|||
return ret;
|
||||
}
|
||||
|
||||
/**************************************************************************************
|
||||
* WINE-specific wglSetPixelFormat which can set the iPixelFormat multiple times
|
||||
*
|
||||
*/
|
||||
static BOOL WINAPI wglSetPixelFormatWINE(HDC hdc, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd)
|
||||
{
|
||||
INT bRet = FALSE;
|
||||
DC * dc = get_dc_ptr( hdc );
|
||||
|
||||
TRACE("(%p,%d,%p)\n", hdc, iPixelFormat, ppfd);
|
||||
|
||||
if (dc)
|
||||
{
|
||||
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pwglSetPixelFormatWINE );
|
||||
update_dc( dc );
|
||||
bRet = physdev->funcs->pwglSetPixelFormatWINE( physdev, iPixelFormat, ppfd );
|
||||
release_dc_ptr( dc );
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* Internal wglGetProcAddress for retrieving WGL extensions
|
||||
*/
|
||||
|
@ -151,8 +130,6 @@ PROC WINAPI wglGetProcAddress(LPCSTR func)
|
|||
*/
|
||||
if(ret && strcmp(func, "wglCreateContextAttribsARB") == 0)
|
||||
return (PROC)wglCreateContextAttribsARB;
|
||||
else if(ret && strcmp(func, "wglSetPixelFormatWINE") == 0)
|
||||
return (PROC)wglSetPixelFormatWINE;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -741,7 +741,7 @@ static BOOL context_set_pixel_format(const struct wined3d_gl_info *gl_info, HDC
|
|||
* when really needed. */
|
||||
if (gl_info->supported[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH])
|
||||
{
|
||||
if (!GL_EXTCALL(wglSetPixelFormatWINE(dc, format, NULL)))
|
||||
if (!GL_EXTCALL(wglSetPixelFormatWINE(dc, format)))
|
||||
{
|
||||
ERR("wglSetPixelFormatWINE failed to set pixel format %d on device context %p.\n",
|
||||
format, dc);
|
||||
|
|
|
@ -3770,8 +3770,7 @@ typedef BOOL (WINAPI *WINED3D_PFNWGLCHOOSEPIXELFORMATARBPROC)(HDC hdc, const int
|
|||
#endif
|
||||
|
||||
/* WGL_WINE_pixel_format_passthrough */
|
||||
typedef BOOL (WINAPI *WINED3D_PFNWGLSETPIXELFORMATWINE)(HDC hdc, int iPixelFormat,
|
||||
const PIXELFORMATDESCRIPTOR *ppfd);
|
||||
typedef BOOL (WINAPI *WINED3D_PFNWGLSETPIXELFORMATWINE)(HDC hdc, int iPixelFormat);
|
||||
|
||||
typedef BOOL (WINAPI *WINED3D_PFNWGLSWAPINTERVALEXTPROC)(int interval);
|
||||
|
||||
|
|
|
@ -1310,17 +1310,25 @@ static int glxdrv_GetPixelFormat(PHYSDEV dev)
|
|||
return physdev->pixel_format;
|
||||
}
|
||||
|
||||
/* This function is the core of X11DRV_SetPixelFormat and X11DRV_SetPixelFormatWINE.
|
||||
* Both functions are the same except that X11DRV_SetPixelFormatWINE allows you to
|
||||
* set the pixel format multiple times. */
|
||||
static BOOL internal_SetPixelFormat( struct glx_physdev *physdev,
|
||||
int iPixelFormat,
|
||||
const PIXELFORMATDESCRIPTOR *ppfd)
|
||||
/**
|
||||
* glxdrv_SetPixelFormat
|
||||
*
|
||||
* Set the pixel-format id used by this DC
|
||||
*/
|
||||
static BOOL glxdrv_SetPixelFormat(PHYSDEV dev, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd)
|
||||
{
|
||||
struct glx_physdev *physdev = get_glxdrv_dev( dev );
|
||||
WineGLPixelFormat *fmt;
|
||||
int value;
|
||||
HWND hwnd;
|
||||
|
||||
TRACE("(%p,%d,%p)\n", dev->hdc, iPixelFormat, ppfd);
|
||||
|
||||
if (!has_opengl()) return FALSE;
|
||||
|
||||
if(physdev->pixel_format) /* cannot change it if already set */
|
||||
return (physdev->pixel_format == iPixelFormat);
|
||||
|
||||
/* SetPixelFormat is not allowed on the X root_window e.g. GetDC(0) */
|
||||
if(physdev->x11dev->drawable == root_window)
|
||||
{
|
||||
|
@ -1385,26 +1393,6 @@ static BOOL internal_SetPixelFormat( struct glx_physdev *physdev,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* glxdrv_SetPixelFormat
|
||||
*
|
||||
* Set the pixel-format id used by this DC
|
||||
*/
|
||||
static BOOL glxdrv_SetPixelFormat(PHYSDEV dev, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd)
|
||||
{
|
||||
struct glx_physdev *physdev = get_glxdrv_dev( dev );
|
||||
|
||||
TRACE("(%p,%d,%p)\n", dev->hdc, iPixelFormat, ppfd);
|
||||
|
||||
if (!has_opengl()) return FALSE;
|
||||
|
||||
if(physdev->pixel_format) /* cannot change it if already set */
|
||||
return (physdev->pixel_format == iPixelFormat);
|
||||
|
||||
return internal_SetPixelFormat(physdev, iPixelFormat, ppfd);
|
||||
}
|
||||
|
||||
/**
|
||||
* X11DRV_wglCopyContext
|
||||
*
|
||||
|
@ -2991,24 +2979,45 @@ static void WINAPI X11DRV_wglFreeMemoryNV(GLvoid* pointer) {
|
|||
}
|
||||
|
||||
/**
|
||||
* glxdrv_wglSetPixelFormatWINE
|
||||
* X11DRV_wglSetPixelFormatWINE
|
||||
*
|
||||
* WGL_WINE_pixel_format_passthrough: wglSetPixelFormatWINE
|
||||
* This is a WINE-specific wglSetPixelFormat which can set the pixel format multiple times.
|
||||
*/
|
||||
static BOOL glxdrv_wglSetPixelFormatWINE(PHYSDEV dev, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd)
|
||||
static BOOL WINAPI X11DRV_wglSetPixelFormatWINE(HDC hdc, int format)
|
||||
{
|
||||
struct glx_physdev *physdev = get_glxdrv_dev( dev );
|
||||
WineGLPixelFormat *fmt;
|
||||
int value;
|
||||
HWND hwnd;
|
||||
|
||||
TRACE("(%p,%d,%p)\n", dev->hdc, iPixelFormat, ppfd);
|
||||
TRACE("(%p,%d)\n", hdc, format);
|
||||
|
||||
if (!has_opengl()) return FALSE;
|
||||
fmt = ConvertPixelFormatWGLtoGLX(gdi_display, format, FALSE /* Offscreen */, &value);
|
||||
if (!fmt)
|
||||
{
|
||||
ERR( "Invalid format %d\n", format );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (physdev->pixel_format == iPixelFormat) return TRUE;
|
||||
hwnd = WindowFromDC( hdc );
|
||||
if (!hwnd || hwnd == GetDesktopWindow())
|
||||
{
|
||||
ERR( "not a valid window DC %p\n", hdc );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Relay to the core SetPixelFormat */
|
||||
TRACE("Changing iPixelFormat from %d to %d\n", physdev->pixel_format, iPixelFormat);
|
||||
return internal_SetPixelFormat(physdev, iPixelFormat, ppfd);
|
||||
wine_tsx11_lock();
|
||||
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &value);
|
||||
wine_tsx11_unlock();
|
||||
|
||||
if (!(value & GLX_WINDOW_BIT))
|
||||
{
|
||||
WARN( "Pixel format %d is not compatible for window rendering\n", format );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return SendMessageW(hwnd, WM_X11DRV_SET_WIN_FORMAT, fmt->fmt_id, 0);
|
||||
/* DC pixel format will be set by the DCE update */
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3167,7 +3176,7 @@ static const WineGLExtension WGL_WINE_pixel_format_passthrough =
|
|||
{
|
||||
"WGL_WINE_pixel_format_passthrough",
|
||||
{
|
||||
{ "wglSetPixelFormatWINE", (void *)1 /* not called directly */ },
|
||||
{ "wglSetPixelFormatWINE", X11DRV_wglSetPixelFormatWINE },
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -3586,7 +3595,7 @@ static const struct gdi_dc_funcs glxdrv_funcs =
|
|||
glxdrv_wglGetProcAddress, /* pwglGetProcAddress */
|
||||
NULL, /* pwglMakeContextCurrentARB */
|
||||
NULL, /* pwglMakeCurrent */
|
||||
glxdrv_wglSetPixelFormatWINE, /* pwglSetPixelFormatWINE */
|
||||
NULL, /* pwglSetPixelFormatWINE */
|
||||
GDI_PRIORITY_GRAPHICS_DRV + 20 /* priority */
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue