Centralize the max glyph dimension

Over several refactorings the max glyph dimension has become
a constant. Simplify the code by removing variables that can
only be constant.

Change-Id: I65800a5ec1dfd4de5337f2f37348bd0eb101cc3e
Reviewed-on: https://skia-review.googlesource.com/154123
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/src/core/SkGlyphRunPainter.cpp b/src/core/SkGlyphRunPainter.cpp
index ee002e1..dc42aa6 100644
--- a/src/core/SkGlyphRunPainter.cpp
+++ b/src/core/SkGlyphRunPainter.cpp
@@ -459,8 +459,7 @@
             cacheBlob->setSubRunHasDistanceFields(runIndex, runPaint.isLCDRenderText(),
                                                   runPaint.isAntiAlias(), hasWCoord);
 
-            FallbackGlyphRunHelper fallbackTextHelper(
-                    viewMatrix, runPaint, glyphCache->getGlyphSizeLimit(), textRatio);
+            FallbackGlyphRunHelper fallbackTextHelper(viewMatrix, runPaint, textRatio);
 
             sk_sp<GrTextStrike> currStrike;
 
@@ -512,8 +511,7 @@
             SkPaint pathPaint(runPaint);
             SkScalar matrixScale = pathPaint.setupForAsPaths();
 
-            FallbackGlyphRunHelper fallbackTextHelper(
-                    viewMatrix, runPaint, glyphCache->getGlyphSizeLimit(), matrixScale);
+            FallbackGlyphRunHelper fallbackTextHelper(viewMatrix, runPaint, matrixScale);
 
             // Temporarily jam in kFill, so we only ever ask for the raw outline from the cache.
             pathPaint.setStyle(SkPaint::kFill_Style);
diff --git a/src/core/SkRemoteGlyphCache.cpp b/src/core/SkRemoteGlyphCache.cpp
index f85c103..07dbf17 100644
--- a/src/core/SkRemoteGlyphCache.cpp
+++ b/src/core/SkRemoteGlyphCache.cpp
@@ -171,10 +171,6 @@
 }
 
 #if SK_SUPPORT_GPU
-SkScalar glyph_size_limit(const SkTextBlobCacheDiffCanvas::Settings& settings) {
-    return GrGlyphCache::ComputeGlyphSizeLimit(settings.fMaxTextureSize, settings.fMaxTextureBytes);
-}
-
 void add_glyph_to_cache(SkStrikeServer::SkGlyphCacheState* cache, SkTypeface* tf,
                         const SkScalerContextEffects& effects, SkGlyphID glyphID) {
     SkASSERT(cache != nullptr);
@@ -306,9 +302,7 @@
     SkPaint pathPaint(runPaint);
 #if SK_SUPPORT_GPU
     SkScalar matrixScale = pathPaint.setupForAsPaths();
-    GrTextContext::FallbackGlyphRunHelper fallbackTextHelper(
-            runMatrix, runPaint, glyph_size_limit(fSettings), matrixScale);
-    const SkPoint emptyPosition{0, 0};
+    GrTextContext::FallbackGlyphRunHelper fallbackTextHelper(runMatrix, runPaint, matrixScale);
 #else
     pathPaint.setupForAsPaths();
 #endif
@@ -331,7 +325,7 @@
         if (SkMask::kARGB32_Format == glyph.fMaskFormat) {
             // Note that we send data for the original glyph even in the case of fallback
             // since its glyph metrics will still be used on the client.
-            fallbackTextHelper.appendGlyph(glyph, glyphID, emptyPosition);
+            fallbackTextHelper.appendGlyph(glyph, glyphID, {0, 0});
         }
 #endif
         glyphCacheState->addGlyph(glyphID, asPath);
@@ -369,8 +363,7 @@
     auto* glyphCacheState = fStrikeServer->getOrCreateCache(dfPaint, &this->surfaceProps(),
                                                             nullptr, flags, &effects);
 
-    GrTextContext::FallbackGlyphRunHelper fallbackTextHelper(
-            runMatrix, runPaint, glyph_size_limit(fSettings), textRatio);
+    GrTextContext::FallbackGlyphRunHelper fallbackTextHelper(runMatrix, runPaint, textRatio);
     const bool asPath = false;
     const SkPoint emptyPosition{0, 0};
     auto glyphs = glyphRun.shuntGlyphsIDs();
diff --git a/src/gpu/GrDirectContext.cpp b/src/gpu/GrDirectContext.cpp
index c87078b..14133cd 100644
--- a/src/gpu/GrDirectContext.cpp
+++ b/src/gpu/GrDirectContext.cpp
@@ -85,7 +85,6 @@
                                            allowMultitexturing);
         this->contextPriv().addOnFlushCallbackObject(fAtlasManager);
 
-        SkASSERT(glyphCache->getGlyphSizeLimit() == fAtlasManager->getGlyphSizeLimit());
         return true;
     }
 
diff --git a/src/gpu/text/GrAtlasManager.cpp b/src/gpu/text/GrAtlasManager.cpp
index c1b3d7b..143f84d 100644
--- a/src/gpu/text/GrAtlasManager.cpp
+++ b/src/gpu/text/GrAtlasManager.cpp
@@ -14,7 +14,6 @@
                                size_t maxTextureBytes,
                                GrDrawOpAtlas::AllowMultitexturing allowMultitexturing)
             : fAllowMultitexturing{allowMultitexturing}
-            , fGlyphSizeLimit{SkGlyphCacheCommon::kSkSideTooBigForAtlas}
             , fProxyProvider{proxyProvider}
             , fCaps{fProxyProvider->refCaps()}
             , fGlyphCache{glyphCache}
diff --git a/src/gpu/text/GrAtlasManager.h b/src/gpu/text/GrAtlasManager.h
index e857ae8..e709c24 100644
--- a/src/gpu/text/GrAtlasManager.h
+++ b/src/gpu/text/GrAtlasManager.h
@@ -55,8 +55,6 @@
         return nullptr;
     }
 
-    SkScalar getGlyphSizeLimit() const { return fGlyphSizeLimit; }
-
     void freeAll();
 
     bool hasGlyph(GrGlyph* glyph);
@@ -146,7 +144,6 @@
 
     GrDrawOpAtlas::AllowMultitexturing fAllowMultitexturing;
     std::unique_ptr<GrDrawOpAtlas> fAtlases[kMaskFormatCount];
-    SkScalar fGlyphSizeLimit;
     GrProxyProvider* fProxyProvider;
     sk_sp<const GrCaps> fCaps;
     GrGlyphCache* fGlyphCache;
diff --git a/src/gpu/text/GrGlyphCache.cpp b/src/gpu/text/GrGlyphCache.cpp
index 933a1c0..7fcd308 100644
--- a/src/gpu/text/GrGlyphCache.cpp
+++ b/src/gpu/text/GrGlyphCache.cpp
@@ -16,11 +16,8 @@
 
 GrGlyphCache::GrGlyphCache(const GrCaps* caps, size_t maxTextureBytes)
         : fPreserveStrike(nullptr)
-        , fGlyphSizeLimit(0)
         , f565Masks(SkMasks::CreateMasks({0xF800, 0x07E0, 0x001F, 0},
-                    GrMaskFormatBytesPerPixel(kA565_GrMaskFormat) * 8)) {
-    fGlyphSizeLimit = ComputeGlyphSizeLimit(caps->maxTextureSize(), maxTextureBytes);
-}
+                    GrMaskFormatBytesPerPixel(kA565_GrMaskFormat) * 8)) { }
 
 GrGlyphCache::~GrGlyphCache() {
     StrikeHash::Iter iter(&fCache);
@@ -41,10 +38,6 @@
     fCache.rewind();
 }
 
-SkScalar GrGlyphCache::ComputeGlyphSizeLimit(int maxTextureSize, size_t maxTextureBytes) {
-    return SkGlyphCacheCommon::kSkSideTooBigForAtlas;
-}
-
 void GrGlyphCache::HandleEviction(GrDrawOpAtlas::AtlasID id, void* ptr) {
     GrGlyphCache* glyphCache = reinterpret_cast<GrGlyphCache*>(ptr);
 
diff --git a/src/gpu/text/GrGlyphCache.h b/src/gpu/text/GrGlyphCache.h
index 8375d1f..c38ba78 100644
--- a/src/gpu/text/GrGlyphCache.h
+++ b/src/gpu/text/GrGlyphCache.h
@@ -112,8 +112,6 @@
     GrGlyphCache(const GrCaps* caps, size_t maxTextureBytes);
     ~GrGlyphCache();
 
-    SkScalar getGlyphSizeLimit() const { return fGlyphSizeLimit; }
-
     void setStrikeToPreserve(GrTextStrike* strike) { fPreserveStrike = strike; }
 
     // The user of the cache may hold a long-lived ref to the returned strike. However, actions by
@@ -133,7 +131,6 @@
     void freeAll();
 
     static void HandleEviction(GrDrawOpAtlas::AtlasID, void*);
-    static SkScalar ComputeGlyphSizeLimit(int maxTextureSize, size_t maxTextureBytes);
 
 private:
     sk_sp<GrTextStrike> generateStrike(const SkGlyphCache* cache) {
@@ -147,7 +144,6 @@
 
     StrikeHash fCache;
     GrTextStrike* fPreserveStrike;
-    SkScalar fGlyphSizeLimit;
     std::unique_ptr<const SkMasks> f565Masks;
 };
 
diff --git a/src/gpu/text/GrTextContext.h b/src/gpu/text/GrTextContext.h
index 8965398..b313d4d 100644
--- a/src/gpu/text/GrTextContext.h
+++ b/src/gpu/text/GrTextContext.h
@@ -72,11 +72,9 @@
     public:
         FallbackGlyphRunHelper(const SkMatrix& viewMatrix,
                            const SkPaint& pathPaint,
-                           SkScalar maxTextSize,
                            SkScalar textRatio)
                 : fViewMatrix(viewMatrix)
                 , fTextSize(pathPaint.getTextSize())
-                , fMaxTextSize(maxTextSize)
                 , fTextRatio(textRatio)
                 , fTransformedFallbackTextSize(fMaxTextSize)
                 , fUseTransformedFallback(false) {
@@ -98,7 +96,7 @@
 
         const SkMatrix& fViewMatrix;
         SkScalar fTextSize;
-        SkScalar fMaxTextSize;
+        SkScalar fMaxTextSize{SkGlyphCacheCommon::kSkSideTooBigForAtlas};
         SkScalar fTextRatio;
         SkScalar fTransformedFallbackTextSize;
         SkScalar fMaxScale;