From a88f7094c44795279085271d70206c4c3cb9a4d8 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 29 Jan 2024 12:04:50 +0900 Subject: [PATCH] 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 --- src/renderer/sw_engine/tvgSwShape.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/renderer/sw_engine/tvgSwShape.cpp b/src/renderer/sw_engine/tvgSwShape.cpp index 45322c07..d3b715ea 100644 --- a/src/renderer/sw_engine/tvgSwShape.cpp +++ b/src/renderer/sw_engine/tvgSwShape.cpp @@ -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) {