gdi32: Introduce NtGdiSelectBitmap.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2021-07-02 12:38:34 +02:00 committed by Alexandre Julliard
parent 4dd693a7ea
commit 30550d2e6d
2 changed files with 13 additions and 56 deletions

View File

@ -423,9 +423,9 @@ LONG WINAPI SetBitmapBits(
/***********************************************************************
* BITMAP_SelectObject
* NtGdiSelectBitmap (win32u.@)
*/
static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc )
HGDIOBJ WINAPI NtGdiSelectBitmap( HDC hdc, HGDIOBJ handle )
{
HGDIOBJ ret;
BITMAPOBJ *bitmap;
@ -456,7 +456,8 @@ static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc )
goto done;
}
if (bitmap->dib.dsBm.bmBitsPixel != 1 &&
if (!is_bitmapobj_dib( bitmap ) &&
bitmap->dib.dsBm.bmBitsPixel != 1 &&
bitmap->dib.dsBm.bmBitsPixel != GetDeviceCaps( hdc, BITSPIXEL ))
{
WARN( "Wrong format bitmap %u bpp\n", bitmap->dib.dsBm.bmBitsPixel );
@ -491,6 +492,14 @@ static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc )
return ret;
}
/***********************************************************************
* BITMAP_SelectObject
*/
static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc )
{
return NtGdiSelectBitmap( hdc, handle );
}
/***********************************************************************
* BITMAP_DeleteObject

View File

@ -1722,59 +1722,7 @@ NTSTATUS WINAPI D3DKMTDestroyDCFromMemory( const D3DKMT_DESTROYDCFROMMEMORY *des
*/
static HGDIOBJ DIB_SelectObject( HGDIOBJ handle, HDC hdc )
{
HGDIOBJ ret;
BITMAPOBJ *bitmap;
DC *dc;
PHYSDEV physdev;
if (!(dc = get_dc_ptr( hdc ))) return 0;
if (GetObjectType( hdc ) != OBJ_MEMDC)
{
ret = 0;
goto done;
}
ret = dc->hBitmap;
if (handle == dc->hBitmap) goto done; /* nothing to do */
if (!(bitmap = GDI_GetObjPtr( handle, OBJ_BITMAP )))
{
ret = 0;
goto done;
}
if (GDI_get_ref_count( handle ))
{
WARN( "Bitmap already selected in another DC\n" );
GDI_ReleaseObj( handle );
ret = 0;
goto done;
}
physdev = GET_DC_PHYSDEV( dc, pSelectBitmap );
if (!physdev->funcs->pSelectBitmap( physdev, handle ))
{
GDI_ReleaseObj( handle );
ret = 0;
}
else
{
dc->hBitmap = handle;
GDI_inc_ref_count( handle );
dc->dirty = 0;
dc->vis_rect.left = 0;
dc->vis_rect.top = 0;
dc->vis_rect.right = bitmap->dib.dsBm.bmWidth;
dc->vis_rect.bottom = bitmap->dib.dsBm.bmHeight;
dc->device_rect = dc->vis_rect;
GDI_ReleaseObj( handle );
DC_InitDC( dc );
GDI_dec_ref_count( ret );
}
done:
release_dc_ptr( dc );
return ret;
return NtGdiSelectBitmap( hdc, handle );
}