From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Huw Davies huw@codeweavers.com --- dlls/gdi32/brush.c | 8 +------- dlls/gdi32/objects.c | 23 +++++++++++++++++++++++ dlls/gdi32/pen.c | 22 ++++++++++++---------- dlls/gdi32/tests/pen.c | 3 +-- include/ntgdi.h | 6 ++++-- 5 files changed, 41 insertions(+), 21 deletions(-)
diff --git a/dlls/gdi32/brush.c b/dlls/gdi32/brush.c index 1dcf4b2c844..7c43df0dfcf 100644 --- a/dlls/gdi32/brush.c +++ b/dlls/gdi32/brush.c @@ -90,8 +90,6 @@ done:
BOOL store_brush_pattern( LOGBRUSH *brush, struct brush_pattern *pattern ) { - HGLOBAL hmem = 0; - pattern->info = NULL; pattern->bits.free = NULL;
@@ -117,20 +115,16 @@ BOOL store_brush_pattern( LOGBRUSH *brush, struct brush_pattern *pattern ) brush->lbColor = 0; return copy_bitmap( pattern, (HBITMAP)brush->lbHatch );
- case BS_DIBPATTERN: - hmem = (HGLOBAL)brush->lbHatch; - if (!(brush->lbHatch = (ULONG_PTR)GlobalLock( hmem ))) return FALSE; - /* fall through */ case BS_DIBPATTERNPT: pattern->usage = brush->lbColor; pattern->info = copy_packed_dib( (BITMAPINFO *)brush->lbHatch, pattern->usage ); - if (hmem) GlobalUnlock( hmem ); if (!pattern->info) return FALSE; pattern->bits.ptr = (char *)pattern->info + get_dib_info_size( pattern->info, pattern->usage ); brush->lbStyle = BS_DIBPATTERN; brush->lbColor = 0; return TRUE;
+ case BS_DIBPATTERN: case BS_DIBPATTERN8X8: case BS_MONOPATTERN: case BS_INDEXED: diff --git a/dlls/gdi32/objects.c b/dlls/gdi32/objects.c index bdd4a03fe34..70cf1d6a0a5 100644 --- a/dlls/gdi32/objects.c +++ b/dlls/gdi32/objects.c @@ -398,6 +398,29 @@ HPEN WINAPI CreatePen( INT style, INT width, COLORREF color ) return NtGdiCreatePen( style, width, color, NULL ); }
+/*********************************************************************** + * ExtCreatePen (GDI32.@) + */ +HPEN WINAPI ExtCreatePen( DWORD style, DWORD width, const LOGBRUSH *brush, DWORD style_count, + const DWORD *style_bits ) +{ + ULONG brush_style = brush->lbStyle; + ULONG_PTR hatch = brush->lbHatch; + HPEN pen; + + if (brush_style == BS_DIBPATTERN) + { + if (!(hatch = (ULONG_PTR)GlobalLock( (HGLOBAL)hatch ))) return 0; + brush_style = BS_DIBPATTERNPT; + } + + pen = NtGdiExtCreatePen( style, width, brush_style, brush->lbColor, brush->lbHatch, hatch, + style_count, style_bits, /* FIXME */ 0, FALSE, NULL ); + + if (brush->lbStyle == BS_DIBPATTERN) GlobalUnlock( (HGLOBAL)brush->lbHatch ); + return pen; +} + /*********************************************************************** * CreateBrushIndirect (GDI32.@) */ diff --git a/dlls/gdi32/pen.c b/dlls/gdi32/pen.c index 3b3ab78ecd7..684cc8375d1 100644 --- a/dlls/gdi32/pen.c +++ b/dlls/gdi32/pen.c @@ -93,12 +93,12 @@ HPEN WINAPI NtGdiCreatePen( INT style, INT width, COLORREF color, HBRUSH brush ) }
/*********************************************************************** - * ExtCreatePen (GDI32.@) + * NtGdiExtCreatePen (win32u.@) */ - -HPEN WINAPI ExtCreatePen( DWORD style, DWORD width, - const LOGBRUSH * brush, DWORD style_count, - const DWORD *style_bits ) +HPEN WINAPI NtGdiExtCreatePen( DWORD style, DWORD width, ULONG brush_style, ULONG color, + ULONG_PTR client_hatch, ULONG_PTR hatch, DWORD style_count, + const DWORD *style_bits, ULONG dib_size, BOOL old_style, + HBRUSH brush ) { PENOBJ *penPtr = NULL; HPEN hpen; @@ -110,7 +110,7 @@ HPEN WINAPI ExtCreatePen( DWORD style, DWORD width, switch (style & PS_STYLE_MASK) { case PS_NULL: - return CreatePen( PS_NULL, 0, brush->lbColor ); + return NtGdiCreatePen( PS_NULL, 0, color, NULL );
case PS_SOLID: case PS_DASH: @@ -154,18 +154,20 @@ HPEN WINAPI ExtCreatePen( DWORD style, DWORD width,
if ((style & PS_TYPE_MASK) == PS_GEOMETRIC) { - if (brush->lbStyle == BS_NULL) return CreatePen( PS_NULL, 0, 0 ); + if (brush_style == BS_NULL) return NtGdiCreatePen( PS_NULL, 0, 0, NULL ); } else { if (width != 1) goto invalid; - if (brush->lbStyle != BS_SOLID) goto invalid; + if (brush_style != BS_SOLID) goto invalid; }
if (!(penPtr = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(PENOBJ,logpen.elpStyleEntry[style_count])))) return 0;
- logbrush = *brush; + logbrush.lbStyle = brush_style; + logbrush.lbColor = color; + logbrush.lbHatch = hatch; if (!store_brush_pattern( &logbrush, &penPtr->pattern )) goto invalid; if (logbrush.lbStyle == BS_DIBPATTERN) logbrush.lbStyle = BS_DIBPATTERNPT;
@@ -173,7 +175,7 @@ HPEN WINAPI ExtCreatePen( DWORD style, DWORD width, penPtr->logpen.elpWidth = abs((int)width); penPtr->logpen.elpBrushStyle = logbrush.lbStyle; penPtr->logpen.elpColor = logbrush.lbColor; - penPtr->logpen.elpHatch = brush->lbHatch; + penPtr->logpen.elpHatch = client_hatch; penPtr->logpen.elpNumEntries = style_count; memcpy(penPtr->logpen.elpStyleEntry, style_bits, style_count * sizeof(DWORD));
diff --git a/dlls/gdi32/tests/pen.c b/dlls/gdi32/tests/pen.c index 530272ea79f..d1bfa7ee34f 100644 --- a/dlls/gdi32/tests/pen.c +++ b/dlls/gdi32/tests/pen.c @@ -646,8 +646,7 @@ static void test_brush_pens(void) ok( elp->elpPenStyle == (PS_DOT | PS_GEOMETRIC), "wrong pen style %x\n", elp->elpPenStyle ); ok( elp->elpBrushStyle == BS_DIBPATTERNPT, "wrong brush style %x\n", elp->elpBrushStyle ); ok( elp->elpColor == 0, "wrong color %x\n", elp->elpColor ); - ok( elp->elpHatch == lb.lbHatch || broken(elp->elpHatch != lb.lbHatch), /* <= w2k */ - "wrong hatch %lx/%lx\n", elp->elpHatch, lb.lbHatch ); + ok( elp->elpHatch == lb.lbHatch, "wrong hatch %lx/%lx\n", elp->elpHatch, lb.lbHatch ); ok( elp->elpNumEntries == 0, "wrong entries %x\n", elp->elpNumEntries ); break;
diff --git a/include/ntgdi.h b/include/ntgdi.h index 7fa2b09b2e0..f8dd944a185 100644 --- a/include/ntgdi.h +++ b/include/ntgdi.h @@ -242,8 +242,10 @@ BOOL WINAPI NtGdiDeleteObjectApp( HGDIOBJ obj ); LONG WINAPI NtGdiDoPalette( HGDIOBJ handle, WORD start, WORD count, void *entries, DWORD func, BOOL inbound ); INT WINAPI NtGdiEndPage( HDC hdc ); -HPEN WINAPI NtGdiExtCreatePen( DWORD style, DWORD width, const LOGBRUSH *brush, - DWORD style_count, const DWORD *style_bits ); +HPEN WINAPI NtGdiExtCreatePen( DWORD style, DWORD width, ULONG brush_style, ULONG color, + ULONG_PTR client_hatch, ULONG_PTR hatch, DWORD style_count, + const DWORD *style_bits, ULONG dib_size, BOOL old_style, + HBRUSH brush ); HRGN WINAPI NtGdiExtCreateRegion( const XFORM *xform, DWORD count, const RGNDATA *data ); INT WINAPI NtGdiExtGetObjectW( HGDIOBJ handle, INT count, void *buffer ); INT WINAPI NtGdiExtSelectClipRgn( HDC hdc, HRGN region, INT mode );