From 28721d69f46191e92751a619c9f39d8309f0f6bf Mon Sep 17 00:00:00 2001
From: Alexandre Julliard <julliard@winehq.org>
Date: Tue, 2 Oct 2012 22:05:57 +0200
Subject: [PATCH] winex11: Get rid of the OpenGL GDI driver.

---
 dlls/winex11.drv/init.c   |  21 +++-
 dlls/winex11.drv/opengl.c | 216 ++------------------------------------
 dlls/winex11.drv/x11drv.h |   2 +-
 3 files changed, 26 insertions(+), 213 deletions(-)

diff --git a/dlls/winex11.drv/init.c b/dlls/winex11.drv/init.c
index 12cff170723..a27b05280ac 100644
--- a/dlls/winex11.drv/init.c
+++ b/dlls/winex11.drv/init.c
@@ -123,7 +123,6 @@ static X11DRV_PDEVICE *create_x11_physdev( Drawable drawable )
 static BOOL X11DRV_CreateDC( PHYSDEV *pdev, LPCWSTR driver, LPCWSTR device,
                              LPCWSTR output, const DEVMODEW* initData )
 {
-    const struct gdi_dc_funcs *glx_funcs = get_glx_driver();
     X11DRV_PDEVICE *physDev = create_x11_physdev( root_window );
 
     if (!physDev) return FALSE;
@@ -134,7 +133,6 @@ static BOOL X11DRV_CreateDC( PHYSDEV *pdev, LPCWSTR driver, LPCWSTR device,
              virtual_screen_rect.bottom - virtual_screen_rect.top );
     push_dc_driver( pdev, &physDev->dev, &x11drv_funcs );
     if (xrender_funcs && !xrender_funcs->pCreateDC( pdev, driver, device, output, initData )) return FALSE;
-    if (glx_funcs && !glx_funcs->pCreateDC( pdev, driver, device, output, initData )) return FALSE;
     return TRUE;
 }
 
@@ -144,7 +142,6 @@ static BOOL X11DRV_CreateDC( PHYSDEV *pdev, LPCWSTR driver, LPCWSTR device,
  */
 static BOOL X11DRV_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev )
 {
-    const struct gdi_dc_funcs *glx_funcs = get_glx_driver();
     X11DRV_PDEVICE *physDev = create_x11_physdev( stock_bitmap_pixmap );
 
     if (!physDev) return FALSE;
@@ -154,7 +151,6 @@ static BOOL X11DRV_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev )
     push_dc_driver( pdev, &physDev->dev, &x11drv_funcs );
     if (orig) return TRUE;  /* we already went through Xrender if we have an orig device */
     if (xrender_funcs && !xrender_funcs->pCreateCompatibleDC( NULL, pdev )) return FALSE;
-    if (glx_funcs && !glx_funcs->pCreateCompatibleDC( NULL, pdev )) return FALSE;
     return TRUE;
 }
 
@@ -432,6 +428,21 @@ static INT X11DRV_ExtEscape( PHYSDEV dev, INT escape, INT in_count, LPCVOID in_d
     return 0;
 }
 
+/**********************************************************************
+ *           X11DRV_wine_get_wgl_driver
+ */
+static struct opengl_funcs * X11DRV_wine_get_wgl_driver( PHYSDEV dev, UINT version )
+{
+    struct opengl_funcs *ret;
+
+    if (!(ret = get_glx_driver( version )))
+    {
+        dev = GET_NEXT_PHYSDEV( dev, wine_get_wgl_driver );
+        ret = dev->funcs->wine_get_wgl_driver( dev, version );
+    }
+    return ret;
+}
+
 
 static const struct gdi_dc_funcs x11drv_funcs =
 {
@@ -561,7 +572,7 @@ static const struct gdi_dc_funcs x11drv_funcs =
     NULL,                               /* pStrokePath */
     X11DRV_UnrealizePalette,            /* pUnrealizePalette */
     NULL,                               /* pWidenPath */
-    NULL,                               /* wine_get_wgl_driver */
+    X11DRV_wine_get_wgl_driver,         /* wine_get_wgl_driver */
     GDI_PRIORITY_GRAPHICS_DRV           /* priority */
 };
 
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index 4b6cb1ff01a..3e68131c45c 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -181,16 +181,6 @@ enum dc_gl_type
     DC_GL_PBUFFER     /* pseudo memory DC using a PBuffer */
 };
 
-struct glx_physdev
-{
-    struct gdi_physdev             dev;
-    X11DRV_PDEVICE                *x11dev;
-    enum dc_gl_type                type;          /* type of GL device context */
-    const struct wgl_pixel_format *format;
-    Drawable                       drawable;
-    Pixmap                         pixmap;        /* pixmap for a DL_GL_PIXMAP_WIN drawable */
-};
-
 struct gl_drawable
 {
     enum dc_gl_type                type;         /* type of GL surface */
@@ -3078,200 +3068,6 @@ static BOOL glxdrv_wglSwapBuffers( HDC hdc )
     return TRUE;
 }
 
-static BOOL create_glx_dc( PHYSDEV *pdev )
-{
-    /* assume that only the main x11 device implements GetDeviceCaps */
-    X11DRV_PDEVICE *x11dev = get_x11drv_dev( GET_NEXT_PHYSDEV( *pdev, pGetDeviceCaps ));
-    struct glx_physdev *physdev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physdev) );
-
-    if (!physdev) return FALSE;
-    physdev->x11dev = x11dev;
-    push_dc_driver( pdev, &physdev->dev, &glxdrv_funcs );
-    return TRUE;
-}
-
-/**********************************************************************
- *	     glxdrv_CreateDC
- */
-static BOOL glxdrv_CreateDC( PHYSDEV *pdev, LPCWSTR driver, LPCWSTR device,
-                             LPCWSTR output, const DEVMODEW* initData )
-{
-    return create_glx_dc( pdev );
-}
-
-/**********************************************************************
- *	     glxdrv_CreateCompatibleDC
- */
-static BOOL glxdrv_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev )
-{
-    if (orig)  /* chain to next driver first */
-    {
-        orig = GET_NEXT_PHYSDEV( orig, pCreateCompatibleDC );
-        if (!orig->funcs->pCreateCompatibleDC( orig, pdev )) return FALSE;
-    }
-    /* otherwise we have been called by x11drv */
-    return create_glx_dc( pdev );
-}
-
-/**********************************************************************
- *	     glxdrv_DeleteDC
- */
-static BOOL glxdrv_DeleteDC( PHYSDEV dev )
-{
-    struct glx_physdev *physdev = get_glxdrv_dev( dev );
-    HeapFree( GetProcessHeap(), 0, physdev );
-    return TRUE;
-}
-
-/**********************************************************************
- *           glxdrv_wine_get_wgl_driver
- */
-static struct opengl_funcs * glxdrv_wine_get_wgl_driver( PHYSDEV dev, UINT version )
-{
-    if (version != WINE_WGL_DRIVER_VERSION)
-    {
-        ERR( "version mismatch, opengl32 wants %u but driver has %u\n", version, WINE_WGL_DRIVER_VERSION );
-        return NULL;
-    }
-
-    if (has_opengl()) return &opengl_funcs;
-
-    dev = GET_NEXT_PHYSDEV( dev, wine_get_wgl_driver );
-    return dev->funcs->wine_get_wgl_driver( dev, version );
-}
-
-static const struct gdi_dc_funcs glxdrv_funcs =
-{
-    NULL,                               /* pAbortDoc */
-    NULL,                               /* pAbortPath */
-    NULL,                               /* pAlphaBlend */
-    NULL,                               /* pAngleArc */
-    NULL,                               /* pArc */
-    NULL,                               /* pArcTo */
-    NULL,                               /* pBeginPath */
-    NULL,                               /* pBlendImage */
-    NULL,                               /* pChord */
-    NULL,                               /* pCloseFigure */
-    glxdrv_CreateCompatibleDC,          /* pCreateCompatibleDC */
-    glxdrv_CreateDC,                    /* pCreateDC */
-    glxdrv_DeleteDC,                    /* pDeleteDC */
-    NULL,                               /* pDeleteObject */
-    NULL,                               /* pDeviceCapabilities */
-    NULL,                               /* pEllipse */
-    NULL,                               /* pEndDoc */
-    NULL,                               /* pEndPage */
-    NULL,                               /* pEndPath */
-    NULL,                               /* pEnumFonts */
-    NULL,                               /* pEnumICMProfiles */
-    NULL,                               /* pExcludeClipRect */
-    NULL,                               /* pExtDeviceMode */
-    NULL,                               /* pExtEscape */
-    NULL,                               /* pExtFloodFill */
-    NULL,                               /* pExtSelectClipRgn */
-    NULL,                               /* pExtTextOut */
-    NULL,                               /* pFillPath */
-    NULL,                               /* pFillRgn */
-    NULL,                               /* pFlattenPath */
-    NULL,                               /* pFontIsLinked */
-    NULL,                               /* pFrameRgn */
-    NULL,                               /* pGdiComment */
-    NULL,                               /* pGdiRealizationInfo */
-    NULL,                               /* pGetBoundsRect */
-    NULL,                               /* pGetCharABCWidths */
-    NULL,                               /* pGetCharABCWidthsI */
-    NULL,                               /* pGetCharWidth */
-    NULL,                               /* pGetDeviceCaps */
-    NULL,                               /* pGetDeviceGammaRamp */
-    NULL,                               /* pGetFontData */
-    NULL,                               /* pGetFontUnicodeRanges */
-    NULL,                               /* pGetGlyphIndices */
-    NULL,                               /* pGetGlyphOutline */
-    NULL,                               /* pGetICMProfile */
-    NULL,                               /* pGetImage */
-    NULL,                               /* pGetKerningPairs */
-    NULL,                               /* pGetNearestColor */
-    NULL,                               /* pGetOutlineTextMetrics */
-    NULL,                               /* pGetPixel */
-    NULL,                               /* pGetSystemPaletteEntries */
-    NULL,                               /* pGetTextCharsetInfo */
-    NULL,                               /* pGetTextExtentExPoint */
-    NULL,                               /* pGetTextExtentExPointI */
-    NULL,                               /* pGetTextFace */
-    NULL,                               /* pGetTextMetrics */
-    NULL,                               /* pGradientFill */
-    NULL,                               /* pIntersectClipRect */
-    NULL,                               /* pInvertRgn */
-    NULL,                               /* pLineTo */
-    NULL,                               /* pModifyWorldTransform */
-    NULL,                               /* pMoveTo */
-    NULL,                               /* pOffsetClipRgn */
-    NULL,                               /* pOffsetViewportOrg */
-    NULL,                               /* pOffsetWindowOrg */
-    NULL,                               /* pPaintRgn */
-    NULL,                               /* pPatBlt */
-    NULL,                               /* pPie */
-    NULL,                               /* pPolyBezier */
-    NULL,                               /* pPolyBezierTo */
-    NULL,                               /* pPolyDraw */
-    NULL,                               /* pPolyPolygon */
-    NULL,                               /* pPolyPolyline */
-    NULL,                               /* pPolygon */
-    NULL,                               /* pPolyline */
-    NULL,                               /* pPolylineTo */
-    NULL,                               /* pPutImage */
-    NULL,                               /* pRealizeDefaultPalette */
-    NULL,                               /* pRealizePalette */
-    NULL,                               /* pRectangle */
-    NULL,                               /* pResetDC */
-    NULL,                               /* pRestoreDC */
-    NULL,                               /* pRoundRect */
-    NULL,                               /* pSaveDC */
-    NULL,                               /* pScaleViewportExt */
-    NULL,                               /* pScaleWindowExt */
-    NULL,                               /* pSelectBitmap */
-    NULL,                               /* pSelectBrush */
-    NULL,                               /* pSelectClipPath */
-    NULL,                               /* pSelectFont */
-    NULL,                               /* pSelectPalette */
-    NULL,                               /* pSelectPen */
-    NULL,                               /* pSetArcDirection */
-    NULL,                               /* pSetBkColor */
-    NULL,                               /* pSetBkMode */
-    NULL,                               /* pSetBoundsRect */
-    NULL,                               /* pSetDCBrushColor */
-    NULL,                               /* pSetDCPenColor */
-    NULL,                               /* pSetDIBitsToDevice */
-    NULL,                               /* pSetDeviceClipping */
-    NULL,                               /* pSetDeviceGammaRamp */
-    NULL,                               /* pSetLayout */
-    NULL,                               /* pSetMapMode */
-    NULL,                               /* pSetMapperFlags */
-    NULL,                               /* pSetPixel */
-    NULL,                               /* pSetPolyFillMode */
-    NULL,                               /* pSetROP2 */
-    NULL,                               /* pSetRelAbs */
-    NULL,                               /* pSetStretchBltMode */
-    NULL,                               /* pSetTextAlign */
-    NULL,                               /* pSetTextCharacterExtra */
-    NULL,                               /* pSetTextColor */
-    NULL,                               /* pSetTextJustification */
-    NULL,                               /* pSetViewportExt */
-    NULL,                               /* pSetViewportOrg */
-    NULL,                               /* pSetWindowExt */
-    NULL,                               /* pSetWindowOrg */
-    NULL,                               /* pSetWorldTransform */
-    NULL,                               /* pStartDoc */
-    NULL,                               /* pStartPage */
-    NULL,                               /* pStretchBlt */
-    NULL,                               /* pStretchDIBits */
-    NULL,                               /* pStrokeAndFillPath */
-    NULL,                               /* pStrokePath */
-    NULL,                               /* pUnrealizePalette */
-    NULL,                               /* pWidenPath */
-    glxdrv_wine_get_wgl_driver,         /* wine_get_wgl_driver */
-    GDI_PRIORITY_GRAPHICS_DRV + 20      /* priority */
-};
-
 static struct opengl_funcs opengl_funcs =
 {
     {
@@ -3288,14 +3084,20 @@ static struct opengl_funcs opengl_funcs =
     }
 };
 
-const struct gdi_dc_funcs *get_glx_driver(void)
+struct opengl_funcs *get_glx_driver( UINT version )
 {
-    return &glxdrv_funcs;
+    if (version != WINE_WGL_DRIVER_VERSION)
+    {
+        ERR( "version mismatch, opengl32 wants %u but driver has %u\n", version, WINE_WGL_DRIVER_VERSION );
+        return NULL;
+    }
+    if (has_opengl()) return &opengl_funcs;
+    return NULL;
 }
 
 #else  /* no OpenGL includes */
 
-const struct gdi_dc_funcs *get_glx_driver(void)
+struct opengl_funcs *get_glx_driver( UINT version )
 {
     return NULL;
 }
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 1f286da581d..a13d25c7698 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -214,7 +214,7 @@ extern int client_side_antialias_with_core DECLSPEC_HIDDEN;
 extern int client_side_antialias_with_render DECLSPEC_HIDDEN;
 extern const struct gdi_dc_funcs *X11DRV_XRender_Init(void) DECLSPEC_HIDDEN;
 
-extern const struct gdi_dc_funcs *get_glx_driver(void) DECLSPEC_HIDDEN;
+extern struct opengl_funcs *get_glx_driver(UINT) DECLSPEC_HIDDEN;
 
 /* IME support */
 extern void IME_SetOpenStatus(BOOL fOpen) DECLSPEC_HIDDEN;
-- 
GitLab