From: Bartosz Kosiorek gang65@poczta.onet.pl
--- dlls/gdiplus/customlinecap.c | 16 +++++++-------- dlls/gdiplus/gdiplus_private.h | 4 +++- dlls/gdiplus/graphicspath.c | 2 +- dlls/gdiplus/tests/customlinecap.c | 31 ++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 10 deletions(-)
diff --git a/dlls/gdiplus/customlinecap.c b/dlls/gdiplus/customlinecap.c index 306c4db242b..f35fea90eba 100644 --- a/dlls/gdiplus/customlinecap.c +++ b/dlls/gdiplus/customlinecap.c @@ -97,6 +97,8 @@ static GpStatus init_custom_linecap(GpCustomLineCap *cap, GpPathData *pathdata,
cap->inset = base_inset; cap->basecap = basecap; + cap->strokeStartCap = LineCapFlat; + cap->strokeEndCap = LineCapFlat; cap->join = LineJoinMiter; cap->scale = 1.0;
@@ -177,19 +179,17 @@ GpStatus WINGDIPAPI GdipGetCustomLineCapWidthScale(GpCustomLineCap* custom, }
GpStatus WINGDIPAPI GdipSetCustomLineCapStrokeCaps(GpCustomLineCap* custom, - GpLineCap start, GpLineCap end) + GpLineCap startcap, GpLineCap endcap) { - static int calls; + TRACE("(%p,%u,%u)\n", custom, startcap, endcap);
- TRACE("(%p,%u,%u)\n", custom, start, end); - - if(!custom) + if(!custom || startcap > LineCapTriangle || endcap > LineCapTriangle) return InvalidParameter;
- if(!(calls++)) - FIXME("not implemented\n"); + custom->strokeStartCap = startcap; + custom->strokeEndCap = endcap;
- return NotImplemented; + return Ok; }
GpStatus WINGDIPAPI GdipSetCustomLineCapBaseCap(GpCustomLineCap* custom, diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 51b83b3242a..bb7d32af47f 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -352,7 +352,9 @@ struct GpCustomLineCap{ GpPathData pathdata; BOOL fill; /* TRUE for fill, FALSE for stroke */ GpLineCap basecap; /* cap used together with customLineCap */ - REAL inset; /* distance between line and cap */ + REAL inset; /* distance between line end and cap beginning */ + GpLineCap strokeStartCap; + GpLineCap strokeEndCap; GpLineJoin join; /* joins used for drawing custom cap*/ REAL scale; }; diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index 08c96416e7c..18df3b13fe2 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -2213,7 +2213,7 @@ static void add_anchor(const GpPointF *endpoint, const GpPointF *nextpoint, if ((custom->pathdata.Types[custom->pathdata.Count - 1] & PathPointTypeCloseSubpath) == PathPointTypeCloseSubpath) widen_closed_figure(tmp_points, 0, custom->pathdata.Count - 1, pen, pen_width, last_point); else - widen_open_figure(tmp_points, 0, custom->pathdata.Count - 1, pen, pen_width, LineCapFlat, LineCapFlat, last_point); + widen_open_figure(tmp_points, 0, custom->pathdata.Count - 1, pen, pen_width, custom->strokeStartCap, custom->strokeEndCap, last_point); } else { diff --git a/dlls/gdiplus/tests/customlinecap.c b/dlls/gdiplus/tests/customlinecap.c index 89323040ad1..9efb0694285 100644 --- a/dlls/gdiplus/tests/customlinecap.c +++ b/dlls/gdiplus/tests/customlinecap.c @@ -380,6 +380,36 @@ static void test_captype(void) GdipDeleteCustomLineCap((GpCustomLineCap*)arrowcap); }
+static void test_strokecap(void) +{ + GpAdjustableArrowCap *arrowcap; + GpCustomLineCap *cap; + CustomLineCapType type; + GpStatus stat; + GpPath *path; + + /* default cap */ + stat = GdipCreatePath(FillModeAlternate, &path); + ok(stat == Ok, "Failed to create path, %d\n", stat); + stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0); + ok(stat == Ok, "AddPathRectangle failed, %d\n", stat); + + stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &cap); + ok(stat == Ok, "Failed to create cap, %d\n", stat); + + stat = GdipSetCustomLineCapStrokeCaps((GpCustomLineCap*)cap, LineCapSquare, LineCapFlat); + ok(stat == Ok, "Unexpected return code, %d\n", stat); + + stat = GdipSetCustomLineCapStrokeCaps((GpCustomLineCap*)cap, LineCapSquareAnchor, LineCapFlat); + ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat); + + stat = GdipSetCustomLineCapStrokeCaps((GpCustomLineCap*)cap, LineCapFlat, LineCapSquareAnchor); + ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat); + GdipDeleteCustomLineCap(cap); + GdipDeletePath(path); + GdipDeleteCustomLineCap((GpCustomLineCap*)arrowcap); +} + START_TEST(customlinecap) { struct GdiplusStartupInput gdiplusStartupInput; @@ -405,6 +435,7 @@ START_TEST(customlinecap) test_scale(); test_create_adjustable_cap(); test_captype(); + test_strokecap();
GdiplusShutdown(gdiplusToken); }