From 54397f1552cfc76de5b1ae9cda0e2328a0de791c Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Fri, 6 May 2011 11:35:26 +0100 Subject: [PATCH] gdi32: Add support for patterned pens. --- dlls/gdi32/dibdrv/objects.c | 31 ++++++++++++++++++++++++++++++- dlls/gdi32/gdi_private.h | 8 ++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/dlls/gdi32/dibdrv/objects.c b/dlls/gdi32/dibdrv/objects.c index 50b2996733d..25aad8e3c7d 100644 --- a/dlls/gdi32/dibdrv/objects.c +++ b/dlls/gdi32/dibdrv/objects.c @@ -544,6 +544,19 @@ static BOOL solid_pen_line(dibdrv_physdev *pdev, POINT *start, POINT *end) return TRUE; } +static BOOL dashed_pen_line(dibdrv_physdev *pdev, POINT *start, POINT *end) +{ + return FALSE; +} + +static const dash_pattern dash_patterns[4] = +{ + {2, {18, 6}, 24}, /* PS_DASH */ + {2, {3, 3}, 6}, /* PS_DOT */ + {4, {9, 6, 3, 6}, 24}, /* PS_DASHDOT */ + {6, {9, 3, 3, 3, 3, 3}, 24} /* PS_DASHDOTDOT */ +}; + /*********************************************************************** * dibdrv_SelectPen */ @@ -552,6 +565,7 @@ HPEN CDECL dibdrv_SelectPen( PHYSDEV dev, HPEN hpen ) PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSelectPen ); dibdrv_physdev *pdev = get_dibdrv_pdev(dev); LOGPEN logpen; + DWORD style; TRACE("(%p, %p)\n", dev, hpen); @@ -583,14 +597,29 @@ HPEN CDECL dibdrv_SelectPen( PHYSDEV dev, HPEN hpen ) pdev->defer |= DEFER_PEN; - switch(logpen.lopnStyle & PS_STYLE_MASK) + style = logpen.lopnStyle & PS_STYLE_MASK; + + switch(style) { case PS_SOLID: if(logpen.lopnStyle & PS_GEOMETRIC) break; if(logpen.lopnWidth.x > 1) break; pdev->pen_line = solid_pen_line; + pdev->pen_pattern.count = 0; pdev->defer &= ~DEFER_PEN; break; + + case PS_DASH: + case PS_DOT: + case PS_DASHDOT: + case PS_DASHDOTDOT: + if(logpen.lopnStyle & PS_GEOMETRIC) break; + if(logpen.lopnWidth.x > 1) break; + pdev->pen_line = dashed_pen_line; + pdev->pen_pattern = dash_patterns[style - PS_DASH]; + pdev->defer &= ~DEFER_PEN; + break; + default: break; } diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index 695eff0fcca..0a90fb1ac09 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -92,6 +92,13 @@ typedef struct const struct primitive_funcs *funcs; } dib_info; +typedef struct +{ + DWORD count; + DWORD dashes[16]; /* 16 is the maximium number for a PS_USERSTYLE pen */ + DWORD total_len; /* total length of the dashes, should be multiplied by 2 if there are an odd number of dash lengths */ +} dash_pattern; + typedef struct dibdrv_physdev { struct gdi_physdev dev; @@ -103,6 +110,7 @@ typedef struct dibdrv_physdev /* pen */ DWORD pen_color, pen_and, pen_xor; BOOL (* pen_line)(struct dibdrv_physdev *pdev, POINT *start, POINT *end); + dash_pattern pen_pattern; /* brush */ UINT brush_style;