renderer: fix trimmed stroke blinking

Bug introduced as part of a7e7bbc.
After recalculating begin and end to the 0-1 range, an extra
check was added to handle cases when begin is very close to end.
However, this was a bad approach since, even for very close values,
their relationship remains important. What should have been
done in the mentioned commit is properly handling  the case
begin == end, which was incorrectly treated as trimming from begin
to end. Instead, it should be handled as trimming from begin to
1.0 and from 0.0 to end.

@Issue: https://github.com/thorvg/thorvg/issues/3204
This commit is contained in:
Mira Grudzinska 2025-02-11 18:00:14 +01:00 committed by Hermet Park
parent cc4c18d6c6
commit 3ed357e17a

View file

@ -240,10 +240,7 @@ static void _trim(const PathCommand* inCmds, uint32_t inCmdsCnt, const Point* in
auto trimStart = begin * totalLength; auto trimStart = begin * totalLength;
auto trimEnd = end * totalLength; auto trimEnd = end * totalLength;
if (fabsf(begin - end) < EPSILON) { if (begin >= end) {
_trimPath(inCmds, inCmdsCnt, inPts, inPtsCnt, trimStart, totalLength, out);
_trimPath(inCmds, inCmdsCnt, inPts, inPtsCnt, 0.0f, trimStart, out, connect);
} else if (begin > end) {
_trimPath(inCmds, inCmdsCnt, inPts, inPtsCnt, trimStart, totalLength, out); _trimPath(inCmds, inCmdsCnt, inPts, inPtsCnt, trimStart, totalLength, out);
_trimPath(inCmds, inCmdsCnt, inPts, inPtsCnt, 0.0f, trimEnd, out, connect); _trimPath(inCmds, inCmdsCnt, inPts, inPtsCnt, 0.0f, trimEnd, out, connect);
} else { } else {