gdiplus: Reuse point when calling GdipAddPathArc on open figure.

Signed-off-by: Jeff Smith <whydoubt@gmail.com>
Signed-off-by: Vincent Povirk <vincent@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jeff Smith 2020-04-15 15:07:11 -05:00 committed by Alexandre Julliard
parent c5ae902946
commit 7ff16aff06
2 changed files with 24 additions and 15 deletions

View File

@ -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;
}
status = extend_current_figure(path, points, count, PathPointTypeBezier);
path->pathdata.Types[old_count] =
(path->newfigure ? PathPointTypeStart : PathPointTypeLine);
path->newfigure = FALSE;
path->pathdata.Count += count;
return Ok;
heap_free(points);
return status;
}
/*******************************************************************************

View File

@ -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);
}