Module: wine Branch: master Commit: 4c0edba681181418e4ede547da49ec3dc903c704 URL: http://source.winehq.org/git/wine.git/?a=commit;h=4c0edba681181418e4ede547da...
Author: Andrew Eikum andrew@brightnightgames.com Date: Mon Jun 29 22:12:40 2009 -0500
gdiplus: Implement GdipDrawCurve3 and GdipDrawCurve3I.
---
dlls/gdiplus/gdiplus.spec | 4 +- dlls/gdiplus/graphics.c | 30 ++++++++ dlls/gdiplus/tests/graphics.c | 162 +++++++++++++++++++++++++++++++++++++++++ include/gdiplusflat.h | 2 + 4 files changed, 196 insertions(+), 2 deletions(-)
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index b93d5f6..008841d 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -165,8 +165,8 @@ @ stdcall GdipDrawClosedCurveI(ptr ptr ptr long) @ stdcall GdipDrawCurve2(ptr ptr ptr long long) @ stdcall GdipDrawCurve2I(ptr ptr ptr long long) -@ stub GdipDrawCurve3 -@ stub GdipDrawCurve3I +@ stdcall GdipDrawCurve3(ptr ptr ptr long long long long) +@ stdcall GdipDrawCurve3I(ptr ptr ptr long long long long) @ stdcall GdipDrawCurve(ptr ptr ptr long) @ stdcall GdipDrawCurveI(ptr ptr ptr long) @ stdcall GdipDrawDriverString(ptr ptr long ptr ptr ptr long ptr) diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 152d590..2be64c7 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -1532,6 +1532,36 @@ GpStatus WINGDIPAPI GdipDrawCurve2I(GpGraphics *graphics, GpPen *pen, return ret; }
+GpStatus WINGDIPAPI GdipDrawCurve3(GpGraphics *graphics, GpPen *pen, + GDIPCONST GpPointF *points, INT count, INT offset, INT numberOfSegments, + REAL tension) +{ + TRACE("(%p, %p, %p, %d, %d, %d, %.2f)\n", graphics, pen, points, count, offset, numberOfSegments, tension); + + if(offset >= count || numberOfSegments > count - offset - 1 || numberOfSegments <= 0){ + return InvalidParameter; + } + + return GdipDrawCurve2(graphics, pen, points + offset, numberOfSegments + 1, tension); +} + +GpStatus WINGDIPAPI GdipDrawCurve3I(GpGraphics *graphics, GpPen *pen, + GDIPCONST GpPoint *points, INT count, INT offset, INT numberOfSegments, + REAL tension) +{ + TRACE("(%p, %p, %p, %d, %d, %d, %.2f)\n", graphics, pen, points, count, offset, numberOfSegments, tension); + + if(count < 0){ + return OutOfMemory; + } + + if(offset >= count || numberOfSegments > count - offset - 1 || numberOfSegments <= 0){ + return InvalidParameter; + } + + return GdipDrawCurve2I(graphics, pen, points + offset, numberOfSegments + 1, tension); +} + GpStatus WINGDIPAPI GdipDrawEllipse(GpGraphics *graphics, GpPen *pen, REAL x, REAL y, REAL width, REAL height) { diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index e42044a..ad7f2d3 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -361,6 +361,166 @@ static void test_GdipDrawBezierI(void) ReleaseDC(0, hdc); }
+static void test_GdipDrawCurve3(void) +{ + GpStatus status; + GpGraphics *graphics = NULL; + GpPen *pen = NULL; + HDC hdc = GetDC(0); + GpPointF points[3]; + + points[0].X = 0; + points[0].Y = 0; + + points[1].X = 40; + points[1].Y = 20; + + points[2].X = 10; + points[2].Y = 40; + + /* make a graphics object and pen object */ + ok(hdc != NULL, "Expected HDC to be initialized\n"); + + status = GdipCreateFromHDC(hdc, &graphics); + expect(Ok, status); + ok(graphics != NULL, "Expected graphics to be initialized\n"); + + status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen); + expect(Ok, status); + ok(pen != NULL, "Expected pen to be initialized\n"); + + /* InvalidParameter cases: null graphics, null pen */ + status = GdipDrawCurve3(NULL, NULL, points, 3, 0, 2, 1); + expect(InvalidParameter, status); + + status = GdipDrawCurve3(graphics, NULL, points, 3, 0, 2, 1); + expect(InvalidParameter, status); + + status = GdipDrawCurve3(NULL, pen, points, 3, 0, 2, 1); + expect(InvalidParameter, status); + + /* InvalidParameter cases: invalid count */ + status = GdipDrawCurve3(graphics, pen, points, -1, 0, 2, 1); + expect(InvalidParameter, status); + + status = GdipDrawCurve3(graphics, pen, points, 0, 0, 2, 1); + expect(InvalidParameter, status); + + status = GdipDrawCurve3(graphics, pen, points, 1, 0, 0, 1); + expect(InvalidParameter, status); + + status = GdipDrawCurve3(graphics, pen, points, 3, 4, 2, 1); + expect(InvalidParameter, status); + + /* InvalidParameter cases: invalid number of segments */ + status = GdipDrawCurve3(graphics, pen, points, 3, 0, -1, 1); + expect(InvalidParameter, status); + + status = GdipDrawCurve3(graphics, pen, points, 3, 1, 2, 1); + expect(InvalidParameter, status); + + status = GdipDrawCurve3(graphics, pen, points, 2, 0, 2, 1); + expect(InvalidParameter, status); + + /* Valid test cases */ + status = GdipDrawCurve3(graphics, pen, points, 2, 0, 1, 1); + expect(Ok, status); + + status = GdipDrawCurve3(graphics, pen, points, 3, 0, 2, 2); + expect(Ok, status); + + status = GdipDrawCurve3(graphics, pen, points, 2, 0, 1, -2); + expect(Ok, status); + + status = GdipDrawCurve3(graphics, pen, points, 3, 1, 1, 0); + expect(Ok, status); + + GdipDeletePen(pen); + GdipDeleteGraphics(graphics); + + ReleaseDC(0, hdc); +} + +static void test_GdipDrawCurve3I(void) +{ + GpStatus status; + GpGraphics *graphics = NULL; + GpPen *pen = NULL; + HDC hdc = GetDC(0); + GpPoint points[3]; + + points[0].X = 0; + points[0].Y = 0; + + points[1].X = 40; + points[1].Y = 20; + + points[2].X = 10; + points[2].Y = 40; + + /* make a graphics object and pen object */ + ok(hdc != NULL, "Expected HDC to be initialized\n"); + + status = GdipCreateFromHDC(hdc, &graphics); + expect(Ok, status); + ok(graphics != NULL, "Expected graphics to be initialized\n"); + + status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen); + expect(Ok, status); + ok(pen != NULL, "Expected pen to be initialized\n"); + + /* InvalidParameter cases: null graphics, null pen */ + status = GdipDrawCurve3I(NULL, NULL, points, 3, 0, 2, 1); + expect(InvalidParameter, status); + + status = GdipDrawCurve3I(graphics, NULL, points, 3, 0, 2, 1); + expect(InvalidParameter, status); + + status = GdipDrawCurve3I(NULL, pen, points, 3, 0, 2, 1); + expect(InvalidParameter, status); + + /* InvalidParameter cases: invalid count */ + status = GdipDrawCurve3I(graphics, pen, points, -1, -1, -1, 1); + expect(OutOfMemory, status); + + status = GdipDrawCurve3I(graphics, pen, points, 0, 0, 2, 1); + expect(InvalidParameter, status); + + status = GdipDrawCurve3I(graphics, pen, points, 1, 0, 0, 1); + expect(InvalidParameter, status); + + status = GdipDrawCurve3I(graphics, pen, points, 3, 4, 2, 1); + expect(InvalidParameter, status); + + /* InvalidParameter cases: invalid number of segments */ + status = GdipDrawCurve3I(graphics, pen, points, 3, 0, -1, 1); + expect(InvalidParameter, status); + + status = GdipDrawCurve3I(graphics, pen, points, 3, 1, 2, 1); + expect(InvalidParameter, status); + + status = GdipDrawCurve3I(graphics, pen, points, 2, 0, 2, 1); + expect(InvalidParameter, status); + + /* Valid test cases */ + status = GdipDrawCurve3I(graphics, pen, points, 2, 0, 1, 1); + expect(Ok, status); + + status = GdipDrawCurve3I(graphics, pen, points, 3, 0, 2, 2); + expect(Ok, status); + + status = GdipDrawCurve3I(graphics, pen, points, 2, 0, 1, -2); + expect(Ok, status); + + status = GdipDrawCurve3I(graphics, pen, points, 3, 1, 1, 0); + expect(Ok, status); + + GdipDeletePen(pen); + GdipDeleteGraphics(graphics); + + ReleaseDC(0, hdc); +} + static void test_GdipDrawCurve2(void) { GpStatus status; @@ -1345,6 +1505,8 @@ START_TEST(graphics) test_GdipDrawCurveI(); test_GdipDrawCurve2(); test_GdipDrawCurve2I(); + test_GdipDrawCurve3(); + test_GdipDrawCurve3I(); test_GdipDrawLineI(); test_GdipDrawLinesI(); test_GdipDrawString(); diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h index 4e830b5..48c188b 100644 --- a/include/gdiplusflat.h +++ b/include/gdiplusflat.h @@ -147,6 +147,8 @@ GpStatus WINGDIPAPI GdipDrawCurve(GpGraphics*,GpPen*,GDIPCONST GpPointF*,INT); GpStatus WINGDIPAPI GdipDrawCurveI(GpGraphics*,GpPen*,GDIPCONST GpPoint*,INT); GpStatus WINGDIPAPI GdipDrawCurve2(GpGraphics*,GpPen*,GDIPCONST GpPointF*,INT,REAL); GpStatus WINGDIPAPI GdipDrawCurve2I(GpGraphics*,GpPen*,GDIPCONST GpPoint*,INT,REAL); +GpStatus WINGDIPAPI GdipDrawCurve3(GpGraphics*,GpPen*,GDIPCONST GpPointF*,INT,INT,INT,REAL); +GpStatus WINGDIPAPI GdipDrawCurve3I(GpGraphics*,GpPen*,GDIPCONST GpPoint*,INT,INT,INT,REAL); GpStatus WINGDIPAPI GdipDrawEllipse(GpGraphics*,GpPen*,REAL,REAL,REAL,REAL); GpStatus WINGDIPAPI GdipDrawEllipseI(GpGraphics*,GpPen*,INT,INT,INT,INT); GpStatus WINGDIPAPI GdipDrawImage(GpGraphics*,GpImage*,REAL,REAL);