Reland "Add maxDimension() to glyph"

This reverts commit d3516170ac4c4ebc3620b9fce8c36d5d13a4e189.

Reason for revert: This does not seem to affect gold

Original change's description:
> Revert "Add maxDimension() to glyph"
> 
> This reverts commit c19cf51df473417336690d619ed193925a19ad61.
> 
> Reason for revert: speculative: broke win7 layout tests
> 
> Original change's description:
> > Add maxDimension() to glyph
> > 
> > Expand the too large for atlas calculation. Considering making
> > a "small enough" function on glyph.
> > 
> > Change-Id: I113831f4182df0939110f651fb4a5921447124c1
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/206705
> > Commit-Queue: Herb Derby <herb@google.com>
> > Commit-Queue: Ben Wagner <bungeman@google.com>
> > Auto-Submit: Herb Derby <herb@google.com>
> > Reviewed-by: Ben Wagner <bungeman@google.com>
> 
> TBR=bungeman@google.com,herb@google.com
> 
> Change-Id: Ie11df8e314ccf801f1d223d56344640b49200633
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/206695
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Mike Reed <reed@google.com>

TBR=bungeman@google.com,herb@google.com,reed@google.com

Change-Id: I91af46df68c901394380a97678ba2366c52cc4bf
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/206902
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/src/core/SkGlyph.h b/src/core/SkGlyph.h
index 4e709b4..41368d2 100644
--- a/src/core/SkGlyph.h
+++ b/src/core/SkGlyph.h
@@ -158,6 +158,13 @@
         return fPathData != nullptr && fPathData->fHasPath ? &fPathData->fPath : nullptr;
     }
 
+    int maxDimension() const {
+        // width and height are only defined if a metrics call was made.
+        SkASSERT(fMaskFormat != MASK_FORMAT_UNKNOWN);
+
+        return std::max(fWidth, fHeight);
+    }
+
     // Returns the size allocated on the arena.
     size_t copyImageData(const SkGlyph& from, SkArenaAlloc* alloc);
 
diff --git a/src/core/SkGlyphRunPainter.cpp b/src/core/SkGlyphRunPainter.cpp
index e82c46e..6c8950e 100644
--- a/src/core/SkGlyphRunPainter.cpp
+++ b/src/core/SkGlyphRunPainter.cpp
@@ -71,10 +71,6 @@
     return {lookupX, lookupY};
 }
 
-bool SkStrikeCommon::GlyphTooBigForAtlas(const SkGlyph& glyph) {
-    return glyph.fWidth > kSkSideTooBigForAtlas || glyph.fHeight > kSkSideTooBigForAtlas;
-}
-
 // -- SkGlyphRunListPainter ------------------------------------------------------------------------
 SkGlyphRunListPainter::SkGlyphRunListPainter(const SkSurfaceProps& props,
                                              SkColorType colorType,
@@ -387,10 +383,10 @@
         ScopedBuffers _ = this->ensureBuffers(glyphRun);
 
         auto addFallback = [this, &maxFallbackDimension]
-                (SkGlyphID glyphID, int width, int height, SkPoint sourcePosition) {
-            SkScalar largestDimension = std::max(width, height);
-            maxFallbackDimension = std::max(maxFallbackDimension, largestDimension);
-            fARGBGlyphsIDs.push_back(glyphID);
+                (const SkGlyph& glyph, SkPoint sourcePosition) {
+            maxFallbackDimension = std::max(maxFallbackDimension,
+                                            SkIntToScalar(glyph.maxDimension()));
+            fARGBGlyphsIDs.push_back(glyph.getGlyphID());
             fARGBPositions.push_back(sourcePosition);
         };
 
@@ -439,13 +435,13 @@
                 if (glyph.isEmpty()) {
                     // do nothing
                 } else if (glyph.fMaskFormat == SkMask::kSDF_Format
-                           && !SkStrikeCommon::GlyphTooBigForAtlas(glyph)) {
+                           && glyph.maxDimension() <= SkStrikeCommon::kSkSideTooBigForAtlas) {
                     fGlyphPos[glyphCount++] = {&glyph, glyphSourcePosition};
                 } else if (glyph.fMaskFormat != SkMask::kARGB32_Format
                            && strike->decideCouldDrawFromPath(glyph)) {
                     fPaths.push_back({&glyph, glyphSourcePosition});
                 } else {
-                    addFallback(glyphID, glyph.fWidth, glyph.fHeight, glyphSourcePosition);
+                    addFallback(glyph, glyphSourcePosition);
                 }
             }
 
@@ -515,7 +511,7 @@
                            && strike->decideCouldDrawFromPath(glyph)) {
                     fGlyphPos[glyphCount++] = {&glyph, glyphSourcePosition};
                 } else {
-                    addFallback(glyphID, glyph.fWidth, glyph.fHeight, glyphSourcePosition);
+                    addFallback(glyph, glyphSourcePosition);
                 }
             }
 
@@ -564,13 +560,13 @@
                 const SkGlyph& glyph = strike->getGlyphMetrics(glyphID, glyphDevicePosition);
                 if (glyph.isEmpty()) {
                     // do nothing
-                } else if (!SkStrikeCommon::GlyphTooBigForAtlas(glyph)) {
+                } else if (glyph.maxDimension() <= SkStrikeCommon::kSkSideTooBigForAtlas) {
                     fGlyphPos[glyphsWithMaskCount++] = {&glyph, glyphDevicePosition};
                 } else if (glyph.fMaskFormat != SkMask::kARGB32_Format
                            && strike->decideCouldDrawFromPath(glyph)) {
                     fPaths.push_back({&glyph, glyphDevicePosition});
                 } else {
-                    addFallback(glyphID, glyph.fWidth, glyph.fHeight, glyphSourcePosition);
+                    addFallback(glyph, glyphSourcePosition);
                 }
             }
 
diff --git a/src/core/SkGlyphRunPainter.h b/src/core/SkGlyphRunPainter.h
index 1feff2b..409f40a 100644
--- a/src/core/SkGlyphRunPainter.h
+++ b/src/core/SkGlyphRunPainter.h
@@ -32,8 +32,6 @@
     // An atlas consists of plots, and plots hold glyphs. The minimum a plot can be is 256x256.
     // This means that the maximum size a glyph can be is 256x256.
     static constexpr uint16_t kSkSideTooBigForAtlas = 256;
-
-    static bool GlyphTooBigForAtlas(const SkGlyph& glyph);
 };
 
 class SkGlyphRunListPainter {