Commit db25d402 authored by Alexandre Julliard's avatar Alexandre Julliard

winex11: Simplify wglSetPixelFormatWINE and export it as a standard extension function.

parent 02b00ffb
...@@ -101,27 +101,6 @@ static HGLRC WINAPI wglCreateContextAttribsARB(HDC hdc, HGLRC hShareContext, con ...@@ -101,27 +101,6 @@ static HGLRC WINAPI wglCreateContextAttribsARB(HDC hdc, HGLRC hShareContext, con
return ret; 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 * Internal wglGetProcAddress for retrieving WGL extensions
*/ */
...@@ -151,8 +130,6 @@ PROC WINAPI wglGetProcAddress(LPCSTR func) ...@@ -151,8 +130,6 @@ PROC WINAPI wglGetProcAddress(LPCSTR func)
*/ */
if(ret && strcmp(func, "wglCreateContextAttribsARB") == 0) if(ret && strcmp(func, "wglCreateContextAttribsARB") == 0)
return (PROC)wglCreateContextAttribsARB; return (PROC)wglCreateContextAttribsARB;
else if(ret && strcmp(func, "wglSetPixelFormatWINE") == 0)
return (PROC)wglSetPixelFormatWINE;
return ret; return ret;
} }
......
...@@ -741,7 +741,7 @@ static BOOL context_set_pixel_format(const struct wined3d_gl_info *gl_info, HDC ...@@ -741,7 +741,7 @@ static BOOL context_set_pixel_format(const struct wined3d_gl_info *gl_info, HDC
* when really needed. */ * when really needed. */
if (gl_info->supported[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH]) 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", ERR("wglSetPixelFormatWINE failed to set pixel format %d on device context %p.\n",
format, dc); format, dc);
......
...@@ -3770,8 +3770,7 @@ typedef BOOL (WINAPI *WINED3D_PFNWGLCHOOSEPIXELFORMATARBPROC)(HDC hdc, const int ...@@ -3770,8 +3770,7 @@ typedef BOOL (WINAPI *WINED3D_PFNWGLCHOOSEPIXELFORMATARBPROC)(HDC hdc, const int
#endif #endif
/* WGL_WINE_pixel_format_passthrough */ /* WGL_WINE_pixel_format_passthrough */
typedef BOOL (WINAPI *WINED3D_PFNWGLSETPIXELFORMATWINE)(HDC hdc, int iPixelFormat, typedef BOOL (WINAPI *WINED3D_PFNWGLSETPIXELFORMATWINE)(HDC hdc, int iPixelFormat);
const PIXELFORMATDESCRIPTOR *ppfd);
typedef BOOL (WINAPI *WINED3D_PFNWGLSWAPINTERVALEXTPROC)(int interval); typedef BOOL (WINAPI *WINED3D_PFNWGLSWAPINTERVALEXTPROC)(int interval);
......
...@@ -1310,17 +1310,25 @@ static int glxdrv_GetPixelFormat(PHYSDEV dev) ...@@ -1310,17 +1310,25 @@ static int glxdrv_GetPixelFormat(PHYSDEV dev)
return physdev->pixel_format; 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 * glxdrv_SetPixelFormat
* set the pixel format multiple times. */ *
static BOOL internal_SetPixelFormat( struct glx_physdev *physdev, * Set the pixel-format id used by this DC
int iPixelFormat, */
const PIXELFORMATDESCRIPTOR *ppfd) static BOOL glxdrv_SetPixelFormat(PHYSDEV dev, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd)
{ {
struct glx_physdev *physdev = get_glxdrv_dev( dev );
WineGLPixelFormat *fmt; WineGLPixelFormat *fmt;
int value; int value;
HWND hwnd; 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) */ /* SetPixelFormat is not allowed on the X root_window e.g. GetDC(0) */
if(physdev->x11dev->drawable == root_window) if(physdev->x11dev->drawable == root_window)
{ {
...@@ -1385,26 +1393,6 @@ static BOOL internal_SetPixelFormat( struct glx_physdev *physdev, ...@@ -1385,26 +1393,6 @@ static BOOL internal_SetPixelFormat( struct glx_physdev *physdev,
return TRUE; 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 * X11DRV_wglCopyContext
* *
...@@ -2991,24 +2979,45 @@ static void WINAPI X11DRV_wglFreeMemoryNV(GLvoid* pointer) { ...@@ -2991,24 +2979,45 @@ static void WINAPI X11DRV_wglFreeMemoryNV(GLvoid* pointer) {
} }
/** /**
* glxdrv_wglSetPixelFormatWINE * X11DRV_wglSetPixelFormatWINE
* *
* WGL_WINE_pixel_format_passthrough: wglSetPixelFormatWINE * WGL_WINE_pixel_format_passthrough: wglSetPixelFormatWINE
* This is a WINE-specific wglSetPixelFormat which can set the pixel format multiple times. * 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;
}
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;
}
/* Relay to the core SetPixelFormat */ return SendMessageW(hwnd, WM_X11DRV_SET_WIN_FORMAT, fmt->fmt_id, 0);
TRACE("Changing iPixelFormat from %d to %d\n", physdev->pixel_format, iPixelFormat); /* DC pixel format will be set by the DCE update */
return internal_SetPixelFormat(physdev, iPixelFormat, ppfd);
} }
/** /**
...@@ -3167,7 +3176,7 @@ static const WineGLExtension WGL_WINE_pixel_format_passthrough = ...@@ -3167,7 +3176,7 @@ static const WineGLExtension WGL_WINE_pixel_format_passthrough =
{ {
"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 = ...@@ -3586,7 +3595,7 @@ static const struct gdi_dc_funcs glxdrv_funcs =
glxdrv_wglGetProcAddress, /* pwglGetProcAddress */ glxdrv_wglGetProcAddress, /* pwglGetProcAddress */
NULL, /* pwglMakeContextCurrentARB */ NULL, /* pwglMakeContextCurrentARB */
NULL, /* pwglMakeCurrent */ NULL, /* pwglMakeCurrent */
glxdrv_wglSetPixelFormatWINE, /* pwglSetPixelFormatWINE */ NULL, /* pwglSetPixelFormatWINE */
GDI_PRIORITY_GRAPHICS_DRV + 20 /* priority */ GDI_PRIORITY_GRAPHICS_DRV + 20 /* priority */
}; };
......
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