[2/2] gdiplus: implemented GdipAddPathPie/GdipAddPathPieI with test
Nikolay Sivov
bunglehead at gmail.com
Mon Aug 4 12:45:16 CDT 2008
Changelog:
- implemented GdipAddPathPie/GdipAddPathPieI with test
---
dlls/gdiplus/gdiplus.spec | 4 +-
dlls/gdiplus/graphicspath.c | 51 +++++++++++++++++++++++++++++++++++++
dlls/gdiplus/tests/graphicspath.c | 27 +++++++++++++++++++
include/gdiplusflat.h | 2 +
4 files changed, 82 insertions(+), 2 deletions(-)
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index add7b0e..57f9734 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -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)
diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c
index c5925b6..9e62d69 100644
--- a/dlls/gdiplus/graphicspath.c
+++ b/dlls/gdiplus/graphicspath.c
@@ -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;
diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c
index 97e92fa..d08b20b 100644
--- a/dlls/gdiplus/tests/graphicspath.c
+++ b/dlls/gdiplus/tests/graphicspath.c
@@ -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);
}
diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h
index 4203e16..ed88096 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -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);
--
1.4.4.4
More information about the wine-patches
mailing list