mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
gl_engine: fix dashing
Incorrect condition for drawing segments in cubics; missing checks. @Issue: https://github.com/thorvg/thorvg/issues/2729 @Issue: https://github.com/thorvg/thorvg/issues/3222
This commit is contained in:
parent
0e633bd009
commit
5b15db0c8e
1 changed files with 21 additions and 22 deletions
|
@ -2216,7 +2216,7 @@ void DashStroke::doStroke(const PathCommand *cmds, uint32_t cmd_count, const Poi
|
||||||
case PathCommand::MoveTo: {
|
case PathCommand::MoveTo: {
|
||||||
// reset the dash state
|
// reset the dash state
|
||||||
mCurrIdx = 0;
|
mCurrIdx = 0;
|
||||||
mCurrLen = 0.f;
|
mCurrLen = mDashPattern[0];
|
||||||
mCurOpGap = false;
|
mCurOpGap = false;
|
||||||
mPtStart = mPtCur = *pts;
|
mPtStart = mPtCur = *pts;
|
||||||
pts++;
|
pts++;
|
||||||
|
@ -2256,17 +2256,17 @@ void DashStroke::dashLineTo(const GlPoint &to)
|
||||||
detail::Line curr{mPtCur, to};
|
detail::Line curr{mPtCur, to};
|
||||||
|
|
||||||
while (len > mCurrLen) {
|
while (len > mCurrLen) {
|
||||||
len -= mCurrLen;
|
detail::Line right;
|
||||||
|
if (mCurrLen > 0.0f) {
|
||||||
detail::Line left, right;
|
detail::Line left;
|
||||||
|
detail::_lineSplitAt(curr, mCurrLen, &left, &right);
|
||||||
detail::_lineSplitAt(curr, mCurrLen, &left, &right);
|
len -= mCurrLen;
|
||||||
|
if (!mCurOpGap) {
|
||||||
|
this->moveTo(left.p1);
|
||||||
|
this->lineTo(left.p2);
|
||||||
|
}
|
||||||
|
} else right = curr;
|
||||||
mCurrIdx = (mCurrIdx + 1) % mDashCount;
|
mCurrIdx = (mCurrIdx + 1) % mDashCount;
|
||||||
if (!mCurOpGap) {
|
|
||||||
this->moveTo(left.p1);
|
|
||||||
this->lineTo(left.p2);
|
|
||||||
}
|
|
||||||
mCurrLen = mDashPattern[mCurrIdx];
|
mCurrLen = mDashPattern[mCurrIdx];
|
||||||
mCurOpGap = !mCurOpGap;
|
mCurOpGap = !mCurOpGap;
|
||||||
curr = right;
|
curr = right;
|
||||||
|
@ -2307,17 +2307,16 @@ void DashStroke::dashCubicTo(const GlPoint &cnt1, const GlPoint &cnt2, const GlP
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (len > mCurrLen) {
|
while (len > mCurrLen) {
|
||||||
len -= mCurrLen;
|
Bezier right;
|
||||||
|
if (mCurrLen > 0.0f) {
|
||||||
Bezier left, right;
|
Bezier left;
|
||||||
|
cur.split(mCurrLen, left, right);
|
||||||
cur.split(mCurrLen, left, right);
|
len -= mCurrLen;
|
||||||
|
if (!mCurOpGap) {
|
||||||
if (mCurrIdx == 0) {
|
this->moveTo(left.start);
|
||||||
this->moveTo(left.start);
|
this->cubicTo(left.ctrl1, left.ctrl2, left.end);
|
||||||
this->cubicTo(left.ctrl1, left.ctrl2, left.end);
|
}
|
||||||
}
|
} else right = cur;
|
||||||
|
|
||||||
mCurrIdx = (mCurrIdx + 1) % mDashCount;
|
mCurrIdx = (mCurrIdx + 1) % mDashCount;
|
||||||
mCurrLen = mDashPattern[mCurrIdx];
|
mCurrLen = mDashPattern[mCurrIdx];
|
||||||
mCurOpGap = !mCurOpGap;
|
mCurOpGap = !mCurOpGap;
|
||||||
|
|
Loading…
Add table
Reference in a new issue