Alexandre Julliard : winex11: Always create the brush pixmap from the pattern bits.

Alexandre Julliard julliard at winehq.org
Thu May 24 14:58:12 CDT 2012


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed May 23 21:44:59 2012 +0200

winex11: Always create the brush pixmap from the pattern bits.

---

 dlls/winex11.drv/brush.c   |   79 +-------------------------------------------
 dlls/winex11.drv/x11drv.h  |    1 -
 dlls/winex11.drv/xrender.c |   44 ++++++------------------
 3 files changed, 12 insertions(+), 112 deletions(-)

diff --git a/dlls/winex11.drv/brush.c b/dlls/winex11.drv/brush.c
index 6574eb8..3406190 100644
--- a/dlls/winex11.drv/brush.c
+++ b/dlls/winex11.drv/brush.c
@@ -210,76 +210,6 @@ static void BRUSH_SelectSolidBrush( X11DRV_PDEVICE *physDev, COLORREF color )
 }
 
 
-/***********************************************************************
- *           BRUSH_SelectPatternBrush
- */
-static void BRUSH_SelectPatternBrush( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, X_PHYSBITMAP *physBitmap )
-{
-    BITMAP bitmap;
-
-    GetObjectW( hbitmap, sizeof(bitmap), &bitmap );
-
-    wine_tsx11_lock();
-
-    if (physDev->brush.pixmap) XFreePixmap( gdi_display, physDev->brush.pixmap );
-
-    if ((physDev->depth == 1) && (physBitmap->depth != 1))
-    {
-        /* Special case: a color pattern on a monochrome DC */
-        physDev->brush.pixmap = XCreatePixmap( gdi_display, root_window,
-                                               bitmap.bmWidth, bitmap.bmHeight, 1);
-        /* FIXME: should probably convert to monochrome instead */
-        XCopyPlane( gdi_display, physBitmap->pixmap, physDev->brush.pixmap,
-                    get_bitmap_gc(1), 0, 0, bitmap.bmWidth, bitmap.bmHeight, 0, 0, 1 );
-    }
-    else
-    {
-        physDev->brush.pixmap = XCreatePixmap( gdi_display, root_window,
-                                               bitmap.bmWidth, bitmap.bmHeight, physBitmap->depth );
-        XCopyArea( gdi_display, physBitmap->pixmap, physDev->brush.pixmap,
-                   get_bitmap_gc(physBitmap->depth), 0, 0, bitmap.bmWidth, bitmap.bmHeight, 0, 0 );
-    }
-    wine_tsx11_unlock();
-
-    if (physBitmap->depth > 1)
-    {
-	physDev->brush.fillStyle = FillTiled;
-	physDev->brush.pixel = 0;  /* Ignored */
-    }
-    else
-    {
-	physDev->brush.fillStyle = FillOpaqueStippled;
-	physDev->brush.pixel = -1;  /* Special case (see DC_SetupGCForBrush) */
-    }
-}
-
-/* create a bitmap appropriate for the given DIB pattern brush */
-HBITMAP create_brush_bitmap( X11DRV_PDEVICE *physDev, const struct brush_pattern *pattern )
-{
-    HDC memdc;
-    int bpp = screen_bpp;
-    HBITMAP bitmap;
-    const BITMAPINFO *info = pattern->info;
-
-    if (physDev->depth == 1 || info->bmiHeader.biBitCount == 1) bpp = 1;
-    bitmap = CreateBitmap( info->bmiHeader.biWidth, abs(info->bmiHeader.biHeight), 1, bpp, NULL );
-    if (!bitmap) return 0;
-
-    /* make sure it's owned by x11drv */
-    memdc = CreateCompatibleDC( physDev->dev.hdc );
-    SelectObject( memdc, bitmap );
-    DeleteDC( memdc );
-    if (!X11DRV_get_phys_bitmap( bitmap ))
-    {
-        DeleteObject( bitmap );
-        return 0;
-    }
-
-    SetDIBits( physDev->dev.hdc, bitmap, 0, abs(info->bmiHeader.biHeight),
-               pattern->bits.ptr, info, pattern->usage );
-    return bitmap;
-}
-
 static BOOL select_pattern_brush( X11DRV_PDEVICE *physdev, const struct brush_pattern *pattern )
 {
     XVisualInfo vis;
@@ -330,14 +260,7 @@ HBRUSH X11DRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_patter
 
     if (pattern)  /* pattern brush */
     {
-        X_PHYSBITMAP *physbitmap;
-        HBITMAP bitmap = pattern->bitmap;
-
-        if (!bitmap || !(physbitmap = X11DRV_get_phys_bitmap( bitmap )))
-        {
-            if (!select_pattern_brush( physDev, pattern )) return 0;
-        }
-        else BRUSH_SelectPatternBrush( physDev, bitmap, physbitmap );
+        if (!select_pattern_brush( physDev, pattern )) return 0;
         TRACE("BS_PATTERN\n");
         physDev->brush.style = BS_PATTERN;
         return hbrush;
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 9b05e3e..7ea8164 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -221,7 +221,6 @@ extern void X11DRV_Xcursor_Init(void) DECLSPEC_HIDDEN;
 extern void X11DRV_BITMAP_Init(void) DECLSPEC_HIDDEN;
 extern void X11DRV_XInput2_Init(void) DECLSPEC_HIDDEN;
 
-extern HBITMAP create_brush_bitmap( X11DRV_PDEVICE *physDev, const struct brush_pattern *pattern ) DECLSPEC_HIDDEN;
 extern X_PHYSBITMAP *X11DRV_get_phys_bitmap( HBITMAP hbitmap ) DECLSPEC_HIDDEN;
 extern X_PHYSBITMAP *X11DRV_init_phys_bitmap( HBITMAP hbitmap ) DECLSPEC_HIDDEN;
 extern X_PHYSBITMAP *X11DRV_create_phys_bitmap( HBITMAP hbitmap, const BITMAP *bitmap, int depth ) DECLSPEC_HIDDEN;
diff --git a/dlls/winex11.drv/xrender.c b/dlls/winex11.drv/xrender.c
index ffd1b4d..91a6bd2 100644
--- a/dlls/winex11.drv/xrender.c
+++ b/dlls/winex11.drv/xrender.c
@@ -2589,56 +2589,34 @@ fallback:
 static HBRUSH xrenderdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_pattern *pattern )
 {
     struct xrender_physdev *physdev = get_xrender_dev( dev );
-    X_PHYSBITMAP *physbitmap;
-    BOOL delete_bitmap = FALSE;
-    BITMAP bm;
-    HBITMAP bitmap;
     Pixmap pixmap;
-    XRenderPictFormat *pict_format;
-    Picture src_pict, dst_pict;
-    XRenderPictureAttributes pa;
+    XVisualInfo vis;
+    XRenderPictFormat *format = physdev->pict_format;
 
     if (!pattern) goto x11drv_fallback;
+    if (pattern->info->bmiHeader.biBitCount == 1) goto x11drv_fallback;
     if (physdev->format == WXR_FORMAT_MONO) goto x11drv_fallback;
 
-    bitmap = pattern->bitmap;
-    if (!bitmap || !(physbitmap = X11DRV_get_phys_bitmap( bitmap )))
-    {
-        if (!(bitmap = create_brush_bitmap( physdev->x11dev, pattern ))) return 0;
-        physbitmap = X11DRV_get_phys_bitmap( bitmap );
-        delete_bitmap = TRUE;
-    }
-
-    if (physbitmap->format == WXR_FORMAT_MONO) goto x11drv_fallback;
-    if (!(pict_format = pict_formats[physbitmap->format])) goto x11drv_fallback;
+    memset( &vis, 0, sizeof(vis) );
+    vis.depth      = format->depth;
+    vis.red_mask   = format->direct.redMask   << format->direct.red;
+    vis.green_mask = format->direct.greenMask << format->direct.green;
+    vis.blue_mask  = format->direct.blueMask  << format->direct.blue;
 
-    GetObjectW( bitmap, sizeof(bm), &bm );
+    pixmap = create_pixmap_from_image( physdev->dev.hdc, &vis, pattern->info,
+                                       &pattern->bits, pattern->usage );
+    if (!pixmap) return 0;
 
     wine_tsx11_lock();
-    pixmap = XCreatePixmap( gdi_display, root_window, bm.bmWidth, bm.bmHeight,
-                            physdev->pict_format->depth );
-
-    pa.repeat = RepeatNone;
-    src_pict = pXRenderCreatePicture(gdi_display, physbitmap->pixmap, pict_format, CPRepeat, &pa);
-    dst_pict = pXRenderCreatePicture(gdi_display, pixmap, physdev->pict_format, CPRepeat, &pa);
-
-    xrender_blit( PictOpSrc, src_pict, 0, dst_pict, 0, 0, bm.bmWidth, bm.bmHeight,
-                  0, 0, bm.bmWidth, bm.bmHeight, 1.0, 1.0 );
-    pXRenderFreePicture( gdi_display, src_pict );
-    pXRenderFreePicture( gdi_display, dst_pict );
-
     if (physdev->x11dev->brush.pixmap) XFreePixmap( gdi_display, physdev->x11dev->brush.pixmap );
     physdev->x11dev->brush.pixmap = pixmap;
     physdev->x11dev->brush.fillStyle = FillTiled;
     physdev->x11dev->brush.pixel = 0;  /* ignored */
     physdev->x11dev->brush.style = BS_PATTERN;
     wine_tsx11_unlock();
-
-    if (delete_bitmap) DeleteObject( bitmap );
     return hbrush;
 
 x11drv_fallback:
-    if (delete_bitmap) DeleteObject( bitmap );
     dev = GET_NEXT_PHYSDEV( dev, pSelectBrush );
     return dev->funcs->pSelectBrush( dev, hbrush, pattern );
 }




More information about the wine-cvs mailing list