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>
This commit is contained in:
Herb Derby 2018-09-12 17:15:26 -04:00 committed by Skia Commit-Bot
parent 03d46695fd
commit 96519f2835
8 changed files with 7 additions and 34 deletions

View File

@ -459,8 +459,7 @@ void GrTextContext::regenerateGlyphRunList(GrTextBlob* cacheBlob,
cacheBlob->setSubRunHasDistanceFields(runIndex, runPaint.isLCDRenderText(), cacheBlob->setSubRunHasDistanceFields(runIndex, runPaint.isLCDRenderText(),
runPaint.isAntiAlias(), hasWCoord); runPaint.isAntiAlias(), hasWCoord);
FallbackGlyphRunHelper fallbackTextHelper( FallbackGlyphRunHelper fallbackTextHelper(viewMatrix, runPaint, textRatio);
viewMatrix, runPaint, glyphCache->getGlyphSizeLimit(), textRatio);
sk_sp<GrTextStrike> currStrike; sk_sp<GrTextStrike> currStrike;
@ -512,8 +511,7 @@ void GrTextContext::regenerateGlyphRunList(GrTextBlob* cacheBlob,
SkPaint pathPaint(runPaint); SkPaint pathPaint(runPaint);
SkScalar matrixScale = pathPaint.setupForAsPaths(); SkScalar matrixScale = pathPaint.setupForAsPaths();
FallbackGlyphRunHelper fallbackTextHelper( FallbackGlyphRunHelper fallbackTextHelper(viewMatrix, runPaint, matrixScale);
viewMatrix, runPaint, glyphCache->getGlyphSizeLimit(), matrixScale);
// Temporarily jam in kFill, so we only ever ask for the raw outline from the cache. // Temporarily jam in kFill, so we only ever ask for the raw outline from the cache.
pathPaint.setStyle(SkPaint::kFill_Style); pathPaint.setStyle(SkPaint::kFill_Style);

View File

@ -171,10 +171,6 @@ bool read_path(Deserializer* deserializer, SkGlyph* glyph, SkGlyphCache* cache)
} }
#if SK_SUPPORT_GPU #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, void add_glyph_to_cache(SkStrikeServer::SkGlyphCacheState* cache, SkTypeface* tf,
const SkScalerContextEffects& effects, SkGlyphID glyphID) { const SkScalerContextEffects& effects, SkGlyphID glyphID) {
SkASSERT(cache != nullptr); SkASSERT(cache != nullptr);
@ -306,9 +302,7 @@ void SkTextBlobCacheDiffCanvas::TrackLayerDevice::processGlyphRunForPaths(
SkPaint pathPaint(runPaint); SkPaint pathPaint(runPaint);
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
SkScalar matrixScale = pathPaint.setupForAsPaths(); SkScalar matrixScale = pathPaint.setupForAsPaths();
GrTextContext::FallbackGlyphRunHelper fallbackTextHelper( GrTextContext::FallbackGlyphRunHelper fallbackTextHelper(runMatrix, runPaint, matrixScale);
runMatrix, runPaint, glyph_size_limit(fSettings), matrixScale);
const SkPoint emptyPosition{0, 0};
#else #else
pathPaint.setupForAsPaths(); pathPaint.setupForAsPaths();
#endif #endif
@ -331,7 +325,7 @@ void SkTextBlobCacheDiffCanvas::TrackLayerDevice::processGlyphRunForPaths(
if (SkMask::kARGB32_Format == glyph.fMaskFormat) { if (SkMask::kARGB32_Format == glyph.fMaskFormat) {
// Note that we send data for the original glyph even in the case of fallback // 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. // since its glyph metrics will still be used on the client.
fallbackTextHelper.appendGlyph(glyph, glyphID, emptyPosition); fallbackTextHelper.appendGlyph(glyph, glyphID, {0, 0});
} }
#endif #endif
glyphCacheState->addGlyph(glyphID, asPath); glyphCacheState->addGlyph(glyphID, asPath);
@ -369,8 +363,7 @@ bool SkTextBlobCacheDiffCanvas::TrackLayerDevice::maybeProcessGlyphRunForDFT(
auto* glyphCacheState = fStrikeServer->getOrCreateCache(dfPaint, &this->surfaceProps(), auto* glyphCacheState = fStrikeServer->getOrCreateCache(dfPaint, &this->surfaceProps(),
nullptr, flags, &effects); nullptr, flags, &effects);
GrTextContext::FallbackGlyphRunHelper fallbackTextHelper( GrTextContext::FallbackGlyphRunHelper fallbackTextHelper(runMatrix, runPaint, textRatio);
runMatrix, runPaint, glyph_size_limit(fSettings), textRatio);
const bool asPath = false; const bool asPath = false;
const SkPoint emptyPosition{0, 0}; const SkPoint emptyPosition{0, 0};
auto glyphs = glyphRun.shuntGlyphsIDs(); auto glyphs = glyphRun.shuntGlyphsIDs();

View File

@ -85,7 +85,6 @@ protected:
allowMultitexturing); allowMultitexturing);
this->contextPriv().addOnFlushCallbackObject(fAtlasManager); this->contextPriv().addOnFlushCallbackObject(fAtlasManager);
SkASSERT(glyphCache->getGlyphSizeLimit() == fAtlasManager->getGlyphSizeLimit());
return true; return true;
} }

View File

@ -14,7 +14,6 @@ GrAtlasManager::GrAtlasManager(GrProxyProvider* proxyProvider, GrGlyphCache* gly
size_t maxTextureBytes, size_t maxTextureBytes,
GrDrawOpAtlas::AllowMultitexturing allowMultitexturing) GrDrawOpAtlas::AllowMultitexturing allowMultitexturing)
: fAllowMultitexturing{allowMultitexturing} : fAllowMultitexturing{allowMultitexturing}
, fGlyphSizeLimit{SkGlyphCacheCommon::kSkSideTooBigForAtlas}
, fProxyProvider{proxyProvider} , fProxyProvider{proxyProvider}
, fCaps{fProxyProvider->refCaps()} , fCaps{fProxyProvider->refCaps()}
, fGlyphCache{glyphCache} , fGlyphCache{glyphCache}

View File

@ -55,8 +55,6 @@ public:
return nullptr; return nullptr;
} }
SkScalar getGlyphSizeLimit() const { return fGlyphSizeLimit; }
void freeAll(); void freeAll();
bool hasGlyph(GrGlyph* glyph); bool hasGlyph(GrGlyph* glyph);
@ -146,7 +144,6 @@ private:
GrDrawOpAtlas::AllowMultitexturing fAllowMultitexturing; GrDrawOpAtlas::AllowMultitexturing fAllowMultitexturing;
std::unique_ptr<GrDrawOpAtlas> fAtlases[kMaskFormatCount]; std::unique_ptr<GrDrawOpAtlas> fAtlases[kMaskFormatCount];
SkScalar fGlyphSizeLimit;
GrProxyProvider* fProxyProvider; GrProxyProvider* fProxyProvider;
sk_sp<const GrCaps> fCaps; sk_sp<const GrCaps> fCaps;
GrGlyphCache* fGlyphCache; GrGlyphCache* fGlyphCache;

View File

@ -16,11 +16,8 @@
GrGlyphCache::GrGlyphCache(const GrCaps* caps, size_t maxTextureBytes) GrGlyphCache::GrGlyphCache(const GrCaps* caps, size_t maxTextureBytes)
: fPreserveStrike(nullptr) : fPreserveStrike(nullptr)
, fGlyphSizeLimit(0)
, f565Masks(SkMasks::CreateMasks({0xF800, 0x07E0, 0x001F, 0}, , f565Masks(SkMasks::CreateMasks({0xF800, 0x07E0, 0x001F, 0},
GrMaskFormatBytesPerPixel(kA565_GrMaskFormat) * 8)) { GrMaskFormatBytesPerPixel(kA565_GrMaskFormat) * 8)) { }
fGlyphSizeLimit = ComputeGlyphSizeLimit(caps->maxTextureSize(), maxTextureBytes);
}
GrGlyphCache::~GrGlyphCache() { GrGlyphCache::~GrGlyphCache() {
StrikeHash::Iter iter(&fCache); StrikeHash::Iter iter(&fCache);
@ -41,10 +38,6 @@ void GrGlyphCache::freeAll() {
fCache.rewind(); fCache.rewind();
} }
SkScalar GrGlyphCache::ComputeGlyphSizeLimit(int maxTextureSize, size_t maxTextureBytes) {
return SkGlyphCacheCommon::kSkSideTooBigForAtlas;
}
void GrGlyphCache::HandleEviction(GrDrawOpAtlas::AtlasID id, void* ptr) { void GrGlyphCache::HandleEviction(GrDrawOpAtlas::AtlasID id, void* ptr) {
GrGlyphCache* glyphCache = reinterpret_cast<GrGlyphCache*>(ptr); GrGlyphCache* glyphCache = reinterpret_cast<GrGlyphCache*>(ptr);

View File

@ -112,8 +112,6 @@ public:
GrGlyphCache(const GrCaps* caps, size_t maxTextureBytes); GrGlyphCache(const GrCaps* caps, size_t maxTextureBytes);
~GrGlyphCache(); ~GrGlyphCache();
SkScalar getGlyphSizeLimit() const { return fGlyphSizeLimit; }
void setStrikeToPreserve(GrTextStrike* strike) { fPreserveStrike = strike; } void setStrikeToPreserve(GrTextStrike* strike) { fPreserveStrike = strike; }
// The user of the cache may hold a long-lived ref to the returned strike. However, actions by // The user of the cache may hold a long-lived ref to the returned strike. However, actions by
@ -133,7 +131,6 @@ public:
void freeAll(); void freeAll();
static void HandleEviction(GrDrawOpAtlas::AtlasID, void*); static void HandleEviction(GrDrawOpAtlas::AtlasID, void*);
static SkScalar ComputeGlyphSizeLimit(int maxTextureSize, size_t maxTextureBytes);
private: private:
sk_sp<GrTextStrike> generateStrike(const SkGlyphCache* cache) { sk_sp<GrTextStrike> generateStrike(const SkGlyphCache* cache) {
@ -147,7 +144,6 @@ private:
StrikeHash fCache; StrikeHash fCache;
GrTextStrike* fPreserveStrike; GrTextStrike* fPreserveStrike;
SkScalar fGlyphSizeLimit;
std::unique_ptr<const SkMasks> f565Masks; std::unique_ptr<const SkMasks> f565Masks;
}; };

View File

@ -72,11 +72,9 @@ public:
public: public:
FallbackGlyphRunHelper(const SkMatrix& viewMatrix, FallbackGlyphRunHelper(const SkMatrix& viewMatrix,
const SkPaint& pathPaint, const SkPaint& pathPaint,
SkScalar maxTextSize,
SkScalar textRatio) SkScalar textRatio)
: fViewMatrix(viewMatrix) : fViewMatrix(viewMatrix)
, fTextSize(pathPaint.getTextSize()) , fTextSize(pathPaint.getTextSize())
, fMaxTextSize(maxTextSize)
, fTextRatio(textRatio) , fTextRatio(textRatio)
, fTransformedFallbackTextSize(fMaxTextSize) , fTransformedFallbackTextSize(fMaxTextSize)
, fUseTransformedFallback(false) { , fUseTransformedFallback(false) {
@ -98,7 +96,7 @@ public:
const SkMatrix& fViewMatrix; const SkMatrix& fViewMatrix;
SkScalar fTextSize; SkScalar fTextSize;
SkScalar fMaxTextSize; SkScalar fMaxTextSize{SkGlyphCacheCommon::kSkSideTooBigForAtlas};
SkScalar fTextRatio; SkScalar fTextRatio;
SkScalar fTransformedFallbackTextSize; SkScalar fTransformedFallbackTextSize;
SkScalar fMaxScale; SkScalar fMaxScale;