From 224e51fcf55ee4b4c34550084c39b63365cdffa4 Mon Sep 17 00:00:00 2001 From: Huw Davies <huw@codeweavers.com> Date: Thu, 24 Nov 2011 09:26:44 +0000 Subject: [PATCH] gdi32: Add an option to allow pen_lines to draw a closed figure. --- dlls/gdi32/dibdrv/dibdrv.h | 2 +- dlls/gdi32/dibdrv/graphics.c | 11 +++++------ dlls/gdi32/dibdrv/objects.c | 10 +++++++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/dlls/gdi32/dibdrv/dibdrv.h b/dlls/gdi32/dibdrv/dibdrv.h index 3e3ab21441e..4068b54e178 100644 --- a/dlls/gdi32/dibdrv/dibdrv.h +++ b/dlls/gdi32/dibdrv/dibdrv.h @@ -87,7 +87,7 @@ typedef struct dibdrv_physdev DWORD pen_color, pen_and, pen_xor; dash_pattern pen_pattern; dash_pos dash_pos; - BOOL (* pen_lines)(struct dibdrv_physdev *pdev, int num, POINT *pts); + BOOL (* pen_lines)(struct dibdrv_physdev *pdev, int num, POINT *pts, BOOL close); /* brush */ UINT brush_style; diff --git a/dlls/gdi32/dibdrv/graphics.c b/dlls/gdi32/dibdrv/graphics.c index d5e4730d46e..590a8167018 100644 --- a/dlls/gdi32/dibdrv/graphics.c +++ b/dlls/gdi32/dibdrv/graphics.c @@ -431,7 +431,7 @@ BOOL dibdrv_LineTo( PHYSDEV dev, INT x, INT y ) reset_dash_origin(pdev); - if(defer_pen(pdev) || !pdev->pen_lines(pdev, 2, pts)) + if(defer_pen(pdev) || !pdev->pen_lines(pdev, 2, pts, FALSE)) return next->funcs->pLineTo( next, x, y ); return TRUE; @@ -528,7 +528,7 @@ BOOL dibdrv_PolyPolyline( PHYSDEV dev, const POINT* pt, const DWORD* counts, DWO LPtoDP( dev->hdc, points, counts[i] ); reset_dash_origin( pdev ); - pdev->pen_lines( pdev, counts[i], points ); + pdev->pen_lines( pdev, counts[i], points, FALSE ); } HeapFree( GetProcessHeap(), 0, points ); @@ -553,7 +553,7 @@ BOOL dibdrv_Polyline( PHYSDEV dev, const POINT* pt, INT count ) LPtoDP( dev->hdc, points, count ); reset_dash_origin( pdev ); - pdev->pen_lines( pdev, count, points ); + pdev->pen_lines( pdev, count, points, FALSE ); HeapFree( GetProcessHeap(), 0, points ); return TRUE; @@ -567,7 +567,7 @@ BOOL dibdrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) PHYSDEV next = GET_NEXT_PHYSDEV( dev, pRectangle ); dibdrv_physdev *pdev = get_dibdrv_pdev(dev); RECT rect = get_device_rect( dev->hdc, left, top, right, bottom, TRUE ); - POINT pts[5]; + POINT pts[4]; TRACE("(%p, %d, %d, %d, %d)\n", dev, left, top, right, bottom); @@ -583,9 +583,8 @@ BOOL dibdrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) pts[0].y = pts[1].y = rect.top; pts[1].x = pts[2].x = rect.left; pts[2].y = pts[3].y = rect.bottom - 1; - pts[4] = pts[0]; - pdev->pen_lines(pdev, 5, pts); + pdev->pen_lines(pdev, 4, pts, TRUE); /* FIXME: Will need updating when we support wide pens */ diff --git a/dlls/gdi32/dibdrv/objects.c b/dlls/gdi32/dibdrv/objects.c index 51e1fdcde1e..0baafdbd9ec 100644 --- a/dlls/gdi32/dibdrv/objects.c +++ b/dlls/gdi32/dibdrv/objects.c @@ -696,7 +696,7 @@ static BOOL solid_pen_line(dibdrv_physdev *pdev, POINT *start, POINT *end) return TRUE; } -static BOOL solid_pen_lines(dibdrv_physdev *pdev, int num, POINT *pts) +static BOOL solid_pen_lines(dibdrv_physdev *pdev, int num, POINT *pts, BOOL close) { int i; @@ -705,6 +705,8 @@ static BOOL solid_pen_lines(dibdrv_physdev *pdev, int num, POINT *pts) if (!solid_pen_line( pdev, pts + i, pts + i + 1 )) return FALSE; + if (close) return solid_pen_line( pdev, pts + num - 1, pts ); + return TRUE; } @@ -996,7 +998,7 @@ static BOOL dashed_pen_line(dibdrv_physdev *pdev, POINT *start, POINT *end) return TRUE; } -static BOOL dashed_pen_lines(dibdrv_physdev *pdev, int num, POINT *pts) +static BOOL dashed_pen_lines(dibdrv_physdev *pdev, int num, POINT *pts, BOOL close) { int i; @@ -1005,10 +1007,12 @@ static BOOL dashed_pen_lines(dibdrv_physdev *pdev, int num, POINT *pts) if (!dashed_pen_line( pdev, pts + i, pts + i + 1 )) return FALSE; + if (close) return dashed_pen_line( pdev, pts + num - 1, pts ); + return TRUE; } -static BOOL null_pen_lines(dibdrv_physdev *pdev, int num, POINT *pts) +static BOOL null_pen_lines(dibdrv_physdev *pdev, int num, POINT *pts, BOOL close) { return TRUE; } -- GitLab