Module: wine Branch: master Commit: 003b5de4f2f08bf1d278ef0dd05cd6004f621afb URL: http://source.winehq.org/git/wine.git/?a=commit;h=003b5de4f2f08bf1d278ef0dd0...
Author: Lei Zhang thestig@google.com Date: Fri Dec 28 13:08:09 2007 -0800
gdiplus: Add GdipCreatePen2 and test cases.
---
dlls/gdiplus/gdiplus.spec | 2 +- dlls/gdiplus/pen.c | 12 ++++++++++-- dlls/gdiplus/tests/pen.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index 796b7cb..1b9e427 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -121,7 +121,7 @@ @ stub GdipCreatePathGradientI @ stdcall GdipCreatePathIter(ptr ptr) @ stdcall GdipCreatePen1(long long long ptr) -@ stub GdipCreatePen2 +@ stdcall GdipCreatePen2(ptr long long ptr) @ stub GdipCreateRegion @ stub GdipCreateRegionHrgn @ stub GdipCreateRegionPath diff --git a/dlls/gdiplus/pen.c b/dlls/gdiplus/pen.c index 320f375..92d76d8 100644 --- a/dlls/gdiplus/pen.c +++ b/dlls/gdiplus/pen.c @@ -87,9 +87,17 @@ GpStatus WINGDIPAPI GdipClonePen(GpPen *pen, GpPen **clonepen) GpStatus WINGDIPAPI GdipCreatePen1(ARGB color, REAL width, GpUnit unit, GpPen **pen) { + GpBrush *brush; + GdipCreateSolidFill(color, (GpSolidFill **)(&brush)); + return GdipCreatePen2(brush, width, unit, pen); +} + +GpStatus WINGDIPAPI GdipCreatePen2(GpBrush *brush, REAL width, GpUnit unit, + GpPen **pen) +{ GpPen *gp_pen;
- if(!pen) + if(!pen || !brush) return InvalidParameter;
gp_pen = GdipAlloc(sizeof(GpPen)); @@ -103,7 +111,7 @@ GpStatus WINGDIPAPI GdipCreatePen1(ARGB color, REAL width, GpUnit unit, gp_pen->miterlimit = 10.0; gp_pen->dash = DashStyleSolid; gp_pen->offset = 0.0; - GdipCreateSolidFill(color, (GpSolidFill **)(&gp_pen->brush)); + gp_pen->brush = brush;
if(!((gp_pen->unit == UnitWorld) || (gp_pen->unit == UnitPixel))) { FIXME("UnitWorld, UnitPixel only supported units\n"); diff --git a/dlls/gdiplus/tests/pen.c b/dlls/gdiplus/tests/pen.c index 33b73f9..ad484ce 100644 --- a/dlls/gdiplus/tests/pen.c +++ b/dlls/gdiplus/tests/pen.c @@ -62,6 +62,10 @@ static void test_constructor_destructor(void) GpStatus status; GpPen *pen = NULL;
+ status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, NULL); + expect(InvalidParameter, status); + ok(pen == NULL, "Expected pen to be NULL\n"); + status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen); expect(Ok, status); ok(pen != NULL, "Expected pen to be initialized\n"); @@ -73,6 +77,38 @@ static void test_constructor_destructor(void) expect(Ok, status); }
+static void test_constructor_destructor2(void) +{ + GpStatus status; + GpPen *pen = NULL; + GpBrush *brush = NULL; + GpPointF points[2]; + + status = GdipCreatePen2(NULL, 10.0f, UnitPixel, &pen); + expect(InvalidParameter, status); + ok(pen == NULL, "Expected pen to be NULL\n"); + + points[0].X = 7.0; + points[0].Y = 11.0; + points[1].X = 13.0; + points[1].Y = 17.0; + + status = GdipCreateLineBrush(&points[0], &points[1], (ARGB)0xffff00ff, + (ARGB)0xff0000ff, WrapModeTile, (GpLineGradient **)&brush); + expect(Ok, status); + ok(brush != NULL, "Expected brush to be initialized\n"); + + status = GdipCreatePen2(brush, 10.0f, UnitPixel, &pen); + expect(Ok, status); + ok(pen != NULL, "Expected pen to be initialized\n"); + + status = GdipDeletePen(pen); + expect(Ok, status); + + status = GdipDeleteBrush(brush); + expect(Ok, status); +} + static void test_brushfill(void) { GpStatus status; @@ -205,6 +241,7 @@ START_TEST(pen) GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
test_constructor_destructor(); + test_constructor_destructor2(); test_brushfill(); test_dasharray();