Nikolay Sivov : gdiplus: Added GdipAddPathCurve3/ GdipAddPathCurve3I with tests.

Alexandre Julliard julliard at winehq.org
Mon Dec 15 08:27:18 CST 2008


Module: wine
Branch: master
Commit: 7cddc57989261aaa1ef4a7d066e75505fe28d748
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7cddc57989261aaa1ef4a7d066e75505fe28d748

Author: Nikolay Sivov <bunglehead at gmail.com>
Date:   Mon Dec 15 02:52:35 2008 +0300

gdiplus: Added GdipAddPathCurve3/GdipAddPathCurve3I with tests.

---

 dlls/gdiplus/gdiplus.spec         |    4 +-
 dlls/gdiplus/graphicspath.c       |   22 ++++++++++++++++++++
 dlls/gdiplus/tests/graphicspath.c |   40 +++++++++++++++++++++++++++++++++++++
 include/gdiplusflat.h             |    2 +
 4 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index 9473f1b..d380d74 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -10,8 +10,8 @@
 @ stdcall GdipAddPathClosedCurveI(ptr ptr long)
 @ stdcall GdipAddPathCurve2(ptr ptr long long)
 @ stdcall GdipAddPathCurve2I(ptr ptr long long)
-@ stub GdipAddPathCurve3
-@ stub GdipAddPathCurve3I
+@ stdcall GdipAddPathCurve3(ptr ptr long long long long)
+@ stdcall GdipAddPathCurve3I(ptr ptr long long long long)
 @ stdcall GdipAddPathCurve(ptr ptr long)
 @ stdcall GdipAddPathCurveI(ptr ptr long)
 @ stdcall GdipAddPathEllipse(ptr long long long long)
diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c
index 20a3b2c..042d4a2 100644
--- a/dlls/gdiplus/graphicspath.c
+++ b/dlls/gdiplus/graphicspath.c
@@ -524,6 +524,28 @@ GpStatus WINGDIPAPI GdipAddPathCurve2I(GpPath *path, GDIPCONST GpPoint *points,
     return stat;
 }
 
+GpStatus WINGDIPAPI GdipAddPathCurve3(GpPath *path, GDIPCONST GpPointF *points,
+    INT count, INT offset, INT nseg, REAL tension)
+{
+    TRACE("(%p, %p, %d, %d, %d, %.2f)\n", path, points, count, offset, nseg, tension);
+
+    if(!path || !points || offset + 1 >= count || count - offset < nseg + 1)
+        return InvalidParameter;
+
+    return GdipAddPathCurve2(path, &points[offset], nseg + 1, tension);
+}
+
+GpStatus WINGDIPAPI GdipAddPathCurve3I(GpPath *path, GDIPCONST GpPoint *points,
+    INT count, INT offset, INT nseg, REAL tension)
+{
+    TRACE("(%p, %p, %d, %d, %d, %.2f)\n", path, points, count, offset, nseg, tension);
+
+    if(!path || !points || offset + 1 >= count || count - offset < nseg + 1)
+        return InvalidParameter;
+
+    return GdipAddPathCurve2I(path, &points[offset], nseg + 1, tension);
+}
+
 GpStatus WINGDIPAPI GdipAddPathEllipse(GpPath *path, REAL x, REAL y, REAL width,
     REAL height)
 {
diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c
index 168c4b5..416d80c 100644
--- a/dlls/gdiplus/tests/graphicspath.c
+++ b/dlls/gdiplus/tests/graphicspath.c
@@ -726,6 +726,15 @@ static path_test_t addcurve_path2[] = {
     {23.3, 13.3, PathPointTypeBezier, 0, 0}, /*10*/
     {30.0, 10.0, PathPointTypeBezier, 0, 0}  /*11*/
     };
+static path_test_t addcurve_path3[] = {
+    {10.0, 10.0, PathPointTypeStart,  0, 0}, /*0*/
+    {13.3, 16.7, PathPointTypeBezier, 0, 1}, /*1*/
+    {3.3,  20.0, PathPointTypeBezier, 0, 0}, /*2*/
+    {10.0, 20.0, PathPointTypeBezier, 0, 0}, /*3*/
+    {16.7, 20.0, PathPointTypeBezier, 0, 0}, /*4*/
+    {23.3, 13.3, PathPointTypeBezier, 0, 0}, /*5*/
+    {30.0, 10.0, PathPointTypeBezier, 0, 0}  /*6*/
+    };
 static void test_addcurve(void)
 {
     GpStatus status;
@@ -765,6 +774,37 @@ static void test_addcurve(void)
     status = GdipAddPathCurve2(path, points, 4, 1.0);
     expect(Ok, status);
     ok_path(path, addcurve_path2, sizeof(addcurve_path2)/sizeof(path_test_t), FALSE);
+
+    /* NULL args */
+    GdipResetPath(path);
+    status = GdipAddPathCurve3(NULL, NULL, 0, 0, 0, 0.0);
+    expect(InvalidParameter, status);
+    status = GdipAddPathCurve3(path, NULL, 0, 0, 0, 0.0);
+    expect(InvalidParameter, status);
+    /* wrong count, offset.. */
+    status = GdipAddPathCurve3(path, points, 0, 0, 0, 0.0);
+    expect(InvalidParameter, status);
+    status = GdipAddPathCurve3(path, points, 4, 0, 0, 0.0);
+    expect(InvalidParameter, status);
+    status = GdipAddPathCurve3(path, points, 4, 0, 4, 0.0);
+    expect(InvalidParameter, status);
+    status = GdipAddPathCurve3(path, points, 4, 1, 3, 0.0);
+    expect(InvalidParameter, status);
+    status = GdipAddPathCurve3(path, points, 4, 1, 0, 0.0);
+    expect(InvalidParameter, status);
+    status = GdipAddPathCurve3(path, points, 4, 3, 1, 0.0);
+    expect(InvalidParameter, status);
+
+    /* use all points */
+    status = GdipAddPathCurve3(path, points, 4, 0, 3, 1.0);
+    expect(Ok, status);
+    ok_path(path, addcurve_path, sizeof(addcurve_path)/sizeof(path_test_t), FALSE);
+    GdipResetPath(path);
+
+    status = GdipAddPathCurve3(path, points, 4, 1, 2, 1.0);
+    expect(Ok, status);
+    ok_path(path, addcurve_path3, sizeof(addcurve_path3)/sizeof(path_test_t), FALSE);
+
     GdipDeletePath(path);
 }
 
diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h
index 216b2f3..1a39dee 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -256,6 +256,8 @@ GpStatus WINGDIPAPI GdipAddPathCurve(GpPath*,GDIPCONST GpPointF*,INT);
 GpStatus WINGDIPAPI GdipAddPathCurveI(GpPath*,GDIPCONST GpPoint*,INT);
 GpStatus WINGDIPAPI GdipAddPathCurve2(GpPath*,GDIPCONST GpPointF*,INT,REAL);
 GpStatus WINGDIPAPI GdipAddPathCurve2I(GpPath*,GDIPCONST GpPoint*,INT,REAL);
+GpStatus WINGDIPAPI GdipAddPathCurve3(GpPath*,GDIPCONST GpPointF*,INT,INT,INT,REAL);
+GpStatus WINGDIPAPI GdipAddPathCurve3I(GpPath*,GDIPCONST GpPoint*,INT,INT,INT,REAL);
 GpStatus WINGDIPAPI GdipAddPathEllipse(GpPath*,REAL,REAL,REAL,REAL);
 GpStatus WINGDIPAPI GdipAddPathEllipseI(GpPath*,INT,INT,INT,INT);
 GpStatus WINGDIPAPI GdipAddPathLine(GpPath*,REAL,REAL,REAL,REAL);




More information about the wine-cvs mailing list