gdi32: Allow a driver to implement SelectBitmap but not CreateBitmap.
This commit is contained in:
parent
e94d3b4e08
commit
eb80e6f2db
@ -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
|
* BITMAP_SelectObject
|
||||||
@ -545,7 +502,7 @@ static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc )
|
|||||||
HGDIOBJ ret;
|
HGDIOBJ ret;
|
||||||
BITMAPOBJ *bitmap;
|
BITMAPOBJ *bitmap;
|
||||||
DC *dc;
|
DC *dc;
|
||||||
PHYSDEV physdev = NULL, old_physdev = NULL;
|
PHYSDEV physdev = NULL, old_physdev = NULL, createdev;
|
||||||
|
|
||||||
if (!(dc = get_dc_ptr( hdc ))) return 0;
|
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 );
|
if (dc->dibdrv) old_physdev = pop_dc_driver( dc, dc->dibdrv );
|
||||||
|
|
||||||
physdev = GET_DC_PHYSDEV( dc, pSelectBitmap );
|
physdev = GET_DC_PHYSDEV( dc, pSelectBitmap );
|
||||||
|
createdev = GET_DC_PHYSDEV( dc, pCreateBitmap );
|
||||||
if (physdev->funcs == &null_driver)
|
if (physdev->funcs == &null_driver)
|
||||||
{
|
{
|
||||||
physdev = dc->dibdrv;
|
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)
|
||||||
|
{
|
||||||
|
/* 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 );
|
GDI_ReleaseObj( handle );
|
||||||
ret = 0;
|
ret = 0;
|
||||||
goto done;
|
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 ))
|
if (!physdev->funcs->pSelectBitmap( physdev, handle ))
|
||||||
{
|
{
|
||||||
GDI_ReleaseObj( handle );
|
GDI_ReleaseObj( handle );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user