aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/utils/SkPolyUtils.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/utils/SkPolyUtils.cpp b/src/utils/SkPolyUtils.cpp
index 0d1b71c76b..8a4bf49000 100644
--- a/src/utils/SkPolyUtils.cpp
+++ b/src/utils/SkPolyUtils.cpp
@@ -486,7 +486,13 @@ bool SkComputeRadialSteps(const SkVector& v1, const SkVector& v2, SkScalar r,
}
SkScalar theta = SkScalarATan2(rSin, rCos);
- int steps = SkScalarRoundToInt(SkScalarAbs(r*theta*kRecipPixelsPerArcSegment));
+ SkScalar floatSteps = SkScalarAbs(r*theta*kRecipPixelsPerArcSegment);
+ // limit the number of steps to at most max uint16_t (that's all we can index)
+ // knock one value off the top to account for rounding
+ if (floatSteps >= (1 << 16)-1) {
+ return false;
+ }
+ int steps = SkScalarRoundToInt(floatSteps);
SkScalar dTheta = steps > 0 ? theta / steps : 0;
*rotSin = SkScalarSinCos(dTheta, rotCos);