Alexandre Julliard : gdi32: Fix setting the path flags in PolyPolyline and PolyPolygon.

Alexandre Julliard julliard at winehq.org
Wed Jun 22 11:04:40 CDT 2016


Module: wine
Branch: master
Commit: e68d68fb7d9e6e61d37f597c194e74689b767d89
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e68d68fb7d9e6e61d37f597c194e74689b767d89

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Jun 22 14:27:28 2016 +0900

gdi32: Fix setting the path flags in PolyPolyline and PolyPolygon.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdi32/path.c | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/dlls/gdi32/path.c b/dlls/gdi32/path.c
index c6b87d4..ede3d61 100644
--- a/dlls/gdi32/path.c
+++ b/dlls/gdi32/path.c
@@ -1298,16 +1298,24 @@ static BOOL pathdrv_Polygon( PHYSDEV dev, const POINT *pts, INT cbPoints )
 static BOOL pathdrv_PolyPolygon( PHYSDEV dev, const POINT* pts, const INT* counts, UINT polygons )
 {
     struct path_physdev *physdev = get_path_physdev( dev );
-    UINT poly;
+    UINT poly, count;
     BYTE *type;
 
-    for(poly = 0; poly < polygons; poly++) {
-        type = add_log_points( physdev, pts, counts[poly], PT_LINETO );
-        if (!type) return FALSE;
+    if (!polygons) return FALSE;
+    for (poly = count = 0; poly < polygons; poly++)
+    {
+        if (counts[poly] < 2) return FALSE;
+        count += counts[poly];
+    }
+
+    type = add_log_points( physdev, pts, count, PT_LINETO );
+    if (!type) return FALSE;
+
+    /* make the first point of each polyline a PT_MOVETO, and close the last one */
+    for (poly = 0; poly < polygons; type += counts[poly++])
+    {
         type[0] = PT_MOVETO;
-        /* win98 adds an extra line to close the figure for some reason */
-        add_log_points( physdev, pts, 1, PT_LINETO | PT_CLOSEFIGURE );
-        pts += counts[poly];
+        type[counts[poly] - 1] = PT_LINETO | PT_CLOSEFIGURE;
     }
     return TRUE;
 }
@@ -1322,13 +1330,18 @@ static BOOL pathdrv_PolyPolyline( PHYSDEV dev, const POINT* pts, const DWORD* co
     UINT poly, count;
     BYTE *type;
 
-    for (poly = count = 0; poly < polylines; poly++) count += counts[poly];
+    if (!polylines) return FALSE;
+    for (poly = count = 0; poly < polylines; poly++)
+    {
+        if (counts[poly] < 2) return FALSE;
+        count += counts[poly];
+    }
 
     type = add_log_points( physdev, pts, count, PT_LINETO );
     if (!type) return FALSE;
 
     /* make the first point of each polyline a PT_MOVETO */
-    for (poly = 0; poly < polylines; poly++, type += counts[poly]) *type = PT_MOVETO;
+    for (poly = 0; poly < polylines; type += counts[poly++]) *type = PT_MOVETO;
     return TRUE;
 }
 




More information about the wine-cvs mailing list