Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/gdiplus/tests/graphicspath.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index 83a5e99138..7fd9b02b28 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -1077,6 +1077,13 @@ static path_test_t widenline_dash_path[] = { {45.0, 10.0, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0}, /*7*/ };
+static path_test_t widenline_unit_path[] = { + {5.0, 9.5, PathPointTypeStart, 0, 1}, /*0*/ + {50.0, 9.5, PathPointTypeLine, 0, 1}, /*1*/ + {50.0, 10.5, PathPointTypeLine, 0, 1}, /*2*/ + {5.0, 10.5, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 1} /*3*/ + }; + static void test_widen(void) { GpStatus status; @@ -1241,6 +1248,23 @@ static void test_widen(void) expect(Ok, status); todo_wine expect(0, count);
+ /* pen width = 0 pixels, UnitWorld - result is a path 1 unit wide */ + GdipDeletePen(pen); + status = GdipCreatePen1(0xffffffff, 0.0, UnitWorld, &pen); + expect(Ok, status); + + status = GdipResetPath(path); + expect(Ok, status); + status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0); + expect(Ok, status); + + status = GdipWidenPath(path, pen, m, 1.0); + expect(Ok, status); + + status = GdipGetPointCount(path, &count); + expect(Ok, status); + ok_path_fudge(path, widenline_unit_path, ARRAY_SIZE(widenline_unit_path), FALSE, 0.000005); + GdipDeleteMatrix(m); GdipDeletePen(pen); GdipDeletePath(path);
Signed-off-by: Jeff Smith whydoubt@gmail.com --- I re-ordered the parameter ordering for some functions, to consistently group (input) path parameters before pen parameters.
dlls/gdiplus/graphicspath.c | 82 ++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 41 deletions(-)
diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index af0d6500f8..9e819242b8 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -1804,12 +1804,12 @@ GpStatus WINGDIPAPI GdipWarpPath(GpPath *path, GpMatrix* matrix, }
static void add_bevel_point(const GpPointF *endpoint, const GpPointF *nextpoint, - GpPen *pen, int right_side, path_list_node_t **last_point) + REAL pen_width, int right_side, path_list_node_t **last_point) { 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/2.0; + REAL distance = pen_width / 2.0; REAL bevel_dx, bevel_dy;
if (segment_length == 0.0) @@ -1835,7 +1835,7 @@ static void add_bevel_point(const GpPointF *endpoint, const GpPointF *nextpoint, }
static void widen_joint(const GpPointF *p1, const GpPointF *p2, const GpPointF *p3, - GpPen* pen, path_list_node_t **last_point) + GpPen* pen, REAL pen_width, path_list_node_t **last_point) { switch (pen->join) { @@ -1843,7 +1843,7 @@ static void widen_joint(const GpPointF *p1, const GpPointF *p2, const GpPointF * case LineJoinMiterClipped: if ((p2->X - p1->X) * (p3->Y - p1->Y) > (p2->Y - p1->Y) * (p3->X - p1->X)) { - float distance = pen->width/2.0; + float distance = pen_width / 2.0; float length_0 = sqrtf((p2->X-p1->X)*(p2->X-p1->X)+(p2->Y-p1->Y)*(p2->Y-p1->Y)); float length_1 = sqrtf((p3->X-p2->X)*(p3->X-p2->X)+(p3->Y-p2->Y)*(p3->Y-p2->Y)); float dx0 = distance * (p2->X - p1->X) / length_0; @@ -1870,14 +1870,14 @@ static void widen_joint(const GpPointF *p1, const GpPointF *p2, const GpPointF * /* else fall-through */ default: case LineJoinBevel: - add_bevel_point(p2, p1, pen, 1, last_point); - add_bevel_point(p2, p3, pen, 0, last_point); + add_bevel_point(p2, p1, pen_width, 1, last_point); + add_bevel_point(p2, p3, pen_width, 0, last_point); break; } }
static void widen_cap(const GpPointF *endpoint, const GpPointF *nextpoint, - GpPen *pen, GpLineCap cap, GpCustomLineCap *custom, int add_first_points, + REAL pen_width, GpLineCap cap, GpCustomLineCap *custom, int add_first_points, int add_last_point, path_list_node_t **last_point) { switch (cap) @@ -1885,16 +1885,16 @@ static void widen_cap(const GpPointF *endpoint, const GpPointF *nextpoint, default: case LineCapFlat: if (add_first_points) - add_bevel_point(endpoint, nextpoint, pen, 1, last_point); + add_bevel_point(endpoint, nextpoint, pen_width, 1, last_point); if (add_last_point) - add_bevel_point(endpoint, nextpoint, pen, 0, last_point); + add_bevel_point(endpoint, nextpoint, pen_width, 0, last_point); break; case LineCapSquare: { 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/2.0; + REAL distance = pen_width / 2.0; REAL bevel_dx, bevel_dy; REAL extend_dx, extend_dy;
@@ -1919,7 +1919,7 @@ static void widen_cap(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/2.0; + REAL distance = pen_width / 2.0; REAL dx, dy, dx2, dy2; const REAL control_point_distance = 0.5522847498307935; /* 4/3 * (sqrt(2) - 1) */
@@ -1956,7 +1956,7 @@ static void widen_cap(const GpPointF *endpoint, const GpPointF *nextpoint, endpoint->Y + dx, PathPointTypeBezier); } else if (add_last_point) - add_bevel_point(endpoint, nextpoint, pen, 0, last_point); + add_bevel_point(endpoint, nextpoint, pen_width, 0, last_point); break; } case LineCapTriangle: @@ -1964,20 +1964,20 @@ static void widen_cap(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/2.0; + REAL distance = pen_width / 2.0; REAL dx, dy;
dx = distance * segment_dx / segment_length; dy = distance * segment_dy / segment_length;
if (add_first_points) { - add_bevel_point(endpoint, nextpoint, pen, 1, last_point); + add_bevel_point(endpoint, nextpoint, pen_width, 1, last_point);
*last_point = add_path_list_node(*last_point, endpoint->X - dx, endpoint->Y - dy, PathPointTypeLine); } if (add_first_points || add_last_point) - add_bevel_point(endpoint, nextpoint, pen, 0, last_point); + add_bevel_point(endpoint, nextpoint, pen_width, 0, last_point); break; } } @@ -2097,9 +2097,9 @@ static void add_anchor(const GpPointF *endpoint, const GpPointF *nextpoint, (*last_point)->type |= PathPointTypeCloseSubpath; }
-static void widen_open_figure(const GpPointF *points, GpPen *pen, int start, int end, - GpLineCap start_cap, GpCustomLineCap *start_custom, GpLineCap end_cap, - GpCustomLineCap *end_custom, path_list_node_t **last_point) +static void widen_open_figure(const GpPointF *points, int start, int end, + GpPen *pen, REAL pen_width, GpLineCap start_cap, GpCustomLineCap *start_custom, + GpLineCap end_cap, GpCustomLineCap *end_custom, path_list_node_t **last_point) { int i; path_list_node_t *prev_point; @@ -2110,28 +2110,28 @@ static void widen_open_figure(const GpPointF *points, GpPen *pen, int start, int prev_point = *last_point;
widen_cap(&points[start], &points[start+1], - pen, start_cap, start_custom, FALSE, TRUE, last_point); + pen_width, start_cap, start_custom, FALSE, TRUE, last_point);
for (i=start+1; i<end; i++) - widen_joint(&points[i-1], &points[i], - &points[i+1], pen, last_point); + widen_joint(&points[i-1], &points[i], &points[i+1], + pen, pen_width, last_point);
widen_cap(&points[end], &points[end-1], - pen, end_cap, end_custom, TRUE, TRUE, last_point); + pen_width, end_cap, end_custom, TRUE, TRUE, last_point);
for (i=end-1; i>start; i--) - widen_joint(&points[i+1], &points[i], - &points[i-1], pen, last_point); + widen_joint(&points[i+1], &points[i], &points[i-1], + pen, pen_width, last_point);
widen_cap(&points[start], &points[start+1], - pen, start_cap, start_custom, TRUE, FALSE, last_point); + pen_width, start_cap, start_custom, TRUE, FALSE, last_point);
prev_point->next->type = PathPointTypeStart; (*last_point)->type |= PathPointTypeCloseSubpath; }
-static void widen_closed_figure(GpPath *path, GpPen *pen, int start, int end, - path_list_node_t **last_point) +static void widen_closed_figure(GpPath *path, int start, int end, + GpPen *pen, REAL pen_width, path_list_node_t **last_point) { int i; path_list_node_t *prev_point; @@ -2143,14 +2143,14 @@ static void widen_closed_figure(GpPath *path, GpPen *pen, int start, int end, prev_point = *last_point;
widen_joint(&path->pathdata.Points[end], &path->pathdata.Points[start], - &path->pathdata.Points[start+1], pen, last_point); + &path->pathdata.Points[start+1], pen, pen_width, last_point);
for (i=start+1; i<end; i++) widen_joint(&path->pathdata.Points[i-1], &path->pathdata.Points[i], - &path->pathdata.Points[i+1], pen, last_point); + &path->pathdata.Points[i+1], pen, pen_width, last_point);
widen_joint(&path->pathdata.Points[end-1], &path->pathdata.Points[end], - &path->pathdata.Points[start], pen, last_point); + &path->pathdata.Points[start], pen, pen_width, last_point);
prev_point->next->type = PathPointTypeStart; (*last_point)->type |= PathPointTypeCloseSubpath; @@ -2159,21 +2159,21 @@ static void widen_closed_figure(GpPath *path, GpPen *pen, int start, int end, prev_point = *last_point;
widen_joint(&path->pathdata.Points[start], &path->pathdata.Points[end], - &path->pathdata.Points[end-1], pen, last_point); + &path->pathdata.Points[end-1], pen, pen_width, last_point);
for (i=end-1; i>start; i--) widen_joint(&path->pathdata.Points[i+1], &path->pathdata.Points[i], - &path->pathdata.Points[i-1], pen, last_point); + &path->pathdata.Points[i-1], pen, pen_width, last_point);
widen_joint(&path->pathdata.Points[start+1], &path->pathdata.Points[start], - &path->pathdata.Points[end], pen, last_point); + &path->pathdata.Points[end], pen, pen_width, last_point);
prev_point->next->type = PathPointTypeStart; (*last_point)->type |= PathPointTypeCloseSubpath; }
-static void widen_dashed_figure(GpPath *path, GpPen *pen, int start, int end, - int closed, path_list_node_t **last_point) +static void widen_dashed_figure(GpPath *path, int start, int end, int closed, + GpPen *pen, REAL pen_width, path_list_node_t **last_point) { int i, j; REAL dash_pos=0.0; @@ -2267,7 +2267,7 @@ static void widen_dashed_figure(GpPath *path, GpPen *pen, int start, int end, tmp_points[num_tmp_points].X = path->pathdata.Points[i].X + segment_dx * segment_pos / segment_length; tmp_points[num_tmp_points].Y = path->pathdata.Points[i].Y + segment_dy * segment_pos / segment_length;
- widen_open_figure(tmp_points, pen, 0, num_tmp_points, + widen_open_figure(tmp_points, 0, num_tmp_points, pen, pen_width, draw_start_cap ? pen->startcap : LineCapFlat, pen->customstart, LineCapFlat, NULL, last_point); draw_start_cap = 0; @@ -2301,7 +2301,7 @@ static void widen_dashed_figure(GpPath *path, GpPen *pen, int start, int end, if (dash_index % 2 == 0 && num_tmp_points != 0) { /* last dash overflows last segment */ - widen_open_figure(tmp_points, pen, 0, num_tmp_points-1, + widen_open_figure(tmp_points, 0, num_tmp_points-1, pen, pen_width, draw_start_cap ? pen->startcap : LineCapFlat, pen->customstart, closed ? LineCapFlat : pen->endcap, pen->customend, last_point); } @@ -2364,17 +2364,17 @@ GpStatus WINGDIPAPI GdipWidenPath(GpPath *path, GpPen *pen, GpMatrix *matrix, if ((types[i]&PathPointTypeCloseSubpath) == PathPointTypeCloseSubpath) { if (pen->dash != DashStyleSolid) - widen_dashed_figure(flat_path, pen, subpath_start, i, 1, &last_point); + widen_dashed_figure(flat_path, subpath_start, i, 1, pen, pen->width, &last_point); else - widen_closed_figure(flat_path, pen, subpath_start, i, &last_point); + widen_closed_figure(flat_path, subpath_start, i, pen, pen->width, &last_point); } else if (i == flat_path->pathdata.Count-1 || (types[i+1]&PathPointTypePathTypeMask) == PathPointTypeStart) { if (pen->dash != DashStyleSolid) - widen_dashed_figure(flat_path, pen, subpath_start, i, 0, &last_point); + widen_dashed_figure(flat_path, subpath_start, i, 0, pen, pen->width, &last_point); else - widen_open_figure(flat_path->pathdata.Points, pen, subpath_start, i, pen->startcap, pen->customstart, pen->endcap, pen->customend, &last_point); + widen_open_figure(flat_path->pathdata.Points, subpath_start, i, pen, pen->width, pen->startcap, pen->customstart, pen->endcap, pen->customend, &last_point); } }
Signed-off-by: Vincent Povirk vincent@codeweavers.com
Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/gdiplus/graphicspath.c | 9 +++++---- dlls/gdiplus/tests/graphicspath.c | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index 9e819242b8..0308c943f3 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -2337,6 +2337,7 @@ GpStatus WINGDIPAPI GdipWidenPath(GpPath *path, GpPen *pen, GpMatrix *matrix, if (status == Ok) { REAL anchor_pen_width = max(pen->width, 2.0); + REAL pen_width = (pen->unit == UnitWorld) ? max(pen->width, 1.0) : pen->width; BYTE *types = flat_path->pathdata.Types;
last_point = points; @@ -2364,17 +2365,17 @@ GpStatus WINGDIPAPI GdipWidenPath(GpPath *path, GpPen *pen, GpMatrix *matrix, if ((types[i]&PathPointTypeCloseSubpath) == PathPointTypeCloseSubpath) { if (pen->dash != DashStyleSolid) - widen_dashed_figure(flat_path, subpath_start, i, 1, pen, pen->width, &last_point); + widen_dashed_figure(flat_path, subpath_start, i, 1, pen, pen_width, &last_point); else - widen_closed_figure(flat_path, subpath_start, i, pen, pen->width, &last_point); + widen_closed_figure(flat_path, subpath_start, i, pen, pen_width, &last_point); } else if (i == flat_path->pathdata.Count-1 || (types[i+1]&PathPointTypePathTypeMask) == PathPointTypeStart) { if (pen->dash != DashStyleSolid) - widen_dashed_figure(flat_path, subpath_start, i, 0, pen, pen->width, &last_point); + widen_dashed_figure(flat_path, subpath_start, i, 0, pen, pen_width, &last_point); else - widen_open_figure(flat_path->pathdata.Points, subpath_start, i, pen, pen->width, pen->startcap, pen->customstart, pen->endcap, pen->customend, &last_point); + widen_open_figure(flat_path->pathdata.Points, subpath_start, i, pen, pen_width, pen->startcap, pen->customstart, pen->endcap, pen->customend, &last_point); } }
diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index 7fd9b02b28..2362872fa0 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -1078,10 +1078,10 @@ static path_test_t widenline_dash_path[] = { };
static path_test_t widenline_unit_path[] = { - {5.0, 9.5, PathPointTypeStart, 0, 1}, /*0*/ - {50.0, 9.5, PathPointTypeLine, 0, 1}, /*1*/ - {50.0, 10.5, PathPointTypeLine, 0, 1}, /*2*/ - {5.0, 10.5, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 1} /*3*/ + {5.0, 9.5, PathPointTypeStart, 0, 0}, /*0*/ + {50.0, 9.5, PathPointTypeLine, 0, 0}, /*1*/ + {50.0, 10.5, PathPointTypeLine, 0, 0}, /*2*/ + {5.0, 10.5, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0} /*3*/ };
static void test_widen(void)
Signed-off-by: Vincent Povirk vincent@codeweavers.com
Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/gdiplus/graphicspath.c | 6 +++--- dlls/gdiplus/tests/graphicspath.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index 0308c943f3..55545a449a 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -2104,7 +2104,7 @@ static void widen_open_figure(const GpPointF *points, int start, int end, int i; path_list_node_t *prev_point;
- if (end <= start) + if (end <= start || pen_width == 0.0) return;
prev_point = *last_point; @@ -2136,7 +2136,7 @@ static void widen_closed_figure(GpPath *path, int start, int end, int i; path_list_node_t *prev_point;
- if (end <= start) + if (end <= start || pen_width == 0.0) return;
/* left outline */ @@ -2190,7 +2190,7 @@ static void widen_dashed_figure(GpPath *path, int start, int end, int closed, int draw_start_cap=0; static const REAL dash_dot_dot[6] = { 3.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
- if (end <= start) + if (end <= start || pen_width == 0.0) return;
switch (pen->dash) diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index 2362872fa0..17e6a7cafb 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -1246,7 +1246,7 @@ static void test_widen(void)
status = GdipGetPointCount(path, &count); expect(Ok, status); - todo_wine expect(0, count); + expect(0, count);
/* pen width = 0 pixels, UnitWorld - result is a path 1 unit wide */ GdipDeletePen(pen); @@ -1389,7 +1389,7 @@ static path_test_t widenline_caparrowanchor_path[] = { };
static path_test_t widenline_capsquareanchor_thin_path[] = { - {6.414213, 8.585786, PathPointTypeStart, 4, 0}, /*0*/ + {6.414213, 8.585786, PathPointTypeStart, 0, 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*/ @@ -1477,7 +1477,7 @@ static void test_widen_cap(void) { LineCapArrowAnchor, 10.0, widenline_caparrowanchor_path, ARRAY_SIZE(widenline_caparrowanchor_path), FALSE, TRUE }, { LineCapSquareAnchor, 0.0, widenline_capsquareanchor_thin_path, - ARRAY_SIZE(widenline_capsquareanchor_thin_path), FALSE, TRUE }, + ARRAY_SIZE(widenline_capsquareanchor_thin_path) }, { LineCapSquareAnchor, 10.0, widenline_capsquareanchor_dashed_path, ARRAY_SIZE(widenline_capsquareanchor_dashed_path), TRUE }, };
Signed-off-by: Vincent Povirk vincent@codeweavers.com