Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/gdiplus/tests/graphicspath.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index aabacef3aa..8c025a4eca 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -75,7 +75,8 @@ typedef struct int todo; } path_test_t;
-static void ok_path(GpPath* path, const path_test_t *expected, INT expected_size, BOOL todo_size) +#define ok_path(a,b,c,d) ok_path_fudge(a,b,c,d,2.0) +static void ok_path_fudge(GpPath* path, const path_test_t *expected, INT expected_size, BOOL todo_size, REAL fudge) { BYTE * types; INT size, idx = 0, eidx = 0, numskip; @@ -104,8 +105,8 @@ static void ok_path(GpPath* path, const path_test_t *expected, INT expected_size /* We allow a few pixels fudge in matching X and Y coordinates to account for imprecision in * floating point to integer conversion */ BOOL match = (types[idx] == expected[eidx].type) && - fabs(points[idx].X - expected[eidx].X) <= 2.0 && - fabs(points[idx].Y - expected[eidx].Y) <= 2.0; + fabs(points[idx].X - expected[eidx].X) <= fudge && + fabs(points[idx].Y - expected[eidx].Y) <= fudge;
stringify_point_type(expected[eidx].type, ename); stringify_point_type(types[idx], name); @@ -1416,7 +1417,7 @@ static void test_widen_cap(void)
status = GdipWidenPath(path, pen, NULL, FlatnessDefault); expect(Ok, status); - ok_path(path, caps[i].expected, caps[i].expected_size, caps[i].todo_size); + ok_path_fudge(path, caps[i].expected, caps[i].expected_size, caps[i].todo_size, 0.000005); }
GdipDeletePen(pen);
Signed-off-by: Jeff Smith whydoubt@gmail.com --- Resending 2-3 in the series, which the mailing list ate.
dlls/gdiplus/tests/graphicspath.c | 40 +++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 12 deletions(-)
diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index 8c025a4eca..3495e4d08e 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -1364,35 +1364,49 @@ static path_test_t widenline_caparrowanchor_path[] = { {32.679489, 0.0, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0}, /*9*/ };
+static path_test_t widenline_capsquareanchor_thin_path[] = { + {6.414213, 8.585786, PathPointTypeStart, 4, 1}, /*0*/ + {6.414213, 11.414213, PathPointTypeLine, 0, 1}, /*1*/ + {3.585786, 11.414213, PathPointTypeLine, 0, 1}, /*2*/ + {3.585786, 8.585786, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 1}, /*3*/ + {48.585785, 11.414213, PathPointTypeStart, 0, 1}, /*4*/ + {48.585785, 8.585786, PathPointTypeLine, 0, 1}, /*5*/ + {51.414211, 8.585786, PathPointTypeLine, 0, 1}, /*6*/ + {51.414211, 11.414213, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 1}, /*7*/ + }; + static void test_widen_cap(void) { struct { LineCap type; + REAL line_width; const path_test_t *expected; INT expected_size; BOOL todo_size; } caps[] = { - { LineCapFlat, widenline_capflat_path, + { LineCapFlat, 10.0, widenline_capflat_path, ARRAY_SIZE(widenline_capflat_path) }, - { LineCapSquare, widenline_capsquare_path, + { LineCapSquare, 10.0, widenline_capsquare_path, ARRAY_SIZE(widenline_capsquare_path) }, - { LineCapRound, widenline_capround_path, + { LineCapRound, 10.0, widenline_capround_path, ARRAY_SIZE(widenline_capround_path) }, - { LineCapTriangle, widenline_captriangle_path, + { LineCapTriangle, 10.0, widenline_captriangle_path, ARRAY_SIZE(widenline_captriangle_path) }, - { LineCapNoAnchor, widenline_capflat_path, + { LineCapNoAnchor, 10.0, widenline_capflat_path, ARRAY_SIZE(widenline_capflat_path) }, - { LineCapSquareAnchor, widenline_capsquareanchor_path, + { LineCapSquareAnchor, 10.0, widenline_capsquareanchor_path, ARRAY_SIZE(widenline_capsquareanchor_path) }, - { LineCapRoundAnchor, widenline_caproundanchor_path, + { LineCapRoundAnchor, 10.0, widenline_caproundanchor_path, ARRAY_SIZE(widenline_caproundanchor_path) }, - { LineCapDiamondAnchor, widenline_capdiamondanchor_path, + { LineCapDiamondAnchor, 10.0, widenline_capdiamondanchor_path, ARRAY_SIZE(widenline_capdiamondanchor_path) }, - { LineCapArrowAnchor, widenline_caparrowanchor_path, + { LineCapArrowAnchor, 10.0, widenline_caparrowanchor_path, ARRAY_SIZE(widenline_caparrowanchor_path), TRUE }, + { LineCapSquareAnchor, 0.0, widenline_capsquareanchor_thin_path, + ARRAY_SIZE(widenline_capsquareanchor_thin_path), TRUE }, }; GpStatus status; GpPath *path; @@ -1401,11 +1415,12 @@ static void test_widen_cap(void)
status = GdipCreatePath(FillModeAlternate, &path); expect(Ok, status); - status = GdipCreatePen1(0xffffffff, 10.0, UnitPixel, &pen); - expect(Ok, status);
for (i = 0; i < ARRAY_SIZE(caps); i++) { + status = GdipCreatePen1(0xffffffff, caps[i].line_width, UnitPixel, &pen); + expect(Ok, status); + status = GdipResetPath(path); expect(Ok, status); status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0); @@ -1418,9 +1433,10 @@ static void test_widen_cap(void) status = GdipWidenPath(path, pen, NULL, FlatnessDefault); expect(Ok, status); ok_path_fudge(path, caps[i].expected, caps[i].expected_size, caps[i].todo_size, 0.000005); + + GdipDeletePen(pen); }
- GdipDeletePen(pen); GdipDeletePath(path); }
Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/gdiplus/graphicspath.c | 16 +++++++++------- dlls/gdiplus/tests/graphicspath.c | 16 ++++++++-------- 2 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index 249f584089..0e62d7db7d 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -1986,6 +1986,8 @@ static void widen_cap(const GpPointF *endpoint, const GpPointF *nextpoint, static void add_anchor(const GpPointF *endpoint, const GpPointF *nextpoint, GpPen *pen, GpLineCap cap, GpCustomLineCap *custom, path_list_node_t **last_point) { + REAL pen_width = max(pen->width, 2.0); + switch (cap) { default: @@ -1996,7 +1998,7 @@ static void add_anchor(const GpPointF *endpoint, const GpPointF *nextpoint, REAL segment_dy = nextpoint->Y-endpoint->Y; REAL segment_dx = nextpoint->X-endpoint->X; REAL segment_length = sqrtf(segment_dy*segment_dy + segment_dx*segment_dx); - REAL distance = pen->width / sqrtf(2.0); + REAL distance = pen_width / sqrtf(2.0); REAL par_dx, par_dy; REAL perp_dx, perp_dy;
@@ -2024,8 +2026,8 @@ static void add_anchor(const GpPointF *endpoint, const GpPointF *nextpoint, REAL dx, dy, dx2, dy2; const REAL control_point_distance = 0.55228475; /* 4/3 * (sqrt(2) - 1) */
- dx = -pen->width * segment_dx / segment_length; - dy = -pen->width * segment_dy / segment_length; + dx = -pen_width * segment_dx / segment_length; + dy = -pen_width * segment_dy / segment_length;
dx2 = dx * control_point_distance; dy2 = dy * control_point_distance; @@ -2076,11 +2078,11 @@ static void add_anchor(const GpPointF *endpoint, const GpPointF *nextpoint, REAL par_dx, par_dy; REAL perp_dx, perp_dy;
- par_dx = -pen->width * segment_dx / segment_length; - par_dy = -pen->width * segment_dy / segment_length; + par_dx = -pen_width * segment_dx / segment_length; + par_dy = -pen_width * segment_dy / segment_length;
- perp_dx = -pen->width * segment_dy / segment_length; - perp_dy = pen->width * segment_dx / segment_length; + perp_dx = -pen_width * segment_dy / segment_length; + perp_dy = pen_width * segment_dx / segment_length;
*last_point = add_path_list_node(*last_point, endpoint->X + par_dx, endpoint->Y + par_dy, PathPointTypeStart); diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index 3495e4d08e..99f25930ca 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -1365,14 +1365,14 @@ static path_test_t widenline_caparrowanchor_path[] = { };
static path_test_t widenline_capsquareanchor_thin_path[] = { - {6.414213, 8.585786, PathPointTypeStart, 4, 1}, /*0*/ - {6.414213, 11.414213, PathPointTypeLine, 0, 1}, /*1*/ - {3.585786, 11.414213, PathPointTypeLine, 0, 1}, /*2*/ - {3.585786, 8.585786, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 1}, /*3*/ - {48.585785, 11.414213, PathPointTypeStart, 0, 1}, /*4*/ - {48.585785, 8.585786, PathPointTypeLine, 0, 1}, /*5*/ - {51.414211, 8.585786, PathPointTypeLine, 0, 1}, /*6*/ - {51.414211, 11.414213, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 1}, /*7*/ + {6.414213, 8.585786, PathPointTypeStart, 4, 0}, /*0*/ + {6.414213, 11.414213, PathPointTypeLine, 0, 0}, /*1*/ + {3.585786, 11.414213, PathPointTypeLine, 0, 0}, /*2*/ + {3.585786, 8.585786, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0}, /*3*/ + {48.585785, 11.414213, PathPointTypeStart, 0, 0}, /*4*/ + {48.585785, 8.585786, PathPointTypeLine, 0, 0}, /*5*/ + {51.414211, 8.585786, PathPointTypeLine, 0, 0}, /*6*/ + {51.414211, 11.414213, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0}, /*7*/ };
static void test_widen_cap(void)
Signed-off-by: Vincent Povirk vincent@codeweavers.com
Signed-off-by: Vincent Povirk vincent@codeweavers.com