[PATCH 2/5] gdiplus: Reuse point when calling GdipAddPathBeziers on open figure.
Jeff Smith
whydoubt at gmail.com
Tue Apr 14 13:59:03 CDT 2020
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48877
Signed-off-by: Jeff Smith <whydoubt at gmail.com>
---
dlls/gdiplus/graphicspath.c | 14 ++++++--------
dlls/gdiplus/tests/graphicspath.c | 23 +++++++++++++++++++++++
2 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c
index 6d2760bef4..cabe8d4bd4 100644
--- a/dlls/gdiplus/graphicspath.c
+++ b/dlls/gdiplus/graphicspath.c
@@ -314,27 +314,25 @@ GpStatus WINGDIPAPI GdipAddPathBeziers(GpPath *path, GDIPCONST GpPointF *points,
INT count)
{
INT i, old_count;
+ GpStatus status;
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;
+ status = extend_current_figure(path, count, points[0].X, points[0].Y, &old_count);
+ if(status != Ok)
+ return status;
- for(i = 0; i < count; i++){
+ for(i = 1; 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;
+ path->pathdata.Count = old_count + count;
return Ok;
}
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();
--
2.23.0
More information about the wine-devel
mailing list