From 30550d2e6da6d0a166e65372acb3c4d537834a3c Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 2 Jul 2021 12:38:34 +0200 Subject: [PATCH] gdi32: Introduce NtGdiSelectBitmap. Signed-off-by: Jacek Caban Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/gdi32/bitmap.c | 15 ++++++++++--- dlls/gdi32/dib.c | 54 +-------------------------------------------- 2 files changed, 13 insertions(+), 56 deletions(-) diff --git a/dlls/gdi32/bitmap.c b/dlls/gdi32/bitmap.c index bb1d7d4eebd..3d2c2e365e1 100644 --- a/dlls/gdi32/bitmap.c +++ b/dlls/gdi32/bitmap.c @@ -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 diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c index 2e55579fb6e..fdd7c9bcfbc 100644 --- a/dlls/gdi32/dib.c +++ b/dlls/gdi32/dib.c @@ -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 ); }