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:
parent
03d46695fd
commit
96519f2835
@ -459,8 +459,7 @@ void GrTextContext::regenerateGlyphRunList(GrTextBlob* cacheBlob,
|
||||
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 @@ void GrTextContext::regenerateGlyphRunList(GrTextBlob* cacheBlob,
|
||||
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);
|
||||
|
@ -171,10 +171,6 @@ bool read_path(Deserializer* deserializer, SkGlyph* glyph, SkGlyphCache* cache)
|
||||
}
|
||||
|
||||
#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 @@ void SkTextBlobCacheDiffCanvas::TrackLayerDevice::processGlyphRunForPaths(
|
||||
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 @@ void SkTextBlobCacheDiffCanvas::TrackLayerDevice::processGlyphRunForPaths(
|
||||
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 @@ bool SkTextBlobCacheDiffCanvas::TrackLayerDevice::maybeProcessGlyphRunForDFT(
|
||||
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();
|
||||
|
@ -85,7 +85,6 @@ protected:
|
||||
allowMultitexturing);
|
||||
this->contextPriv().addOnFlushCallbackObject(fAtlasManager);
|
||||
|
||||
SkASSERT(glyphCache->getGlyphSizeLimit() == fAtlasManager->getGlyphSizeLimit());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,6 @@ GrAtlasManager::GrAtlasManager(GrProxyProvider* proxyProvider, GrGlyphCache* gly
|
||||
size_t maxTextureBytes,
|
||||
GrDrawOpAtlas::AllowMultitexturing allowMultitexturing)
|
||||
: fAllowMultitexturing{allowMultitexturing}
|
||||
, fGlyphSizeLimit{SkGlyphCacheCommon::kSkSideTooBigForAtlas}
|
||||
, fProxyProvider{proxyProvider}
|
||||
, fCaps{fProxyProvider->refCaps()}
|
||||
, fGlyphCache{glyphCache}
|
||||
|
@ -55,8 +55,6 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkScalar getGlyphSizeLimit() const { return fGlyphSizeLimit; }
|
||||
|
||||
void freeAll();
|
||||
|
||||
bool hasGlyph(GrGlyph* glyph);
|
||||
@ -146,7 +144,6 @@ private:
|
||||
|
||||
GrDrawOpAtlas::AllowMultitexturing fAllowMultitexturing;
|
||||
std::unique_ptr<GrDrawOpAtlas> fAtlases[kMaskFormatCount];
|
||||
SkScalar fGlyphSizeLimit;
|
||||
GrProxyProvider* fProxyProvider;
|
||||
sk_sp<const GrCaps> fCaps;
|
||||
GrGlyphCache* fGlyphCache;
|
||||
|
@ -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 @@ void GrGlyphCache::freeAll() {
|
||||
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);
|
||||
|
||||
|
@ -112,8 +112,6 @@ public:
|
||||
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 @@ public:
|
||||
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 @@ private:
|
||||
|
||||
StrikeHash fCache;
|
||||
GrTextStrike* fPreserveStrike;
|
||||
SkScalar fGlyphSizeLimit;
|
||||
std::unique_ptr<const SkMasks> f565Masks;
|
||||
};
|
||||
|
||||
|
@ -72,11 +72,9 @@ public:
|
||||
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 @@ public:
|
||||
|
||||
const SkMatrix& fViewMatrix;
|
||||
SkScalar fTextSize;
|
||||
SkScalar fMaxTextSize;
|
||||
SkScalar fMaxTextSize{SkGlyphCacheCommon::kSkSideTooBigForAtlas};
|
||||
SkScalar fTextRatio;
|
||||
SkScalar fTransformedFallbackTextSize;
|
||||
SkScalar fMaxScale;
|
||||
|
Loading…
Reference in New Issue
Block a user