Jacek Caban : gdi32: Introduce get_gdi_object_type.

Alexandre Julliard julliard at winehq.org
Wed Sep 15 16:21:31 CDT 2021


Module: wine
Branch: master
Commit: a222f974c3144d98d690c1235d5a53c3c39d7334
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=a222f974c3144d98d690c1235d5a53c3c39d7334

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Sep 14 21:51:51 2021 +0200

gdi32: Introduce get_gdi_object_type.

And use it instead of GetObjectType in ntgdi functions.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdi32/bitblt.c        |  2 +-
 dlls/gdi32/bitmap.c        |  4 ++--
 dlls/gdi32/dc.c            |  6 +++---
 dlls/gdi32/dib.c           |  4 ++--
 dlls/gdi32/gdiobj.c        |  5 +++++
 dlls/gdi32/ntgdi_private.h |  1 +
 dlls/gdi32/palette.c       |  2 +-
 dlls/gdi32/path.c          | 14 ++++++++------
 8 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/dlls/gdi32/bitblt.c b/dlls/gdi32/bitblt.c
index cff84bc1dce..0de7932aa95 100644
--- a/dlls/gdi32/bitblt.c
+++ b/dlls/gdi32/bitblt.c
@@ -866,7 +866,7 @@ BOOL WINAPI NtGdiTransparentBlt( HDC hdcDest, int xDest, int yDest, int widthDes
     if(oldStretchMode == BLACKONWHITE || oldStretchMode == WHITEONBLACK)
         SetStretchBltMode(hdcSrc, COLORONCOLOR);
     hdcWork = NtGdiCreateCompatibleDC( hdcDest );
-    if ((GetObjectType( hdcDest ) != OBJ_MEMDC ||
+    if ((get_gdi_object_type( hdcDest ) != NTGDI_OBJ_MEMDC ||
          NtGdiExtGetObjectW( NtGdiGetDCObject( hdcDest, NTGDI_OBJ_SURF ),
                              sizeof(dib), &dib ) == sizeof(BITMAP)) &&
         NtGdiGetDeviceCaps( hdcDest, BITSPIXEL ) == 32)
diff --git a/dlls/gdi32/bitmap.c b/dlls/gdi32/bitmap.c
index ad04603bf69..4a8b899dd52 100644
--- a/dlls/gdi32/bitmap.c
+++ b/dlls/gdi32/bitmap.c
@@ -58,7 +58,7 @@ HBITMAP WINAPI NtGdiCreateCompatibleBitmap( HDC hdc, INT width, INT height )
 
     if (!width || !height) return 0;
 
-    if (GetObjectType( hdc ) != OBJ_MEMDC)
+    if (get_gdi_object_type( hdc ) != NTGDI_OBJ_MEMDC)
         return NtGdiCreateBitmap( width, height,
                                   NtGdiGetDeviceCaps( hdc, PLANES ),
                                   NtGdiGetDeviceCaps( hdc, BITSPIXEL ), NULL );
@@ -373,7 +373,7 @@ HGDIOBJ WINAPI NtGdiSelectBitmap( HDC hdc, HGDIOBJ handle )
 
     if (!(dc = get_dc_ptr( hdc ))) return 0;
 
-    if (GetObjectType( hdc ) != OBJ_MEMDC)
+    if (get_gdi_object_type( hdc ) != NTGDI_OBJ_MEMDC)
     {
         ret = 0;
         goto done;
diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c
index f7b56b06f6f..3c84d2024fe 100644
--- a/dlls/gdi32/dc.c
+++ b/dlls/gdi32/dc.c
@@ -375,7 +375,7 @@ void DC_UpdateXforms( DC *dc )
     /* Reselect the font and pen back into the dc so that the size
        gets updated. */
     if (linear_xform_cmp( &oldworld2vport, &dc->xformWorld2Vport ) &&
-        GetObjectType( dc->hSelf ) != OBJ_METADC)
+        get_gdi_object_type( dc->hSelf ) != NTGDI_OBJ_METADC)
     {
         NtGdiSelectFont(dc->hSelf, dc->hFont);
         NtGdiSelectPen(dc->hSelf, dc->hPen);
@@ -1012,7 +1012,7 @@ BOOL WINAPI NtGdiGetDeviceGammaRamp( HDC hdc, void *ptr )
     TRACE("%p, %p\n", hdc, ptr);
     if( dc )
     {
-        if (GetObjectType( hdc ) != OBJ_MEMDC)
+        if (get_gdi_object_type( hdc ) != NTGDI_OBJ_MEMDC)
         {
             PHYSDEV physdev = GET_DC_PHYSDEV( dc, pGetDeviceGammaRamp );
             ret = physdev->funcs->pGetDeviceGammaRamp( physdev, ptr );
@@ -1112,7 +1112,7 @@ BOOL WINAPI NtGdiSetDeviceGammaRamp( HDC hdc, void *ptr )
     TRACE( "%p, %p\n", hdc, ptr );
     if( dc )
     {
-        if (GetObjectType( hdc ) != OBJ_MEMDC)
+        if (get_gdi_object_type( hdc ) != NTGDI_OBJ_MEMDC)
         {
             PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetDeviceGammaRamp );
 
diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c
index f539df6d41e..9f10f479c2f 100644
--- a/dlls/gdi32/dib.c
+++ b/dlls/gdi32/dib.c
@@ -1689,8 +1689,8 @@ NTSTATUS WINAPI NtGdiDdDDIDestroyDCFromMemory( const D3DKMT_DESTROYDCFROMMEMORY
 
     TRACE("dc %p, bitmap %p.\n", desc->hDc, desc->hBitmap);
 
-    if (GetObjectType( desc->hDc ) != OBJ_MEMDC ||
-        GetObjectType( desc->hBitmap ) != OBJ_BITMAP) return STATUS_INVALID_PARAMETER;
+    if (get_gdi_object_type( desc->hDc ) != NTGDI_OBJ_MEMDC ||
+        get_gdi_object_type( desc->hBitmap ) != NTGDI_OBJ_BITMAP) return STATUS_INVALID_PARAMETER;
     NtGdiDeleteObjectApp( desc->hBitmap );
     NtGdiDeleteObjectApp( desc->hDc );
 
diff --git a/dlls/gdi32/gdiobj.c b/dlls/gdi32/gdiobj.c
index 5787231d087..917d1c91f01 100644
--- a/dlls/gdi32/gdiobj.c
+++ b/dlls/gdi32/gdiobj.c
@@ -816,6 +816,11 @@ void *free_gdi_handle( HGDIOBJ handle )
     return object;
 }
 
+DWORD get_gdi_object_type( HGDIOBJ obj )
+{
+    GDI_HANDLE_ENTRY *entry = handle_entry( obj );
+    return entry ? entry->ExtType << NTGDI_HANDLE_TYPE_SHIFT : 0;
+}
 
 /***********************************************************************
  *           get_any_obj_ptr
diff --git a/dlls/gdi32/ntgdi_private.h b/dlls/gdi32/ntgdi_private.h
index 7f21608b244..8e122dec6a0 100644
--- a/dlls/gdi32/ntgdi_private.h
+++ b/dlls/gdi32/ntgdi_private.h
@@ -383,6 +383,7 @@ extern BOOL GDI_dec_ref_count( HGDIOBJ handle ) DECLSPEC_HIDDEN;
 extern DWORD get_dpi(void) DECLSPEC_HIDDEN;
 extern DWORD get_system_dpi(void) DECLSPEC_HIDDEN;
 extern HGDIOBJ get_stock_object( INT obj ) DECLSPEC_HIDDEN;
+extern DWORD get_gdi_object_type( HGDIOBJ obj ) DECLSPEC_HIDDEN;
 
 /* mapping.c */
 extern BOOL dp_to_lp( DC *dc, POINT *points, INT count ) DECLSPEC_HIDDEN;
diff --git a/dlls/gdi32/palette.c b/dlls/gdi32/palette.c
index e48d4501c6d..c8cd98f6778 100644
--- a/dlls/gdi32/palette.c
+++ b/dlls/gdi32/palette.c
@@ -518,7 +518,7 @@ HPALETTE WINAPI GDISelectPalette( HDC hdc, HPALETTE hpal, WORD wBkg)
 
     TRACE("%p %p\n", hdc, hpal );
 
-    if (GetObjectType(hpal) != OBJ_PAL)
+    if (get_gdi_object_type(hpal) != NTGDI_OBJ_PAL)
     {
       WARN("invalid selected palette %p\n",hpal);
       return 0;
diff --git a/dlls/gdi32/path.c b/dlls/gdi32/path.c
index 94c69302d06..cc6c6c714c2 100644
--- a/dlls/gdi32/path.c
+++ b/dlls/gdi32/path.c
@@ -1627,14 +1627,16 @@ static struct gdi_path *PATH_WidenPath(DC *dc)
     elp = HeapAlloc( GetProcessHeap(), 0, size );
     GetObjectW( dc->hPen, size, elp );
 
-    obj_type = GetObjectType(dc->hPen);
-    if(obj_type == OBJ_PEN) {
+    obj_type = get_gdi_object_type(dc->hPen);
+    switch (obj_type)
+    {
+    case NTGDI_OBJ_PEN:
         penStyle = ((LOGPEN*)elp)->lopnStyle;
-    }
-    else if(obj_type == OBJ_EXTPEN) {
+        break;
+    case NTGDI_OBJ_EXTPEN:
         penStyle = elp->elpPenStyle;
-    }
-    else {
+        break;
+    default:
         SetLastError(ERROR_CAN_NOT_COMPLETE);
         HeapFree( GetProcessHeap(), 0, elp );
         return NULL;




More information about the wine-cvs mailing list