Alexandre Julliard : winex11: Get the current pixel format from the drawable structure in wglGetPixelFormat .

Alexandre Julliard julliard at winehq.org
Fri Sep 7 13:26:21 CDT 2012


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Sep  7 15:31:05 2012 +0200

winex11: Get the current pixel format from the drawable structure in wglGetPixelFormat.

---

 dlls/winex11.drv/opengl.c |   30 +++++++++++++-----------------
 1 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index d5d3ca9..a31c5ef 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -1509,26 +1509,22 @@ static int glxdrv_wglDescribePixelFormat( HDC hdc, int iPixelFormat,
  */
 static int glxdrv_wglGetPixelFormat( HDC hdc )
 {
-    struct x11drv_escape_get_drawable escape;
-
-    TRACE( "(%p)\n", hdc );
+    HWND hwnd = WindowFromDC( hdc );
+    struct gl_drawable *gl;
+    int ret = 0;
 
-    escape.code = X11DRV_GET_DRAWABLE;
-    if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape.code), (LPCSTR)&escape.code,
-                    sizeof(escape), (LPSTR)&escape ))
-        return 0;
+    EnterCriticalSection( &context_section );
+    if (!XFindContext( gdi_display, (XID)hwnd, gl_hwnd_context, (char **)&gl ) ||
+        !XFindContext( gdi_display, (XID)hdc, gl_pbuffer_context, (char **)&gl ))
+        ret = gl->pixel_format;
+    LeaveCriticalSection( &context_section );
 
-    if (!is_valid_pixel_format( escape.pixel_format )) return 0;  /* not set yet */
+    /* Offscreen formats can't be used with traditional WGL calls.
+     * As has been verified on Windows GetPixelFormat doesn't fail but returns iPixelFormat=1. */
+    if (ret && !is_onscreen_pixel_format( ret )) ret = 1;
 
-    if (!is_onscreen_pixel_format( escape.pixel_format ))
-    {
-        /* 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", escape.pixel_format);
-        return 1;
-    }
-    TRACE("(%p): returns %d\n", hdc, escape.pixel_format);
-    return escape.pixel_format;
+    TRACE( "%p -> %d\n", hdc, ret );
+    return ret;
 }
 
 /***********************************************************************




More information about the wine-cvs mailing list