Make sure ReflexHash grid count is reasonable

Bug: chromium:888233
Change-Id: I42bea81d8dc6eee3516ed585f8bb838ef20ce554
Reviewed-on: https://skia-review.googlesource.com/156368
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
diff --git a/src/utils/SkPolyUtils.cpp b/src/utils/SkPolyUtils.cpp
index 23e7394..1d8bec0 100644
--- a/src/utils/SkPolyUtils.cpp
+++ b/src/utils/SkPolyUtils.cpp
@@ -1440,7 +1440,8 @@
             : fBounds(bounds)
             , fNumVerts(0) {
         // We want vertexCount grid cells, roughly distributed to match the bounds ratio
-        fHCount = SkScalarRoundToInt(SkScalarSqrt(vertexCount*bounds.width()/bounds.height()));
+        SkScalar hCount = SkScalarSqrt(vertexCount*bounds.width()/bounds.height());
+        fHCount = SkTMax(SkTMin(SkScalarRoundToInt(hCount), vertexCount), 1);
         fVCount = vertexCount/fHCount;
         fGridConversion.set((fHCount - 0.001f)/bounds.width(), (fVCount - 0.001f)/bounds.height());
         fGrid.setCount(fHCount*fVCount);