Index: src/effects/gradients/SkGradientShader.cpp |
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp |
index 502d73383af2b3e7b5744cf8ad715f2132281c4f..c84e46a641f21ae16c41a29609db4546af096bd7 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 |
} |