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>
This commit is contained in:
Jim Van Verth 2018-09-24 12:24:15 -04:00 committed by Skia Commit-Bot
parent dcc85fc610
commit ac9f090976

View File

@ -1440,7 +1440,8 @@ public:
: 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);