sw_engine: Address a corner case in trim path handling

This update fixes an issue where duplicated overlapping curves/lines,
when introduced as a single line.
That case overlapping command operation is take account for
the trim path's path-building process.

We now skip such cases to ensure the trim path functions correctly.

issue: https://github.com/thorvg/thorvg/issues/1939
This commit is contained in:
Hermet Park 2024-01-29 12:04:50 +09:00
parent 07b11e0528
commit a88f7094c4

View file

@ -122,7 +122,9 @@ static void _dashLineTo(SwDashStroke& dash, const Point* to, const Matrix* trans
Line cur = {dash.ptCur, *to};
auto len = _lineLength(cur.pt1, cur.pt2);
if (len < dash.curLen) {
if (mathZero(len)) {
_outlineMoveTo(*dash.outline, &dash.ptCur, transform);
} else if (len < dash.curLen) {
dash.curLen -= len;
if (!dash.curOpGap) {
if (dash.move) {
@ -179,7 +181,9 @@ static void _dashCubicTo(SwDashStroke& dash, const Point* ctrl1, const Point* ct
Bezier cur = {dash.ptCur, *ctrl1, *ctrl2, *to};
auto len = bezLength(cur);
if (len < dash.curLen) {
if (mathZero(len)) {
_outlineMoveTo(*dash.outline, &dash.ptCur, transform);
} else if (len < dash.curLen) {
dash.curLen -= len;
if (!dash.curOpGap) {
if (dash.move) {