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 | 2 +- dlls/gdi32/bitmap.c | 2 +- dlls/gdi32/dc.c | 20 ++++++++++---------- dlls/gdi32/dibdrv/objects.c | 8 ++++---- dlls/gdi32/font.c | 2 +- dlls/gdi32/gdiobj.c | 23 +++++++++++++++++++++++ dlls/gdi32/ntgdi_private.h | 1 + dlls/gdi32/painting.c | 2 +- dlls/gdi32/palette.c | 8 ++++---- dlls/gdi32/pen.c | 2 +- 10 files changed, 47 insertions(+), 23 deletions(-)
diff --git a/dlls/gdi32/bitblt.c b/dlls/gdi32/bitblt.c index e6a846c3d74..ec117199a86 100644 --- a/dlls/gdi32/bitblt.c +++ b/dlls/gdi32/bitblt.c @@ -785,7 +785,7 @@ BOOL WINAPI MaskBlt(HDC hdcDest, INT nXDest, INT nYDest, return BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, FRGND_ROP3(dwRop));
hbrMask = CreatePatternBrush(hbmMask); - hbrDst = NtGdiSelectBrush(hdcDest, GetStockObject(NULL_BRUSH)); + hbrDst = NtGdiSelectBrush( hdcDest, get_stock_object(NULL_BRUSH) );
/* make bitmap */ hDC1 = NtGdiCreateCompatibleDC( hdcDest ); diff --git a/dlls/gdi32/bitmap.c b/dlls/gdi32/bitmap.c index 1ce0e940235..cc9b106de0b 100644 --- a/dlls/gdi32/bitmap.c +++ b/dlls/gdi32/bitmap.c @@ -387,7 +387,7 @@ HGDIOBJ WINAPI NtGdiSelectBitmap( HDC hdc, HGDIOBJ handle ) goto done; }
- if (handle != GetStockObject(DEFAULT_BITMAP) && GDI_get_ref_count( handle )) + if (handle != get_stock_object( DEFAULT_BITMAP ) && GDI_get_ref_count( handle )) { WARN( "Bitmap already selected in another DC\n" ); GDI_ReleaseObj( handle ); diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c index 739dc53d31d..42217681b17 100644 --- a/dlls/gdi32/dc.c +++ b/dlls/gdi32/dc.c @@ -133,10 +133,10 @@ DC *alloc_dc_ptr( DWORD magic ) dc->physDev = &dc->nulldrv; dc->thread = GetCurrentThreadId(); dc->refcount = 1; - dc->hPen = GDI_inc_ref_count( GetStockObject( BLACK_PEN )); - dc->hBrush = GDI_inc_ref_count( GetStockObject( WHITE_BRUSH )); - dc->hFont = GDI_inc_ref_count( GetStockObject( SYSTEM_FONT )); - dc->hPalette = GetStockObject( DEFAULT_PALETTE ); + dc->hPen = GDI_inc_ref_count( get_stock_object( BLACK_PEN )); + dc->hBrush = GDI_inc_ref_count( get_stock_object( WHITE_BRUSH )); + dc->hFont = GDI_inc_ref_count( get_stock_object( SYSTEM_FONT )); + dc->hPalette = get_stock_object( DEFAULT_PALETTE );
set_initial_dc_state( dc );
@@ -395,11 +395,11 @@ static BOOL reset_dc_state( HDC hdc ) set_initial_dc_state( dc ); set_bk_color( dc, RGB( 255, 255, 255 )); set_text_color( dc, RGB( 0, 0, 0 )); - NtGdiSelectBrush( hdc, GetStockObject( WHITE_BRUSH )); - NtGdiSelectFont( hdc, GetStockObject( SYSTEM_FONT )); - NtGdiSelectPen( hdc, GetStockObject( BLACK_PEN )); + NtGdiSelectBrush( hdc, get_stock_object( WHITE_BRUSH )); + NtGdiSelectFont( hdc, get_stock_object( SYSTEM_FONT )); + NtGdiSelectPen( hdc, get_stock_object( BLACK_PEN )); NtGdiSetVirtualResolution( hdc, 0, 0, 0, 0 ); - GDISelectPalette( hdc, GetStockObject( DEFAULT_PALETTE ), FALSE ); + GDISelectPalette( hdc, get_stock_object( DEFAULT_PALETTE ), FALSE ); NtGdiSetBoundsRect( hdc, NULL, DCB_DISABLE ); NtGdiAbortPath( hdc );
@@ -659,7 +659,7 @@ HDC WINAPI CreateDCW( LPCWSTR driver, LPCWSTR device, LPCWSTR output, if (!(dc = alloc_dc_ptr( NTGDI_OBJ_DC ))) return 0; hdc = dc->hSelf;
- dc->hBitmap = GDI_inc_ref_count( GetStockObject( DEFAULT_BITMAP )); + dc->hBitmap = GDI_inc_ref_count( get_stock_object( DEFAULT_BITMAP ));
TRACE("(driver=%s, device=%s, output=%s): returning %p\n", debugstr_w(driver), debugstr_w(device), debugstr_w(output), dc->hSelf ); @@ -727,7 +727,7 @@ HDC WINAPI NtGdiCreateCompatibleDC( HDC hdc )
TRACE("(%p): returning %p\n", hdc, dc->hSelf );
- dc->hBitmap = GDI_inc_ref_count( GetStockObject( DEFAULT_BITMAP )); + dc->hBitmap = GDI_inc_ref_count( get_stock_object( DEFAULT_BITMAP )); dc->attr->vis_rect.left = 0; dc->attr->vis_rect.top = 0; dc->attr->vis_rect.right = 1; diff --git a/dlls/gdi32/dibdrv/objects.c b/dlls/gdi32/dibdrv/objects.c index 4e24de0b3aa..452b2705e51 100644 --- a/dlls/gdi32/dibdrv/objects.c +++ b/dlls/gdi32/dibdrv/objects.c @@ -1770,7 +1770,7 @@ COLORREF CDECL dibdrv_SetDCPenColor( PHYSDEV dev, COLORREF color ) dibdrv_physdev *pdev = get_dibdrv_pdev(dev); DC *dc = get_physdev_dc( dev );
- if (dc->hPen == GetStockObject( DC_PEN )) + if (dc->hPen == get_stock_object( DC_PEN )) pdev->pen_brush.colorref = color;
return color; @@ -2136,7 +2136,7 @@ HBRUSH CDECL dibdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_
GetObjectW( hbrush, sizeof(logbrush), &logbrush );
- if (hbrush == GetStockObject( DC_BRUSH )) + if (hbrush == get_stock_object( DC_BRUSH )) logbrush.lbColor = dc->attr->brush_color;
select_brush( pdev, &pdev->brush, &logbrush, pattern, TRUE ); @@ -2188,7 +2188,7 @@ HPEN CDECL dibdrv_SelectPen( PHYSDEV dev, HPEN hpen, const struct brush_pattern pdev->pen_endcap = logpen.lopnStyle & PS_ENDCAP_MASK; pdev->pen_width = get_pen_device_width( dc, logpen.lopnWidth.x );
- if (hpen == GetStockObject( DC_PEN )) + if (hpen == get_stock_object( DC_PEN )) logbrush.lbColor = dc->attr->pen_color;
set_dash_pattern( &pdev->pen_pattern, 0, NULL ); @@ -2256,7 +2256,7 @@ COLORREF CDECL dibdrv_SetDCBrushColor( PHYSDEV dev, COLORREF color ) dibdrv_physdev *pdev = get_dibdrv_pdev(dev); DC *dc = get_physdev_dc( dev );
- if (dc->hBrush == GetStockObject( DC_BRUSH )) + if (dc->hBrush == get_stock_object( DC_BRUSH )) { LOGBRUSH logbrush = { BS_SOLID, color, 0 }; select_brush( pdev, &pdev->brush, &logbrush, NULL, TRUE ); diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index 1bbab661c95..792ba803257 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -5289,7 +5289,7 @@ done: UINT size = NtGdiGetOutlineTextMetricsInternalW( hdc, 0, NULL, 0 ); OUTLINETEXTMETRICW* otm = NULL; POINT pts[5]; - HPEN hpen = NtGdiSelectPen(hdc, GetStockObject(NULL_PEN)); + HPEN hpen = NtGdiSelectPen( hdc, get_stock_object(NULL_PEN) ); HBRUSH hbrush = CreateSolidBrush( dc->attr->text_color );
hbrush = NtGdiSelectBrush(hdc, hbrush); diff --git a/dlls/gdi32/gdiobj.c b/dlls/gdi32/gdiobj.c index 50c337cd6c4..c12ff98c058 100644 --- a/dlls/gdi32/gdiobj.c +++ b/dlls/gdi32/gdiobj.c @@ -610,6 +610,29 @@ static void set_gdi_shared(void) NtCurrentTeb()->Peb->GdiSharedHandleTable = &gdi_shared; }
+HGDIOBJ get_stock_object( INT obj ) +{ + assert( obj >= 0 && obj <= STOCK_LAST + 1 && obj != 9 ); + + switch (obj) + { + case OEM_FIXED_FONT: + if (get_system_dpi() != 96) obj = 9; + break; + case SYSTEM_FONT: + if (get_system_dpi() != 96) obj = STOCK_LAST + 2; + break; + case SYSTEM_FIXED_FONT: + if (get_system_dpi() != 96) obj = STOCK_LAST + 3; + break; + case DEFAULT_GUI_FONT: + if (get_system_dpi() != 96) obj = STOCK_LAST + 4; + break; + } + + return entry_to_handle( handle_entry( ULongToHandle( obj + FIRST_GDI_HANDLE ))); +} + static void init_stock_objects(void) { const struct DefaultFontInfo *deffonts; diff --git a/dlls/gdi32/ntgdi_private.h b/dlls/gdi32/ntgdi_private.h index 73870fcd2f8..ec3db21a2bd 100644 --- a/dlls/gdi32/ntgdi_private.h +++ b/dlls/gdi32/ntgdi_private.h @@ -403,6 +403,7 @@ extern HGDIOBJ GDI_inc_ref_count( HGDIOBJ handle ) DECLSPEC_HIDDEN; 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;
/* mapping.c */ extern BOOL dp_to_lp( DC *dc, POINT *points, INT count ) DECLSPEC_HIDDEN; diff --git a/dlls/gdi32/painting.c b/dlls/gdi32/painting.c index 1ab977595f8..acb3a95f30f 100644 --- a/dlls/gdi32/painting.c +++ b/dlls/gdi32/painting.c @@ -100,7 +100,7 @@ BOOL CDECL nulldrv_FrameRgn( PHYSDEV dev, HRGN rgn, HBRUSH brush, INT width, INT BOOL CDECL nulldrv_InvertRgn( PHYSDEV dev, HRGN rgn ) { INT prev_rop = SetROP2( dev->hdc, R2_NOT ); - BOOL ret = NtGdiFillRgn( dev->hdc, rgn, GetStockObject(BLACK_BRUSH) ); + BOOL ret = NtGdiFillRgn( dev->hdc, rgn, get_stock_object(BLACK_BRUSH) ); SetROP2( dev->hdc, prev_rop ); return ret; } diff --git a/dlls/gdi32/palette.c b/dlls/gdi32/palette.c index 0451adbdf80..a14ba9aeb08 100644 --- a/dlls/gdi32/palette.c +++ b/dlls/gdi32/palette.c @@ -202,7 +202,7 @@ static UINT set_palette_entries( HPALETTE hpalette, UINT start, UINT count, TRACE("hpal=%p,start=%i,count=%i\n",hpalette,start,count );
hpalette = get_full_gdi_handle( hpalette ); - if (hpalette == GetStockObject(DEFAULT_PALETTE)) return 0; + if (hpalette == get_stock_object(DEFAULT_PALETTE)) return 0; palPtr = GDI_GetObjPtr( hpalette, NTGDI_OBJ_PAL ); if (!palPtr) return 0;
@@ -255,7 +255,7 @@ static BOOL animate_palette( HPALETTE hPal, UINT StartIndex, UINT NumEntries, TRACE("%p (%i - %i)\n", hPal, StartIndex,StartIndex+NumEntries);
hPal = get_full_gdi_handle( hPal ); - if( hPal != GetStockObject(DEFAULT_PALETTE) ) + if( hPal != get_stock_object(DEFAULT_PALETTE) ) { PALETTEOBJ * palPtr; UINT pal_entries; @@ -412,7 +412,7 @@ COLORREF CDECL nulldrv_GetNearestColor( PHYSDEV dev, COLORREF color ) PALETTEENTRY entry; HPALETTE hpal = dc->hPalette;
- if (!hpal) hpal = GetStockObject( DEFAULT_PALETTE ); + if (!hpal) hpal = get_stock_object( DEFAULT_PALETTE ); if (spec_type == 2) /* PALETTERGB */ index = NtGdiGetNearestPaletteIndex( hpal, color ); else /* PALETTEINDEX */ @@ -549,7 +549,7 @@ UINT WINAPI GDIRealizePalette( HDC hdc )
TRACE("%p...\n", hdc );
- if( dc->hPalette == GetStockObject( DEFAULT_PALETTE )) + if( dc->hPalette == get_stock_object( DEFAULT_PALETTE )) { PHYSDEV physdev = GET_DC_PHYSDEV( dc, pRealizeDefaultPalette ); realized = physdev->funcs->pRealizeDefaultPalette( physdev ); diff --git a/dlls/gdi32/pen.c b/dlls/gdi32/pen.c index f79eaca4185..fa8b138229e 100644 --- a/dlls/gdi32/pen.c +++ b/dlls/gdi32/pen.c @@ -92,7 +92,7 @@ HPEN create_pen( INT style, INT width, COLORREF color ) HPEN WINAPI NtGdiCreatePen( INT style, INT width, COLORREF color, HBRUSH brush ) { if (brush) FIXME( "brush not supported\n" ); - if (style == PS_NULL) return GetStockObject( NULL_PEN ); + if (style == PS_NULL) return get_stock_object( NULL_PEN ); return create_pen( style, width, color ); }