From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Huw Davies huw@codeweavers.com --- dlls/gdi32/bitblt.c | 3 ++- dlls/gdi32/bitmap.c | 3 ++- dlls/gdi32/dib.c | 5 ++-- dlls/gdi32/dibdrv/dc.c | 2 +- dlls/gdi32/gdiobj.c | 53 ++++++++++++++---------------------------- dlls/gdi32/objects.c | 26 +++++++++++++++++++++ include/ntgdi.h | 2 ++ 7 files changed, 53 insertions(+), 41 deletions(-)
diff --git a/dlls/gdi32/bitblt.c b/dlls/gdi32/bitblt.c index c10b9d37199..e6a846c3d74 100644 --- a/dlls/gdi32/bitblt.c +++ b/dlls/gdi32/bitblt.c @@ -866,7 +866,8 @@ BOOL WINAPI GdiTransparentBlt( HDC hdcDest, int xDest, int yDest, int widthDest, SetStretchBltMode(hdcSrc, COLORONCOLOR); hdcWork = NtGdiCreateCompatibleDC( hdcDest ); if ((GetObjectType( hdcDest ) != OBJ_MEMDC || - GetObjectW( GetCurrentObject( hdcDest, OBJ_BITMAP ), sizeof(dib), &dib ) == sizeof(BITMAP)) && + GetObjectW( NtGdiGetDCObject( hdcDest, NTGDI_OBJ_SURF ), + sizeof(dib), &dib ) == sizeof(BITMAP)) && GetDeviceCaps( hdcDest, BITSPIXEL ) == 32) { /* screen DCs or DDBs are not supposed to have an alpha channel, so use a 24-bpp bitmap as copy */ diff --git a/dlls/gdi32/bitmap.c b/dlls/gdi32/bitmap.c index db6a4c44c84..1ce0e940235 100644 --- a/dlls/gdi32/bitmap.c +++ b/dlls/gdi32/bitmap.c @@ -63,7 +63,8 @@ HBITMAP WINAPI NtGdiCreateCompatibleBitmap( HDC hdc, INT width, INT height ) NtGdiGetDeviceCaps( hdc, PLANES ), NtGdiGetDeviceCaps( hdc, BITSPIXEL ), NULL );
- switch (NtGdiExtGetObjectW( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(dib), &dib )) + switch (NtGdiExtGetObjectW( NtGdiGetDCObject( hdc, NTGDI_OBJ_SURF ), + sizeof(dib), &dib )) { case sizeof(BITMAP): /* A device-dependent bitmap is selected in the DC */ return NtGdiCreateBitmap( width, height, dib.dsBm.bmPlanes, dib.dsBm.bmBitsPixel, NULL ); diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c index 68ca1c31664..f00d5cf13e2 100644 --- a/dlls/gdi32/dib.c +++ b/dlls/gdi32/dib.c @@ -253,7 +253,7 @@ static BOOL bitmapinfo_from_user_bitmapinfo( BITMAPINFO *dst, const BITMAPINFO * static int fill_color_table_from_palette( BITMAPINFO *info, HDC hdc ) { PALETTEENTRY palEntry[256]; - HPALETTE palette = GetCurrentObject( hdc, OBJ_PAL ); + HPALETTE palette = NtGdiGetDCObject( hdc, NTGDI_OBJ_PAL ); int i, colors = 1 << info->bmiHeader.biBitCount;
info->bmiHeader.biClrUsed = colors; @@ -284,7 +284,8 @@ BOOL fill_color_table_from_pal_colors( BITMAPINFO *info, HDC hdc ) int i, count, colors = info->bmiHeader.biClrUsed;
if (!colors) return TRUE; - if (!(palette = GetCurrentObject( hdc, OBJ_PAL ))) return FALSE; + if (!(palette = NtGdiGetDCObject( hdc, NTGDI_OBJ_PAL ))) + return FALSE; if (!(count = get_palette_entries( palette, 0, colors, entries ))) return FALSE;
for (i = 0; i < colors; i++, index++) diff --git a/dlls/gdi32/dibdrv/dc.c b/dlls/gdi32/dibdrv/dc.c index c31845d30a9..6336e3f23fe 100644 --- a/dlls/gdi32/dibdrv/dc.c +++ b/dlls/gdi32/dibdrv/dc.c @@ -534,7 +534,7 @@ static BOOL WINAPI dibdrv_wglMakeCurrent( HDC hdc, struct wgl_context *context ) if (!osmesa_funcs) return FALSE; if (!context) return osmesa_funcs->make_current( NULL, NULL, 0, 0, 0, 0 );
- bitmap = GetCurrentObject( hdc, OBJ_BITMAP ); + bitmap = NtGdiGetDCObject( hdc, NTGDI_OBJ_SURF ); bmp = GDI_GetObjPtr( bitmap, NTGDI_OBJ_BITMAP ); if (!bmp) return FALSE;
diff --git a/dlls/gdi32/gdiobj.c b/dlls/gdi32/gdiobj.c index cc68070674a..14b65429d4a 100644 --- a/dlls/gdi32/gdiobj.c +++ b/dlls/gdi32/gdiobj.c @@ -1005,47 +1005,28 @@ INT WINAPI NtGdiExtGetObjectW( HGDIOBJ handle, INT count, void *buffer ) }
/*********************************************************************** - * GetCurrentObject (GDI32.@) + * NtGdiGetDCObject (win32u.@) * * Get the currently selected object of a given type in a device context. - * - * PARAMS - * hdc [I] Device context to get the current object from - * type [I] Type of current object to get (OBJ_* defines from "wingdi.h") - * - * RETURNS - * Success: The current object of the given type selected in hdc. - * Failure: A NULL handle. - * - * NOTES - * - only the following object types are supported: - *| OBJ_PEN - *| OBJ_BRUSH - *| OBJ_PAL - *| OBJ_FONT - *| OBJ_BITMAP */ -HGDIOBJ WINAPI GetCurrentObject(HDC hdc,UINT type) +HANDLE WINAPI NtGdiGetDCObject( HDC hdc, UINT type ) { HGDIOBJ ret = 0; - DC * dc = get_dc_ptr( hdc ); - - if (!dc) return 0; - - switch (type) { - case OBJ_EXTPEN: /* fall through */ - case OBJ_PEN: ret = dc->hPen; break; - case OBJ_BRUSH: ret = dc->hBrush; break; - case OBJ_PAL: ret = dc->hPalette; break; - case OBJ_FONT: ret = dc->hFont; break; - case OBJ_BITMAP: ret = dc->hBitmap; break; - - /* tests show that OBJ_REGION is explicitly ignored */ - case OBJ_REGION: break; - default: - /* the SDK only mentions those above */ - FIXME("(%p,%d): unknown type.\n",hdc,type); - break; + DC *dc; + + if (!(dc = get_dc_ptr( hdc ))) return 0; + + switch (type) + { + case NTGDI_OBJ_EXTPEN: /* fall through */ + case NTGDI_OBJ_PEN: ret = dc->hPen; break; + case NTGDI_OBJ_BRUSH: ret = dc->hBrush; break; + case NTGDI_OBJ_PAL: ret = dc->hPalette; break; + case NTGDI_OBJ_FONT: ret = dc->hFont; break; + case NTGDI_OBJ_SURF: ret = dc->hBitmap; break; + default: + FIXME( "(%p, %d): unknown type.\n", hdc, type ); + break; } release_dc_ptr( dc ); return ret; diff --git a/dlls/gdi32/objects.c b/dlls/gdi32/objects.c index b989a83daa1..b656c2a3f1e 100644 --- a/dlls/gdi32/objects.c +++ b/dlls/gdi32/objects.c @@ -353,6 +353,32 @@ INT WINAPI GetObjectW( HGDIOBJ handle, INT count, void *buffer ) return result; }
+/*********************************************************************** + * GetCurrentObject (GDI32.@) + */ +HGDIOBJ WINAPI GetCurrentObject( HDC hdc, UINT type ) +{ + unsigned int obj_type; + + switch (type) + { + case OBJ_EXTPEN: obj_type = NTGDI_OBJ_EXTPEN; break; + case OBJ_PEN: obj_type = NTGDI_OBJ_PEN; break; + case OBJ_BRUSH: obj_type = NTGDI_OBJ_BRUSH; break; + case OBJ_PAL: obj_type = NTGDI_OBJ_PAL; break; + case OBJ_FONT: obj_type = NTGDI_OBJ_FONT; break; + case OBJ_BITMAP: obj_type = NTGDI_OBJ_SURF; break; + case OBJ_REGION: + /* tests show that OBJ_REGION is explicitly ignored */ + return 0; + default: + FIXME( "(%p,%d): unknown type.\n", hdc, type ); + return 0; + } + + return NtGdiGetDCObject( hdc, obj_type ); +} + /*********************************************************************** * GetObjectA (GDI32.@) */ diff --git a/include/ntgdi.h b/include/ntgdi.h index 2ee70cf3971..9e07268a307 100644 --- a/include/ntgdi.h +++ b/include/ntgdi.h @@ -57,6 +57,7 @@ typedef struct _GDI_HANDLE_ENTRY #define NTGDI_OBJ_DC 0x010000 #define NTGDI_OBJ_ENHMETADC 0x210000 #define NTGDI_OBJ_REGION 0x040000 +#define NTGDI_OBJ_SURF 0x050000 #define NTGDI_OBJ_METAFILE 0x260000 #define NTGDI_OBJ_ENHMETAFILE 0x460000 #define NTGDI_OBJ_METADC 0x660000 @@ -296,6 +297,7 @@ BOOL WINAPI NtGdiGetCharWidthW( HDC hdc, UINT first_char, UINT last_char, WC ULONG flags, void *buffer ); BOOL WINAPI NtGdiGetColorAdjustment( HDC hdc, COLORADJUSTMENT *ca ); BOOL WINAPI NtGdiGetDCDword( HDC hdc, UINT method, DWORD *result ); +HANDLE WINAPI NtGdiGetDCObject( HDC hdc, UINT type ); BOOL WINAPI NtGdiGetDCPoint( HDC hdc, UINT method, POINT *result ); INT WINAPI NtGdiGetDIBitsInternal( HDC hdc, HBITMAP hbitmap, UINT startscan, UINT lines, void *bits, BITMAPINFO *info, UINT coloruse,