Index: src/effects/gradients/Sk4fLinearGradient.cpp |
diff --git a/src/effects/gradients/Sk4fLinearGradient.cpp b/src/effects/gradients/Sk4fLinearGradient.cpp |
index dc6e530a0c0896777c185b0ab2a1ff5c5be4cefb..cd1f770ef98306f20ac452b729e2950998b3eed1 100644 |
--- a/src/effects/gradients/Sk4fLinearGradient.cpp |
+++ b/src/effects/gradients/Sk4fLinearGradient.cpp |
@@ -100,12 +100,13 @@ SkScalar pinFx<SkShader::kMirror_TileMode>(SkScalar fx) { |
return f < 0 ? f + 2 : f; |
} |
-// true when x is in [k1,k2) |
+// true when x is in [k1,k2), or [k2, k1) when the interval is reversed. |
+// TODO(fmalita): hoist the reversed interval check out of this helper. |
bool in_range(SkScalar x, SkScalar k1, SkScalar k2) { |
SkASSERT(k1 != k2); |
return (k1 < k2) |
- ? (x >= k1 && x < k2) |
- : (x >= k2 && x < k1); |
+ ? (x >= k1 && x < k2) |
+ : (x > k2 && x <= k1); |
} |
} // anonymous namespace |
@@ -116,7 +117,7 @@ LinearGradient4fContext::LinearGradient4fContext(const SkLinearGradient& shader, |
: INHERITED(shader, rec) { |
// Our fast path expects interval points to be monotonically increasing in x. |
- const bool reverseIntervals = this->isFast() && fDstToPos.getScaleX() < 0; |
+ const bool reverseIntervals = this->isFast() && signbit(fDstToPos.getScaleX()); |
this->buildIntervals(shader, rec, reverseIntervals); |
SkASSERT(fIntervals.count() > 0); |
@@ -290,6 +291,7 @@ public: |
, fDx(dx) |
, fIsVertical(is_vertical) |
{ |
+ SkASSERT(fAdvX >= 0); |
SkASSERT(firstInterval <= lastInterval); |
SkASSERT(in_range(fx, i->fP0, i->fP1)); |
this->compute_interval_props(fx - i->fP0); |