diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index 48d46a3992..5b046a1f4e 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -352,8 +352,8 @@ @ stdcall GdipGetPenColor(ptr ptr) @ stub GdipGetPenCompoundArray @ stub GdipGetPenCompoundCount -@ stub GdipGetPenCustomEndCap -@ stub GdipGetPenCustomStartCap +@ stdcall GdipGetPenCustomEndCap(ptr ptr) +@ stdcall GdipGetPenCustomStartCap(ptr ptr) @ stdcall GdipGetPenDashArray(ptr ptr long) @ stdcall GdipGetPenDashCap197819(ptr ptr) @ stdcall GdipGetPenDashCount(ptr ptr) diff --git a/dlls/gdiplus/pen.c b/dlls/gdiplus/pen.c index 829b191562..104d9de648 100644 --- a/dlls/gdiplus/pen.c +++ b/dlls/gdiplus/pen.c @@ -116,6 +116,8 @@ GpStatus WINGDIPAPI GdipCreatePen2(GpBrush *brush, REAL width, GpUnit unit, gp_pen->miterlimit = 10.0; gp_pen->dash = DashStyleSolid; gp_pen->offset = 0.0; + gp_pen->customstart = NULL; + gp_pen->customend = NULL; if(!((gp_pen->unit == UnitWorld) || (gp_pen->unit == UnitPixel))) { FIXME("UnitWorld, UnitPixel only supported units\n"); @@ -163,6 +165,32 @@ GpStatus WINGDIPAPI GdipGetPenColor(GpPen *pen, ARGB *argb) return GdipGetSolidFillColor(((GpSolidFill*)pen->brush), argb); } +GpStatus WINGDIPAPI GdipGetPenCustomEndCap(GpPen *pen, GpCustomLineCap** customCap) +{ + if(!pen || !customCap) + return InvalidParameter; + + if(!pen->customend){ + *customCap = NULL; + return Ok; + } + + return GdipCloneCustomLineCap(pen->customend, customCap); +} + +GpStatus WINGDIPAPI GdipGetPenCustomStartCap(GpPen *pen, GpCustomLineCap** customCap) +{ + if(!pen || !customCap) + return InvalidParameter; + + if(!pen->customstart){ + *customCap = NULL; + return Ok; + } + + return GdipCloneCustomLineCap(pen->customstart, customCap); +} + GpStatus WINGDIPAPI GdipGetPenDashArray(GpPen *pen, REAL *dash, INT count) { if(!pen || !dash || count > pen->numdashes) @@ -312,7 +340,8 @@ GpStatus WINGDIPAPI GdipSetPenCustomEndCap(GpPen *pen, GpCustomLineCap* customCa GpCustomLineCap * cap; GpStatus ret; - if(!pen || !customCap) return InvalidParameter; + /* native crashes on pen == NULL, customCap != NULL */ + if(!customCap) return InvalidParameter; if((ret = GdipCloneCustomLineCap(customCap, &cap)) == Ok){ GdipDeleteCustomLineCap(pen->customend); @@ -328,7 +357,8 @@ GpStatus WINGDIPAPI GdipSetPenCustomStartCap(GpPen *pen, GpCustomLineCap* custom GpCustomLineCap * cap; GpStatus ret; - if(!pen || !customCap) return InvalidParameter; + /* native crashes on pen == NULL, customCap != NULL */ + if(!customCap) return InvalidParameter; if((ret = GdipCloneCustomLineCap(customCap, &cap)) == Ok){ GdipDeleteCustomLineCap(pen->customstart); diff --git a/dlls/gdiplus/tests/pen.c b/dlls/gdiplus/tests/pen.c index ad484ce477..d75e510f9e 100644 --- a/dlls/gdiplus/tests/pen.c +++ b/dlls/gdiplus/tests/pen.c @@ -226,6 +226,55 @@ static void test_dasharray(void) GdipDeletePen(pen); } +static void test_customcap(void) +{ + GpPen *pen; + GpStatus status; + GpCustomLineCap *custom; + + status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen); + expect(Ok, status); + + /* NULL args */ + status = GdipGetPenCustomStartCap(NULL, NULL); + expect(InvalidParameter, status); + status = GdipGetPenCustomStartCap(pen, NULL); + expect(InvalidParameter, status); + status = GdipGetPenCustomStartCap(NULL, &custom); + expect(InvalidParameter, status); + + status = GdipGetPenCustomEndCap(NULL, NULL); + expect(InvalidParameter, status); + status = GdipGetPenCustomEndCap(pen, NULL); + expect(InvalidParameter, status); + status = GdipGetPenCustomEndCap(NULL, &custom); + expect(InvalidParameter, status); + + /* native crashes on pen == NULL, custom != NULL */ + status = GdipSetPenCustomStartCap(NULL, NULL); + expect(InvalidParameter, status); + status = GdipSetPenCustomStartCap(pen, NULL); + expect(InvalidParameter, status); + + status = GdipSetPenCustomEndCap(NULL, NULL); + expect(InvalidParameter, status); + status = GdipSetPenCustomEndCap(pen, NULL); + expect(InvalidParameter, status); + + /* get without setting previously */ + custom = (GpCustomLineCap*)0xdeadbeef; + status = GdipGetPenCustomEndCap(pen, &custom); + expect(Ok, status); + ok(custom == NULL,"Expect CustomCap == NULL\n"); + + custom = (GpCustomLineCap*)0xdeadbeef; + status = GdipGetPenCustomStartCap(pen, &custom); + expect(Ok, status); + ok(custom == NULL,"Expect CustomCap == NULL\n"); + + GdipDeletePen(pen); +} + START_TEST(pen) { struct GdiplusStartupInput gdiplusStartupInput; @@ -244,6 +293,7 @@ START_TEST(pen) test_constructor_destructor2(); test_brushfill(); test_dasharray(); + test_customcap(); GdiplusShutdown(gdiplusToken); } diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h index 2e0d743b1f..4293f6429e 100644 --- a/include/gdiplusflat.h +++ b/include/gdiplusflat.h @@ -33,6 +33,8 @@ GpStatus WINGDIPAPI GdipCreatePen2(GpBrush*,REAL,GpUnit,GpPen**); GpStatus WINGDIPAPI GdipDeletePen(GpPen*); GpStatus WINGDIPAPI GdipGetPenBrushFill(GpPen*,GpBrush**); GpStatus WINGDIPAPI GdipGetPenColor(GpPen*,ARGB*); +GpStatus WINGDIPAPI GdipGetPenCustomStartCap(GpPen*,GpCustomLineCap**); +GpStatus WINGDIPAPI GdipGetPenCustomEndCap(GpPen*,GpCustomLineCap**); GpStatus WINGDIPAPI GdipGetPenDashArray(GpPen*,REAL*,INT); GpStatus WINGDIPAPI GdipGetPenDashCount(GpPen*,INT*); GpStatus WINGDIPAPI GdipGetPenDashOffset(GpPen*,REAL*);