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

Alexandre Julliard julliard at winehq.org
Thu Jun 28 13:55:16 CDT 2012


Module: wine
Branch: master
Commit: db25d4022aad801a455bea09267a4be8ed0206fb
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=db25d4022aad801a455bea09267a4be8ed0206fb

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Jun 28 12:00:45 2012 +0200

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

---

 dlls/gdi32/opengl.c       |   23 ------------
 dlls/wined3d/context.c    |    2 +-
 dlls/wined3d/wined3d_gl.h |    3 +-
 dlls/winex11.drv/opengl.c |   83 +++++++++++++++++++++++++--------------------
 4 files changed, 48 insertions(+), 63 deletions(-)

diff --git a/dlls/gdi32/opengl.c b/dlls/gdi32/opengl.c
index 90c2a87..df7424d 100644
--- a/dlls/gdi32/opengl.c
+++ b/dlls/gdi32/opengl.c
@@ -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;
 }
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index b5db3e1..e53936f 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -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);
diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h
index fe156d0..51281e4 100644
--- a/dlls/wined3d/wined3d_gl.h
+++ b/dlls/wined3d/wined3d_gl.h
@@ -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);
 
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index b78edc3..09694f1 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -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;
+    }
+
+    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 */
-    TRACE("Changing iPixelFormat from %d to %d\n", physdev->pixel_format, iPixelFormat);
-    return internal_SetPixelFormat(physdev, iPixelFormat, ppfd);
+    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 */
 };
 




More information about the wine-cvs mailing list