From 09eb59d3c654681f2e6b3246275378c604f88d6a Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 3 Aug 2011 11:37:02 +0200 Subject: [PATCH] gdi32: Set the initial bits of a bitmap from the gdi side. --- dlls/gdi32/bitmap.c | 14 ++++++++++++-- dlls/gdi32/driver.c | 2 +- dlls/winex11.drv/bitmap.c | 24 ++++++++---------------- dlls/winex11.drv/x11drv.h | 2 +- include/wine/gdi_driver.h | 4 ++-- 5 files changed, 24 insertions(+), 22 deletions(-) diff --git a/dlls/gdi32/bitmap.c b/dlls/gdi32/bitmap.c index f0c5764bab5..5970d7f98c2 100644 --- a/dlls/gdi32/bitmap.c +++ b/dlls/gdi32/bitmap.c @@ -657,6 +657,12 @@ HBITMAP BITMAP_CopyBitmap(HBITMAP hbitmap) } +static void set_initial_bitmap_bits( HBITMAP hbitmap, BITMAPOBJ *bmp ) +{ + if (!bmp->bitmap.bmBits) return; + SetBitmapBits( hbitmap, bmp->bitmap.bmHeight * bmp->bitmap.bmWidthBytes, bmp->bitmap.bmBits ); +} + /*********************************************************************** * BITMAP_SetOwnerDC * @@ -681,8 +687,12 @@ BOOL BITMAP_SetOwnerDC( HBITMAP hbitmap, PHYSDEV physdev ) { if (physdev->funcs->pCreateBitmap) { - ret = physdev->funcs->pCreateBitmap( physdev, hbitmap, bitmap->bitmap.bmBits ); - if (ret) bitmap->funcs = physdev->funcs; + ret = physdev->funcs->pCreateBitmap( physdev, hbitmap ); + if (ret) + { + bitmap->funcs = physdev->funcs; + set_initial_bitmap_bits( hbitmap, bitmap ); + } } else { diff --git a/dlls/gdi32/driver.c b/dlls/gdi32/driver.c index dc4a33b9385..9d958d8c322 100644 --- a/dlls/gdi32/driver.c +++ b/dlls/gdi32/driver.c @@ -213,7 +213,7 @@ static BOOL nulldrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom return TRUE; } -static BOOL nulldrv_CreateBitmap( PHYSDEV dev, HBITMAP bitmap, LPVOID bits ) +static BOOL nulldrv_CreateBitmap( PHYSDEV dev, HBITMAP bitmap ) { return TRUE; } diff --git a/dlls/winex11.drv/bitmap.c b/dlls/winex11.drv/bitmap.c index 15ecb051366..503f3bb69d4 100644 --- a/dlls/winex11.drv/bitmap.c +++ b/dlls/winex11.drv/bitmap.c @@ -132,7 +132,7 @@ HBITMAP X11DRV_SelectBitmap( PHYSDEV dev, HBITMAP hbitmap ) * * Returns TRUE on success else FALSE */ -BOOL X11DRV_CreateBitmap( PHYSDEV dev, HBITMAP hbitmap, LPVOID bmBits ) +BOOL X11DRV_CreateBitmap( PHYSDEV dev, HBITMAP hbitmap ) { X_PHYSBITMAP *physBitmap; BITMAP bitmap; @@ -178,6 +178,13 @@ BOOL X11DRV_CreateBitmap( PHYSDEV dev, HBITMAP hbitmap, LPVOID bmBits ) /* Create the pixmap */ physBitmap->pixmap = XCreatePixmap(gdi_display, root_window, bitmap.bmWidth, bitmap.bmHeight, physBitmap->pixmap_depth); + if (physBitmap->pixmap) + { + GC gc = get_bitmap_gc(physBitmap->pixmap_depth); + XSetFunction( gdi_display, gc, GXclear ); + XFillRectangle( gdi_display, physBitmap->pixmap, gc, 0, 0, bitmap.bmWidth, bitmap.bmHeight ); + XSetFunction( gdi_display, gc, GXcopy ); + } wine_tsx11_unlock(); if (!physBitmap->pixmap) { @@ -185,21 +192,6 @@ BOOL X11DRV_CreateBitmap( PHYSDEV dev, HBITMAP hbitmap, LPVOID bmBits ) HeapFree( GetProcessHeap(), 0, physBitmap ); return FALSE; } - - if (bmBits) /* Set bitmap bits */ - { - X11DRV_SetBitmapBits( hbitmap, bmBits, bitmap.bmHeight * bitmap.bmWidthBytes ); - } - else /* else clear the bitmap */ - { - GC gc = get_bitmap_gc(physBitmap->pixmap_depth); - wine_tsx11_lock(); - XSetFunction( gdi_display, gc, GXclear ); - XFillRectangle( gdi_display, physBitmap->pixmap, gc, 0, 0, - bitmap.bmWidth, bitmap.bmHeight ); - XSetFunction( gdi_display, gc, GXcopy ); - wine_tsx11_unlock(); - } return TRUE; } diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 30fc62e71af..d54dda785be 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -187,7 +187,7 @@ extern BOOL X11DRV_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom, INT xstart, INT ystart, INT xend, INT yend ) DECLSPEC_HIDDEN; extern BOOL X11DRV_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom, INT xstart, INT ystart, INT xend, INT yend ) DECLSPEC_HIDDEN; -extern BOOL X11DRV_CreateBitmap( PHYSDEV dev, HBITMAP hbitmap, LPVOID bmBits ) DECLSPEC_HIDDEN; +extern BOOL X11DRV_CreateBitmap( PHYSDEV dev, HBITMAP hbitmap ) DECLSPEC_HIDDEN; extern HBITMAP X11DRV_CreateDIBSection( PHYSDEV dev, HBITMAP hbitmap, const BITMAPINFO *bmi, UINT usage ) DECLSPEC_HIDDEN; extern BOOL X11DRV_DeleteBitmap( HBITMAP hbitmap ) DECLSPEC_HIDDEN; diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index cffd3f6cd5d..5cd867ee14c 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -64,7 +64,7 @@ struct gdi_dc_funcs INT (*pChoosePixelFormat)(PHYSDEV,const PIXELFORMATDESCRIPTOR *); BOOL (*pChord)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT); BOOL (*pCloseFigure)(PHYSDEV); - BOOL (*pCreateBitmap)(PHYSDEV,HBITMAP,LPVOID); + BOOL (*pCreateBitmap)(PHYSDEV,HBITMAP); BOOL (*pCreateDC)(HDC,PHYSDEV *,LPCWSTR,LPCWSTR,LPCWSTR,const DEVMODEW*); HBITMAP (*pCreateDIBSection)(PHYSDEV,HBITMAP,const BITMAPINFO *,UINT); BOOL (*pDeleteBitmap)(HBITMAP); @@ -189,7 +189,7 @@ struct gdi_dc_funcs }; /* increment this when you change the DC function table */ -#define WINE_GDI_DRIVER_VERSION 9 +#define WINE_GDI_DRIVER_VERSION 10 static inline PHYSDEV get_physdev_entry_point( PHYSDEV dev, size_t offset ) {