Don't try to add large glyphs to the font atlas.
When the glyph data is invalid we can try to allocate a ridiculous amount of memory. This adds a check to cover such cases.
BUG=414581
R=egdaniel@google.com
Author: jvanverth@google.com
Review URL: https://codereview.chromium.org/585853003
diff --git a/src/gpu/GrTextStrike.cpp b/src/gpu/GrTextStrike.cpp
index 24fa707..fa97f73 100644
--- a/src/gpu/GrTextStrike.cpp
+++ b/src/gpu/GrTextStrike.cpp
@@ -289,6 +289,19 @@
GrAtlas::RemovePlot(&fPlotUsage, plot);
}
+bool GrTextStrike::glyphTooLargeForAtlas(GrGlyph* glyph) {
+ int width = glyph->fBounds.width();
+ int height = glyph->fBounds.height();
+ int pad = fUseDistanceField ? 2 * SK_DistanceFieldPad : 0;
+ if (width + pad > GR_PLOT_WIDTH) {
+ return true;
+ }
+ if (height + pad > GR_PLOT_HEIGHT) {
+ return true;
+ }
+
+ return false;
+}
bool GrTextStrike::addGlyphToAtlas(GrGlyph* glyph, GrFontScaler* scaler) {
#if 0 // testing hack to force us to flush our cache often