gdiplus: Caps are added at the end of a path.

Signed-off-by: Jeff Smith <whydoubt@gmail.com>
Signed-off-by: Vincent Povirk <vincent@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jeff Smith 2020-03-05 23:15:49 -06:00 committed by Alexandre Julliard
parent 15e8adfcfc
commit 260fb550be
2 changed files with 50 additions and 37 deletions

View File

@ -1984,10 +1984,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, GpLineCap cap, GpCustomLineCap *custom, path_list_node_t **last_point)
{
REAL pen_width = max(pen->width, 2.0);
switch (cap)
{
default:
@ -2130,14 +2128,6 @@ static void widen_open_figure(const GpPointF *points, GpPen *pen, int start, int
prev_point->next->type = PathPointTypeStart;
(*last_point)->type |= PathPointTypeCloseSubpath;
if (start_cap & LineCapAnchorMask)
add_anchor(&points[start], &points[start+1],
pen, start_cap, start_custom, last_point);
if (end_cap & LineCapAnchorMask)
add_anchor(&points[end], &points[end-1],
pen, end_cap, end_custom, last_point);
}
static void widen_closed_figure(GpPath *path, GpPen *pen, int start, int end,
@ -2327,7 +2317,6 @@ GpStatus WINGDIPAPI GdipWidenPath(GpPath *path, GpPen *pen, GpMatrix *matrix,
GpStatus status;
path_list_node_t *points=NULL, *last_point=NULL;
int i, subpath_start=0, new_length;
BYTE type;
TRACE("(%p,%p,%p,%0.2f)\n", path, pen, matrix, flatness);
@ -2347,6 +2336,9 @@ GpStatus WINGDIPAPI GdipWidenPath(GpPath *path, GpPen *pen, GpMatrix *matrix,
if (status == Ok)
{
REAL anchor_pen_width = max(pen->width, 2.0);
BYTE *types = flat_path->pathdata.Types;
last_point = points;
if (pen->endcap > LineCapDiamondAnchor)
@ -2366,12 +2358,10 @@ GpStatus WINGDIPAPI GdipWidenPath(GpPath *path, GpPen *pen, GpMatrix *matrix,
for (i=0; i < flat_path->pathdata.Count; i++)
{
type = flat_path->pathdata.Types[i];
if ((type&PathPointTypePathTypeMask) == PathPointTypeStart)
if ((types[i]&PathPointTypePathTypeMask) == PathPointTypeStart)
subpath_start = i;
if ((type&PathPointTypeCloseSubpath) == PathPointTypeCloseSubpath)
if ((types[i]&PathPointTypeCloseSubpath) == PathPointTypeCloseSubpath)
{
if (pen->dash != DashStyleSolid)
widen_dashed_figure(flat_path, pen, subpath_start, i, 1, &last_point);
@ -2379,7 +2369,7 @@ GpStatus WINGDIPAPI GdipWidenPath(GpPath *path, GpPen *pen, GpMatrix *matrix,
widen_closed_figure(flat_path, pen, subpath_start, i, &last_point);
}
else if (i == flat_path->pathdata.Count-1 ||
(flat_path->pathdata.Types[i+1]&PathPointTypePathTypeMask) == PathPointTypeStart)
(types[i+1]&PathPointTypePathTypeMask) == PathPointTypeStart)
{
if (pen->dash != DashStyleSolid)
widen_dashed_figure(flat_path, pen, subpath_start, i, 0, &last_point);
@ -2388,6 +2378,29 @@ GpStatus WINGDIPAPI GdipWidenPath(GpPath *path, GpPen *pen, GpMatrix *matrix,
}
}
for (i=0; i < flat_path->pathdata.Count; i++)
{
if ((types[i]&PathPointTypeCloseSubpath) == PathPointTypeCloseSubpath)
continue;
if ((types[i]&PathPointTypePathTypeMask) == PathPointTypeStart)
subpath_start = i;
if (i == flat_path->pathdata.Count-1 ||
(types[i+1]&PathPointTypePathTypeMask) == PathPointTypeStart)
{
if (pen->startcap & LineCapAnchorMask)
add_anchor(&flat_path->pathdata.Points[subpath_start],
&flat_path->pathdata.Points[subpath_start+1],
anchor_pen_width, pen->startcap, pen->customstart, &last_point);
if (pen->endcap & LineCapAnchorMask)
add_anchor(&flat_path->pathdata.Points[i],
&flat_path->pathdata.Points[i-1],
anchor_pen_width, pen->endcap, pen->customend, &last_point);
}
}
new_length = path_list_count(points)-1;
if (!lengthen_path(path, new_length))

View File

@ -1380,14 +1380,14 @@ static path_test_t widenline_capsquareanchor_dashed_path[] = {
{35.0, 5.0, PathPointTypeLine, 0, 0}, /*1*/
{35.0, 15.0, PathPointTypeLine, 0, 0}, /*2*/
{5.0, 15.0, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0}, /*3*/
{45.0, 5.0, PathPointTypeStart, 0, 1}, /*4*/
{50.0, 5.0, PathPointTypeLine, 0, 1}, /*5*/
{50.0, 15.0, PathPointTypeLine, 0, 1}, /*6*/
{45.0, 15.0, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 1}, /*7*/
{12.071068, 2.928932, PathPointTypeStart, 0, 1}, /*8*/
{12.071068, 17.071066, PathPointTypeLine, 0, 1}, /*9*/
{-2.071068, 17.071066, PathPointTypeLine, 0, 1}, /*10*/
{-2.071068, 2.928932, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 1}, /*11*/
{45.0, 5.0, PathPointTypeStart, 0, 0}, /*4*/
{50.0, 5.0, PathPointTypeLine, 0, 0}, /*5*/
{50.0, 15.0, PathPointTypeLine, 0, 0}, /*6*/
{45.0, 15.0, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0}, /*7*/
{12.071068, 2.928932, PathPointTypeStart, 0, 0}, /*8*/
{12.071068, 17.071066, PathPointTypeLine, 0, 0}, /*9*/
{-2.071068, 17.071066, PathPointTypeLine, 0, 0}, /*10*/
{-2.071068, 2.928932, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0}, /*11*/
{42.928928, 17.071068, PathPointTypeStart, 0, 0}, /*12*/
{42.928928, 2.928932, PathPointTypeLine, 0, 0}, /*13*/
{57.071068, 2.928932, PathPointTypeLine, 0, 0}, /*14*/
@ -1399,18 +1399,18 @@ static path_test_t widenline_capsquareanchor_multifigure_path[] = {
{25.0, 5.0, PathPointTypeLine, 0, 0}, /*1*/
{25.0, 15.0, PathPointTypeLine, 0, 0}, /*2*/
{5.0, 15.0, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0}, /*3*/
{30.0, 5.0, PathPointTypeStart, 0, 1}, /*4*/
{50.0, 5.0, PathPointTypeLine, 0, 1}, /*5*/
{50.0, 15.0, PathPointTypeLine, 0, 1}, /*6*/
{30.0, 15.0, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 1}, /*7*/
{12.071068, 2.928932, PathPointTypeStart, 0, 1}, /*8*/
{12.071068, 17.071066, PathPointTypeLine, 0, 1}, /*9*/
{-2.071068, 17.071066, PathPointTypeLine, 0, 1}, /*10*/
{-2.071068, 2.928932, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 1}, /*11*/
{17.928930, 17.071068, PathPointTypeStart, 0, 1}, /*12*/
{17.928930, 2.928932, PathPointTypeLine, 0, 1}, /*13*/
{32.071068, 2.928932, PathPointTypeLine, 0, 1}, /*14*/
{32.071068, 17.071068, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 1}, /*15*/
{30.0, 5.0, PathPointTypeStart, 0, 0}, /*4*/
{50.0, 5.0, PathPointTypeLine, 0, 0}, /*5*/
{50.0, 15.0, PathPointTypeLine, 0, 0}, /*6*/
{30.0, 15.0, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0}, /*7*/
{12.071068, 2.928932, PathPointTypeStart, 0, 0}, /*8*/
{12.071068, 17.071066, PathPointTypeLine, 0, 0}, /*9*/
{-2.071068, 17.071066, PathPointTypeLine, 0, 0}, /*10*/
{-2.071068, 2.928932, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0}, /*11*/
{17.928930, 17.071068, PathPointTypeStart, 0, 0}, /*12*/
{17.928930, 2.928932, PathPointTypeLine, 0, 0}, /*13*/
{32.071068, 2.928932, PathPointTypeLine, 0, 0}, /*14*/
{32.071068, 17.071068, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0}, /*15*/
{37.071068, 2.928932, PathPointTypeStart, 0, 0}, /*16*/
{37.071068, 17.071066, PathPointTypeLine, 0, 0}, /*17*/
{22.928930, 17.071066, PathPointTypeLine, 0, 0}, /*18*/