Index: src/core/SkGeometry.cpp |
diff --git a/src/core/SkGeometry.cpp b/src/core/SkGeometry.cpp |
index 7256b9e517ec5e401c6e6838dbc6245392b99f85..5d181a3a20ae045598765a7b64be4c7340408781 100644 |
--- a/src/core/SkGeometry.cpp |
+++ b/src/core/SkGeometry.cpp |
@@ -743,7 +743,8 @@ static int solve_cubic_poly(const SkScalar coeff[4], SkScalar tValues[3]) { |
SkScalar r; |
if (R2MinusQ3 < 0) { // we have 3 real roots |
- SkScalar theta = SkScalarACos(R / SkScalarSqrt(Q3)); |
+ // the divide/root can, due to finite precisions, be slightly outside of -1...1 |
+ SkScalar theta = SkScalarACos(SkScalarPin(R / SkScalarSqrt(Q3), -1, 1)); |
SkScalar neg2RootQ = -2 * SkScalarSqrt(Q); |
r = neg2RootQ * SkScalarCos(theta/3) - adiv3; |