aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects
diff options
context:
space:
mode:
Diffstat (limited to 'src/effects')
-rw-r--r--src/effects/gradients/Sk4fGradientBase.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/effects/gradients/Sk4fGradientBase.cpp b/src/effects/gradients/Sk4fGradientBase.cpp
index 02b43fe08a..442916638b 100644
--- a/src/effects/gradients/Sk4fGradientBase.cpp
+++ b/src/effects/gradients/Sk4fGradientBase.cpp
@@ -207,8 +207,9 @@ GradientShaderBase4fContext::GradientShaderBase4fContext(const SkGradientShaderB
clamp_color, clamp_pos,
componentScale);
} else if (shader.fTileMode == SkShader::kMirror_TileMode) {
+ const int count = fIntervals.count();
// synthetic flipped intervals in [1 .. 2)
- for (int i = fIntervals.count() - 1; i >= 0; --i) {
+ for (int i = count - 1; i >= 0; --i) {
const Interval& interval = fIntervals[i];
const SkScalar p0 = interval.fP0;
const SkScalar p1 = interval.fP1;
@@ -216,6 +217,19 @@ GradientShaderBase4fContext::GradientShaderBase4fContext(const SkGradientShaderB
Sk4f c = Sk4f::Load(interval.fC0.fVec) + dc * Sk4f(p1 - p0);
fIntervals.emplace_back(c, dc * Sk4f(-1), 2 - p1, 2 - p0);
}
+
+ if (!dx_is_pos) {
+ // When dx is negative, our initial invervals are in (1..0] order.
+ // The loop above appends their flipped counterparts, pivoted in 2: (1..0](2..1]
+ // To achieve the expected monotonic interval order, we need to
+ // swap the two halves: (2..1](1..0]
+ // TODO: we can probably avoid this late swap with some additional logic during
+ // the initial interval buildup.
+ SkASSERT(fIntervals.count() == count * 2)
+ for (int i = 0; i < count; ++i) {
+ SkTSwap(fIntervals[i], fIntervals[count + i]);
+ }
+ }
}
SkASSERT(fIntervals.count() > 0);