aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/effects/gradients/SkGradientShader.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 502d73383a..c84e46a641 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -161,10 +161,11 @@ SkGradientShaderBase::SkGradientShaderBase(const Descriptor& desc)
curr = SkScalarPin(desc.fPos[i], 0, 1);
}
*origPosPtr++ = curr;
-
+
recs->fPos = SkScalarToFixed(curr);
- if (curr > prev) {
- recs->fScale = (1 << 24) / SkScalarToFixed(curr - prev);
+ SkFixed diff = SkScalarToFixed(curr - prev);
+ if (diff > 0) {
+ recs->fScale = (1 << 24) / diff;
} else {
recs->fScale = 0; // ignore this segment
}