Module: wine Branch: master Commit: e0f32f53d575cdffd0f35d39d97a941281e3e23d URL: https://gitlab.winehq.org/wine/wine/-/commit/e0f32f53d575cdffd0f35d39d97a941...
Author: Bartosz Kosiorek gang65@poczta.onet.pl Date: Fri Nov 18 16:50:04 2022 +0100
gdiplus: Add GdipSetCustomLineCapStrokeCaps implementation and usage.
---
dlls/gdiplus/customlinecap.c | 16 ++++++++-------- dlls/gdiplus/gdiplus_private.h | 2 ++ dlls/gdiplus/graphicspath.c | 2 +- dlls/gdiplus/tests/customlinecap.c | 28 ++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 9 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 baae159d7f9..c68fdedb0b8 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -353,6 +353,8 @@ struct GpCustomLineCap{ BOOL fill; /* TRUE for fill, FALSE for stroke */ GpLineCap basecap; /* cap used together with customLineCap */ 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 8bb835c1ca1..fdb7dd24906 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -2145,7 +2145,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->strokeEndCap, custom->strokeStartCap, last_point); } else { diff --git a/dlls/gdiplus/tests/customlinecap.c b/dlls/gdiplus/tests/customlinecap.c index 89323040ad1..4ff090ddce0 100644 --- a/dlls/gdiplus/tests/customlinecap.c +++ b/dlls/gdiplus/tests/customlinecap.c @@ -380,6 +380,33 @@ static void test_captype(void) GdipDeleteCustomLineCap((GpCustomLineCap*)arrowcap); }
+static void test_strokecap(void) +{ + GpCustomLineCap *cap; + 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); +} + START_TEST(customlinecap) { struct GdiplusStartupInput gdiplusStartupInput; @@ -405,6 +432,7 @@ START_TEST(customlinecap) test_scale(); test_create_adjustable_cap(); test_captype(); + test_strokecap();
GdiplusShutdown(gdiplusToken); }