[PATCH v2 5/6] gdiplus: Reuse point when calling GdipAddPathArc on open figure.
Jeff Smith
whydoubt at gmail.com
Wed Apr 15 15:07:11 CDT 2020
Signed-off-by: Jeff Smith <whydoubt at gmail.com>
---
dlls/gdiplus/graphicspath.c | 25 ++++++++++---------------
dlls/gdiplus/tests/graphicspath.c | 14 ++++++++++++++
2 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c
index 04806a95af..ba977f970a 100644
--- a/dlls/gdiplus/graphicspath.c
+++ b/dlls/gdiplus/graphicspath.c
@@ -241,7 +241,9 @@ static GpStatus extend_current_figure(GpPath *path, GDIPCONST PointF *points, IN
GpStatus WINGDIPAPI GdipAddPathArc(GpPath *path, REAL x1, REAL y1, REAL x2,
REAL y2, REAL startAngle, REAL sweepAngle)
{
- INT count, old_count, i;
+ GpPointF *points;
+ GpStatus status;
+ INT count;
TRACE("(%p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f)\n",
path, x1, y1, x2, y2, startAngle, sweepAngle);
@@ -250,26 +252,19 @@ GpStatus WINGDIPAPI GdipAddPathArc(GpPath *path, REAL x1, REAL y1, REAL x2,
return InvalidParameter;
count = arc2polybezier(NULL, x1, y1, x2, y2, startAngle, sweepAngle);
-
if(count == 0)
return Ok;
- if(!lengthen_path(path, count))
+
+ points = heap_alloc_zero(sizeof(GpPointF)*count);
+ if(!points)
return OutOfMemory;
- old_count = path->pathdata.Count;
- arc2polybezier(&path->pathdata.Points[old_count], x1, y1, x2, y2,
- startAngle, sweepAngle);
+ arc2polybezier(points, x1, y1, x2, y2, startAngle, sweepAngle);
- for(i = 0; i < count; i++){
- path->pathdata.Types[old_count + i] = PathPointTypeBezier;
- }
-
- path->pathdata.Types[old_count] =
- (path->newfigure ? PathPointTypeStart : PathPointTypeLine);
- path->newfigure = FALSE;
- path->pathdata.Count += count;
+ status = extend_current_figure(path, points, count, PathPointTypeBezier);
- return Ok;
+ heap_free(points);
+ return status;
}
/*******************************************************************************
diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c
index b3ee72f29b..a02500bc1d 100644
--- a/dlls/gdiplus/tests/graphicspath.c
+++ b/dlls/gdiplus/tests/graphicspath.c
@@ -435,6 +435,13 @@ static path_test_t arc_path[] = {
{450.9, 824.1, PathPointTypeBezier, 0, 0}, /*36*/
{540.4, 676.9, PathPointTypeBezier | PathPointTypeCloseSubpath, 0, 1} /*37*/
};
+static path_test_t arc_path2[] = {
+ {1.0, 0.0, PathPointTypeStart, 0, 0}, /*0*/
+ {1.0, 0.5, PathPointTypeLine, 0, 0}, /*1*/
+ {1.0, 0.776142, PathPointTypeBezier, 0, 0}, /*2*/
+ {0.776142, 1.0, PathPointTypeBezier, 0, 0}, /*3*/
+ {0.5, 1.0, PathPointTypeBezier, 0, 0} /*4*/
+ };
static void test_arc(void)
{
@@ -463,6 +470,13 @@ static void test_arc(void)
ok_path(path, arc_path, ARRAY_SIZE(arc_path), FALSE);
+ GdipResetPath(path);
+ GdipAddPathLine(path, 1.0, 0.0, 1.0, 0.5);
+ status = GdipAddPathArc(path, 0.0, 0.0, 1.0, 1.0, 0.0, 90.0);
+ expect(Ok, status);
+
+ ok_path_fudge(path, arc_path2, ARRAY_SIZE(arc_path2), FALSE, 0.000005);
+
GdipDeletePath(path);
}
--
2.23.0
More information about the wine-devel
mailing list