From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Huw Davies huw@codeweavers.com --- dlls/gdi32/gdiobj.c | 40 +++++++++++++++++++++----------------- dlls/gdi32/ntgdi_private.h | 3 +++ dlls/gdi32/palette.c | 2 +- dlls/gdi32/pen.c | 18 ++++++++++------- 4 files changed, 37 insertions(+), 26 deletions(-)
diff --git a/dlls/gdi32/gdiobj.c b/dlls/gdi32/gdiobj.c index 14b65429d4a..ffb42ab88e2 100644 --- a/dlls/gdi32/gdiobj.c +++ b/dlls/gdi32/gdiobj.c @@ -80,12 +80,7 @@ static const LOGBRUSH LtGrayBrush = { BS_SOLID, RGB(192,192,192), 0 }; static const LOGBRUSH GrayBrush = { BS_SOLID, RGB(128,128,128), 0 }; static const LOGBRUSH DkGrayBrush = { BS_SOLID, RGB(64,64,64), 0 };
-static const LOGPEN WhitePen = { PS_SOLID, { 0, 0 }, RGB(255,255,255) }; -static const LOGPEN BlackPen = { PS_SOLID, { 0, 0 }, RGB(0,0,0) }; -static const LOGPEN NullPen = { PS_NULL, { 0, 0 }, 0 }; - static const LOGBRUSH DCBrush = { BS_SOLID, RGB(255,255,255), 0 }; -static const LOGPEN DCPen = { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
/* reserve one extra entry for the stock default bitmap */ /* this is what Windows does too */ @@ -582,6 +577,15 @@ DWORD get_system_dpi(void) return pGetDpiForSystem ? pGetDpiForSystem() : 96; }
+static HFONT create_font( const LOGFONTW *deffont ) +{ + ENUMLOGFONTEXDVW lf; + + memset( &lf, 0, sizeof(lf) ); + lf.elfEnumLogfontEx.elfLogFont = *deffont; + return NtGdiHfontCreate( &lf, sizeof(lf), 0, 0, NULL ); +} + static HFONT create_scaled_font( const LOGFONTW *deffont ) { LOGFONTW lf; @@ -595,7 +599,7 @@ static HFONT create_scaled_font( const LOGFONTW *deffont )
lf = *deffont; lf.lfHeight = MulDiv( lf.lfHeight, dpi, 96 ); - return CreateFontIndirectW( &lf ); + return create_font( &lf ); }
static void set_gdi_shared(void) @@ -648,24 +652,24 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) stock_objects[BLACK_BRUSH] = create_brush( &BlackBrush ); stock_objects[NULL_BRUSH] = create_brush( &NullBrush );
- stock_objects[WHITE_PEN] = CreatePenIndirect( &WhitePen ); - stock_objects[BLACK_PEN] = CreatePenIndirect( &BlackPen ); - stock_objects[NULL_PEN] = CreatePenIndirect( &NullPen ); + stock_objects[WHITE_PEN] = create_pen( PS_SOLID, 0, RGB(255,255,255) ); + stock_objects[BLACK_PEN] = create_pen( PS_SOLID, 0, RGB(0,0,0) ); + stock_objects[NULL_PEN] = create_pen( PS_NULL, 0, RGB(0,0,0) );
stock_objects[DEFAULT_PALETTE] = PALETTE_Init(); - stock_objects[DEFAULT_BITMAP] = CreateBitmap( 1, 1, 1, 1, NULL ); + stock_objects[DEFAULT_BITMAP] = NtGdiCreateBitmap( 1, 1, 1, 1, NULL );
/* language-independent stock fonts */ - stock_objects[OEM_FIXED_FONT] = CreateFontIndirectW( &OEMFixedFont ); - stock_objects[ANSI_FIXED_FONT] = CreateFontIndirectW( &AnsiFixedFont ); - stock_objects[ANSI_VAR_FONT] = CreateFontIndirectW( &AnsiVarFont ); + stock_objects[OEM_FIXED_FONT] = create_font( &OEMFixedFont ); + stock_objects[ANSI_FIXED_FONT] = create_font( &AnsiFixedFont ); + stock_objects[ANSI_VAR_FONT] = create_font( &AnsiVarFont );
/* language-dependent stock fonts */ deffonts = get_default_fonts(get_default_charset()); - stock_objects[SYSTEM_FONT] = CreateFontIndirectW( &deffonts->SystemFont ); - stock_objects[DEVICE_DEFAULT_FONT] = CreateFontIndirectW( &deffonts->DeviceDefaultFont ); - stock_objects[SYSTEM_FIXED_FONT] = CreateFontIndirectW( &deffonts->SystemFixedFont ); - stock_objects[DEFAULT_GUI_FONT] = CreateFontIndirectW( &deffonts->DefaultGuiFont ); + stock_objects[SYSTEM_FONT] = create_font( &deffonts->SystemFont ); + stock_objects[DEVICE_DEFAULT_FONT] = create_font( &deffonts->DeviceDefaultFont ); + stock_objects[SYSTEM_FIXED_FONT] = create_font( &deffonts->SystemFixedFont ); + stock_objects[DEFAULT_GUI_FONT] = create_font( &deffonts->DefaultGuiFont );
scaled_stock_objects[OEM_FIXED_FONT] = create_scaled_font( &OEMFixedFont ); scaled_stock_objects[SYSTEM_FONT] = create_scaled_font( &deffonts->SystemFont ); @@ -673,7 +677,7 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) scaled_stock_objects[DEFAULT_GUI_FONT] = create_scaled_font( &deffonts->DefaultGuiFont );
stock_objects[DC_BRUSH] = create_brush( &DCBrush ); - stock_objects[DC_PEN] = CreatePenIndirect( &DCPen ); + stock_objects[DC_PEN] = create_pen( PS_SOLID, 0, RGB(0,0,0) );
/* clear the NOSYSTEM bit on all stock objects*/ for (i = 0; i < NB_STOCK_OBJECTS; i++) diff --git a/dlls/gdi32/ntgdi_private.h b/dlls/gdi32/ntgdi_private.h index a438a3f93ae..73870fcd2f8 100644 --- a/dlls/gdi32/ntgdi_private.h +++ b/dlls/gdi32/ntgdi_private.h @@ -453,6 +453,9 @@ extern HPALETTE PALETTE_Init(void) DECLSPEC_HIDDEN; extern UINT get_palette_entries( HPALETTE hpalette, UINT start, UINT count, PALETTEENTRY *entries ) DECLSPEC_HIDDEN;
+/* pen.c */ +extern HPEN create_pen( INT style, INT width, COLORREF color ) DECLSPEC_HIDDEN; + /* region.c */ extern BOOL add_rect_to_region( HRGN rgn, const RECT *rect ) DECLSPEC_HIDDEN; extern INT mirror_region( HRGN dst, HRGN src, INT width ) DECLSPEC_HIDDEN; diff --git a/dlls/gdi32/palette.c b/dlls/gdi32/palette.c index aa7745dc65f..0451adbdf80 100644 --- a/dlls/gdi32/palette.c +++ b/dlls/gdi32/palette.c @@ -89,7 +89,7 @@ HPALETTE PALETTE_Init(void) palPtr->palPalEntry[i].peBlue = entries[i < 10 ? i : 236 + i].rgbBlue; palPtr->palPalEntry[i].peFlags = 0; } - return CreatePalette( palPtr ); + return NtGdiCreatePaletteInternal( palPtr, palPtr->palNumEntries ); }
diff --git a/dlls/gdi32/pen.c b/dlls/gdi32/pen.c index ff2a766d40c..f79eaca4185 100644 --- a/dlls/gdi32/pen.c +++ b/dlls/gdi32/pen.c @@ -50,17 +50,12 @@ static const struct gdi_obj_funcs pen_funcs = PEN_DeleteObject /* pDeleteObject */ };
- -/*********************************************************************** - * NtGdiCreatePen (win32u.@) - */ -HPEN WINAPI NtGdiCreatePen( INT style, INT width, COLORREF color, HBRUSH brush ) +HPEN create_pen( INT style, INT width, COLORREF color ) { PENOBJ *penPtr; HPEN hpen;
TRACE( "%d %d %06x\n", style, width, color ); - if (brush) FIXME( "brush not supported\n" );
switch (style) { @@ -72,7 +67,6 @@ HPEN WINAPI NtGdiCreatePen( INT style, INT width, COLORREF color, HBRUSH brush ) case PS_INSIDEFRAME: break; case PS_NULL: - if ((hpen = GetStockObject( NULL_PEN ))) return hpen; width = 1; color = 0; break; @@ -92,6 +86,16 @@ HPEN WINAPI NtGdiCreatePen( INT style, INT width, COLORREF color, HBRUSH brush ) return hpen; }
+/*********************************************************************** + * NtGdiCreatePen (win32u.@) + */ +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 ); + return create_pen( style, width, color ); +} + /*********************************************************************** * NtGdiExtCreatePen (win32u.@) */