Alexandre Julliard : gdi32: Allow a driver to implement SelectBitmap but not CreateBitmap.
Alexandre Julliard
julliard at winehq.org
Tue May 8 14:16:55 CDT 2012
Module: wine
Branch: master
Commit: eb80e6f2dbf89cb15c2b9086af55714a54cf6c3b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=eb80e6f2dbf89cb15c2b9086af55714a54cf6c3b
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue May 8 14:32:23 2012 +0200
gdi32: Allow a driver to implement SelectBitmap but not CreateBitmap.
---
dlls/gdi32/bitmap.c | 73 +++++++++++++++++---------------------------------
1 files changed, 25 insertions(+), 48 deletions(-)
diff --git a/dlls/gdi32/bitmap.c b/dlls/gdi32/bitmap.c
index acb0575..bcc2932 100644
--- a/dlls/gdi32/bitmap.c
+++ b/dlls/gdi32/bitmap.c
@@ -493,49 +493,6 @@ static void set_initial_bitmap_bits( HBITMAP hbitmap, BITMAPOBJ *bmp )
}
}
-/***********************************************************************
- * BITMAP_SetOwnerDC
- *
- * Set the type of DC that owns the bitmap. This is used when the
- * bitmap is selected into a device to initialize the bitmap function
- * table.
- */
-static BOOL BITMAP_SetOwnerDC( HBITMAP hbitmap, PHYSDEV physdev )
-{
- BITMAPOBJ *bitmap;
- BOOL ret = TRUE;
-
- /* never set the owner of the stock bitmap since it can be selected in multiple DCs */
- if (hbitmap == GetStockObject(DEFAULT_BITMAP)) return TRUE;
-
- if (!(bitmap = GDI_GetObjPtr( hbitmap, OBJ_BITMAP ))) return FALSE;
-
- if (bitmap->funcs != physdev->funcs)
- {
- /* we can only change from the null driver to some other driver */
- if (bitmap->funcs == &null_driver)
- {
- if (physdev->funcs->pCreateBitmap)
- {
- ret = physdev->funcs->pCreateBitmap( physdev, hbitmap );
- if (ret)
- {
- bitmap->funcs = physdev->funcs;
- set_initial_bitmap_bits( hbitmap, bitmap );
- }
- }
- else bitmap->funcs = &dib_driver; /* use the DIB driver to emulate DDB support */
- }
- else
- {
- FIXME( "Trying to select bitmap %p in different DC type\n", hbitmap );
- ret = FALSE;
- }
- }
- GDI_ReleaseObj( hbitmap );
- return ret;
-}
-
/***********************************************************************
* BITMAP_SelectObject
@@ -545,7 +502,7 @@ static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc )
HGDIOBJ ret;
BITMAPOBJ *bitmap;
DC *dc;
- PHYSDEV physdev = NULL, old_physdev = NULL;
+ PHYSDEV physdev = NULL, old_physdev = NULL, createdev;
if (!(dc = get_dc_ptr( hdc ))) return 0;
@@ -574,6 +531,7 @@ static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc )
if (dc->dibdrv) old_physdev = pop_dc_driver( dc, dc->dibdrv );
physdev = GET_DC_PHYSDEV( dc, pSelectBitmap );
+ createdev = GET_DC_PHYSDEV( dc, pCreateBitmap );
if (physdev->funcs == &null_driver)
{
physdev = dc->dibdrv;
@@ -585,12 +543,31 @@ static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc )
}
}
- if (!BITMAP_SetOwnerDC( handle, physdev ))
+ /* never set the owner of the stock bitmap since it can be selected in multiple DCs */
+ if (handle != GetStockObject(DEFAULT_BITMAP) && bitmap->funcs != createdev->funcs)
{
- GDI_ReleaseObj( handle );
- ret = 0;
- goto done;
+ /* we can only change from the null driver to some other driver */
+ if (bitmap->funcs != &null_driver)
+ {
+ FIXME( "Trying to select bitmap %p in different DC type\n", handle );
+ GDI_ReleaseObj( handle );
+ ret = 0;
+ goto done;
+ }
+ if (createdev->funcs != &null_driver)
+ {
+ if (!createdev->funcs->pCreateBitmap( createdev, handle ))
+ {
+ GDI_ReleaseObj( handle );
+ ret = 0;
+ goto done;
+ }
+ bitmap->funcs = createdev->funcs;
+ set_initial_bitmap_bits( handle, bitmap );
+ }
+ else bitmap->funcs = &dib_driver; /* use the DIB driver to emulate DDB support */
}
+
if (!physdev->funcs->pSelectBitmap( physdev, handle ))
{
GDI_ReleaseObj( handle );
More information about the wine-cvs
mailing list