Commit eb80e6f2 authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Allow a driver to implement SelectBitmap but not CreateBitmap.

parent e94d3b4e
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment