Commit 7ff16aff authored by Jeff Smith's avatar Jeff Smith Committed by Alexandre Julliard

gdiplus: Reuse point when calling GdipAddPathArc on open figure.

parent c5ae9029
......@@ -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;
}
/*******************************************************************************
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment