gl/wg_engine: fix differences in dashing among engines

The differences resulted from discrepancies between
the engines in applying equality or inequality signs
and in using different precision levels when determining
the dash remainder when transitioning to a new path
command.

@Issue: https://github.com/thorvg/thorvg/issues/3265
This commit is contained in:
Mira Grudzinska 2025-02-24 23:23:16 +01:00 committed by Hermet Park
parent 64ed756c2c
commit 7275b77c22
2 changed files with 3 additions and 3 deletions

View file

@ -2056,7 +2056,7 @@ void DashStroke::dashLineTo(const Point& to)
this->lineTo(curr.pt2);
}
if (mCurrLen < 1) {
if (mCurrLen < 0.1f) {
mCurrIdx = (mCurrIdx + 1) % mDashCount;
mCurrLen = mDashPattern[mCurrIdx];
mCurOpGap = !mCurOpGap;
@ -2108,7 +2108,7 @@ void DashStroke::dashCubicTo(const Point& cnt1, const Point& cnt2, const Point&
this->cubicTo(cur.ctrl1, cur.ctrl2, cur.end);
}
if (mCurrLen < 1) {
if (mCurrLen < 0.1f) {
mCurrIdx = (mCurrIdx + 1) % mDashCount;
mCurrLen = mDashPattern[mCurrIdx];
mCurOpGap = !mCurOpGap;

View file

@ -377,7 +377,7 @@ struct WgIndexedVertexBuffer
while(dashOffset > dashes_lenth) dashOffset -= dashes_lenth;
auto gap = false;
// scip dashes by offset
while(len_total < dashOffset) {
while(len_total <= dashOffset) {
index_dash = (index_dash + 1) % dashCnt;
len_total += dashPattern[index_dash];
gap = !gap;