More checks in ReflexHash setup
Bug: skia:8500
Change-Id: Ic9e485072202534ae2aa702daa4cffe4b7400d03
Reviewed-on: https://skia-review.googlesource.com/c/166805
Auto-Submit: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
diff --git a/src/utils/SkPolyUtils.cpp b/src/utils/SkPolyUtils.cpp
index aabd6d4..a37814a 100644
--- a/src/utils/SkPolyUtils.cpp
+++ b/src/utils/SkPolyUtils.cpp
@@ -1442,17 +1442,21 @@
bool init(const SkRect& bounds, int vertexCount) {
fBounds = bounds;
fNumVerts = 0;
+ SkScalar width = bounds.width();
+ SkScalar height = bounds.height();
+ if (!SkScalarIsFinite(width) || !SkScalarIsFinite(height)) {
+ return false;
+ }
// We want vertexCount grid cells, roughly distributed to match the bounds ratio
- SkScalar hCount = SkScalarSqrt(sk_ieee_float_divide(vertexCount*bounds.width(),
- bounds.height()));
+ SkScalar hCount = SkScalarSqrt(sk_ieee_float_divide(vertexCount*width, height));
if (!SkScalarIsFinite(hCount)) {
return false;
}
fHCount = SkTMax(SkTMin(SkScalarRoundToInt(hCount), vertexCount), 1);
fVCount = vertexCount/fHCount;
- fGridConversion.set(sk_ieee_float_divide(fHCount - 0.001f, bounds.width()),
- sk_ieee_float_divide(fVCount - 0.001f, bounds.height()));
+ fGridConversion.set(sk_ieee_float_divide(fHCount - 0.001f, width),
+ sk_ieee_float_divide(fVCount - 0.001f, height));
if (!fGridConversion.isFinite()) {
return false;
}