Commit 4c0edba6 authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

gdiplus: Implement GdipDrawCurve3 and GdipDrawCurve3I.

parent d6bb2b75
......@@ -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)
......
......@@ -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)
{
......
......@@ -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();
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment