gdiplus: Implemented GdipAddPathPie/GdipAddPathPieI with test.

This commit is contained in:
Nikolay Sivov 2008-08-04 21:45:16 +04:00 committed by Alexandre Julliard
parent 5887e661b7
commit aa0df2300e
4 changed files with 82 additions and 2 deletions

View File

@ -21,8 +21,8 @@
@ stdcall GdipAddPathLine(ptr long long long long)
@ stdcall GdipAddPathLineI(ptr long long long long)
@ stdcall GdipAddPathPath(ptr ptr long)
@ stub GdipAddPathPie
@ stub GdipAddPathPieI
@ stdcall GdipAddPathPie(ptr long long long long long long)
@ stdcall GdipAddPathPieI(ptr long long long long long long)
@ stdcall GdipAddPathPolygon(ptr ptr long)
@ stdcall GdipAddPathPolygonI(ptr ptr long)
@ stdcall GdipAddPathRectangle(ptr long long long long)

View File

@ -546,6 +546,57 @@ GpStatus WINGDIPAPI GdipAddPathPath(GpPath *path, GDIPCONST GpPath* addingPath,
return Ok;
}
GpStatus WINGDIPAPI GdipAddPathPie(GpPath *path, REAL x, REAL y, REAL width, REAL height,
REAL startAngle, REAL sweepAngle)
{
GpPointF *ptf;
GpStatus status;
INT i, count;
if(!path)
return InvalidParameter;
count = arc2polybezier(NULL, x, y, width, height, startAngle, sweepAngle);
if(count == 0)
return Ok;
ptf = GdipAlloc(sizeof(GpPointF)*count);
if(!ptf)
return OutOfMemory;
arc2polybezier(ptf, x, y, width, height, startAngle, sweepAngle);
status = GdipAddPathLine(path, (width - x)/2, (height - y)/2, ptf[0].X, ptf[0].Y);
if(status != Ok){
GdipFree(ptf);
return status;
}
/* one spline is already added as a line endpoint */
if(!lengthen_path(path, count - 1)){
GdipFree(ptf);
return OutOfMemory;
}
memcpy(&(path->pathdata.Points[path->pathdata.Count]), &(ptf[1]),sizeof(GpPointF)*(count-1));
for(i = 0; i < count-1; i++)
path->pathdata.Types[path->pathdata.Count+i] = PathPointTypeBezier;
path->pathdata.Count += count-1;
GdipClosePathFigure(path);
GdipFree(ptf);
return status;
}
GpStatus WINGDIPAPI GdipAddPathPieI(GpPath *path, INT x, INT y, INT width, INT height,
REAL startAngle, REAL sweepAngle)
{
return GdipAddPathPieI(path, (REAL)x, (REAL)y, (REAL)width, (REAL)height, startAngle, sweepAngle);
}
GpStatus WINGDIPAPI GdipAddPathPolygon(GpPath *path, GDIPCONST GpPointF *points, INT count)
{
INT old_count;

View File

@ -856,6 +856,32 @@ static void test_reverse(void)
GdipDeletePath(path);
}
static path_test_t addpie_path[] = {
{50.0, 25.0, PathPointTypeStart, 0, 0}, /*0*/
{97.2, 33.3, PathPointTypeLine, 0, 0}, /*1*/
{91.8, 40.9, PathPointTypeBezier,0, 0}, /*2*/
{79.4, 46.8, PathPointTypeBezier,0, 0}, /*3*/
{63.9, 49.0, PathPointTypeBezier | PathPointTypeCloseSubpath, 0, 0} /*4*/
};
static void test_addpie(void)
{
GpStatus status;
GpPath *path;
GdipCreatePath(FillModeAlternate, &path);
/* NULL argument */
status = GdipAddPathPie(NULL, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
expect(InvalidParameter, status);
status = GdipAddPathPie(path, 0.0, 0.0, 100.0, 50.0, 10.0, 50.0);
expect(Ok, status);
ok_path(path, addpie_path, sizeof(addpie_path)/sizeof(path_test_t), FALSE);
GdipDeletePath(path);
}
START_TEST(graphicspath)
{
struct GdiplusStartupInput gdiplusStartupInput;
@ -882,6 +908,7 @@ START_TEST(graphicspath)
test_addcurve();
test_addclosedcurve();
test_reverse();
test_addpie();
GdiplusShutdown(gdiplusToken);
}

View File

@ -261,6 +261,8 @@ GpStatus WINGDIPAPI GdipAddPathLine2(GpPath*,GDIPCONST GpPointF*,INT);
GpStatus WINGDIPAPI GdipAddPathLine2I(GpPath*,GDIPCONST GpPoint*,INT);
GpStatus WINGDIPAPI GdipAddPathLineI(GpPath*,INT,INT,INT,INT);
GpStatus WINGDIPAPI GdipAddPathPath(GpPath*,GDIPCONST GpPath*,BOOL);
GpStatus WINGDIPAPI GdipAddPathPie(GpPath*,REAL,REAL,REAL,REAL,REAL,REAL);
GpStatus WINGDIPAPI GdipAddPathPieI(GpPath*,INT,INT,INT,INT,REAL,REAL);
GpStatus WINGDIPAPI GdipAddPathPolygon(GpPath*,GDIPCONST GpPointF*,INT);
GpStatus WINGDIPAPI GdipAddPathPolygonI(GpPath*,GDIPCONST GpPoint*,INT);
GpStatus WINGDIPAPI GdipAddPathRectangle(GpPath*,REAL,REAL,REAL,REAL);