Jeff Smith : gdiplus: Reuse point when calling GdipAddPathBeziers on open figure.

Alexandre Julliard julliard at winehq.org
Thu Apr 16 16:45:13 CDT 2020


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

Author: Jeff Smith <whydoubt at gmail.com>
Date:   Wed Apr 15 15:07:08 2020 -0500

gdiplus: Reuse point when calling GdipAddPathBeziers on open figure.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48877
Signed-off-by: Jeff Smith <whydoubt at gmail.com>
Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdiplus/graphicspath.c       | 20 +-------------------
 dlls/gdiplus/tests/graphicspath.c | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c
index 547f172d98..2729455567 100644
--- a/dlls/gdiplus/graphicspath.c
+++ b/dlls/gdiplus/graphicspath.c
@@ -322,30 +322,12 @@ GpStatus WINGDIPAPI GdipAddPathBezierI(GpPath *path, INT x1, INT y1, INT x2,
 GpStatus WINGDIPAPI GdipAddPathBeziers(GpPath *path, GDIPCONST GpPointF *points,
     INT count)
 {
-    INT i, old_count;
-
     TRACE("(%p, %p, %d)\n", path, points, count);
 
     if(!path || !points || ((count - 1) % 3))
         return InvalidParameter;
 
-    if(!lengthen_path(path, count))
-        return OutOfMemory;
-
-    old_count = path->pathdata.Count;
-
-    for(i = 0; i < count; i++){
-        path->pathdata.Points[old_count + i].X = points[i].X;
-        path->pathdata.Points[old_count + i].Y = points[i].Y;
-        path->pathdata.Types[old_count + i] = PathPointTypeBezier;
-    }
-
-    path->pathdata.Types[old_count] =
-        (path->newfigure ? PathPointTypeStart : PathPointTypeLine);
-    path->newfigure = FALSE;
-    path->pathdata.Count += count;
-
-    return Ok;
+    return extend_current_figure(path, points, count, PathPointTypeBezier);
 }
 
 GpStatus WINGDIPAPI GdipAddPathBeziersI(GpPath *path, GDIPCONST GpPoint *points,
diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c
index d85cf68dfc..d19c7836fb 100644
--- a/dlls/gdiplus/tests/graphicspath.c
+++ b/dlls/gdiplus/tests/graphicspath.c
@@ -365,6 +365,28 @@ static void test_bezier(void)
     GdipDeletePath(path);
 }
 
+static void test_beziers(void)
+{
+    GpStatus status;
+    GpPath* path;
+    PointF bezier_points1[] = {{10.0,10.0}, {20.0,10.0}, {20.0,20.0}, {30.0,20.0}};
+    PointF bezier_points2[] = {{30.0,20.0}, {40.0,20.0}, {40.0,30.0}, {50.0,30.0}};
+    PointF bezier_points3[] = {{50.0,10.0}, {60.0,10.0}, {60.0,20.0}, {70.0,20.0}};
+
+    GdipCreatePath(FillModeAlternate, &path);
+
+    status = GdipAddPathBeziers(path, bezier_points1, 4);
+    expect(Ok, status);
+    status = GdipAddPathBeziers(path, bezier_points2, 4);
+    expect(Ok, status);
+    status = GdipAddPathBeziers(path, bezier_points3, 4);
+    expect(Ok, status);
+
+    ok_path(path, bezier_path, ARRAY_SIZE(bezier_path), FALSE);
+
+    GdipDeletePath(path);
+}
+
 static path_test_t arc_path[] = {
     {600.0, 450.0, PathPointTypeStart, 0, 0}, /*0*/
     {600.0, 643.3, PathPointTypeBezier, 0, 0}, /*1*/
@@ -1818,6 +1840,7 @@ START_TEST(graphicspath)
     test_createpath2();
     test_line2();
     test_bezier();
+    test_beziers();
     test_arc();
     test_worldbounds();
     test_pathpath();




More information about the wine-cvs mailing list