Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Unified Diff: src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp

Issue 1983353003: Attempt to improve lifetime management of SkGlyphCache in Ganesh atlas text code. (Closed) Base URL: https://skia.googlesource.com/skia.git@fixtest
Patch Set: Updated to only compare descriptors Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/text/GrAtlasTextBlob.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
diff --git a/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp b/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
index e5a8956517cad675758ae5cec291c23608b5bfdf..28d32198ded9da74215a46c24bb2ccfc6721d46e 100644
--- a/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
+++ b/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
@@ -142,35 +142,27 @@ void GrAtlasTextBlob::regenInBatch(GrDrawBatch::Target* target,
GrBatchFontCache* fontCache,
GrBlobRegenHelper *helper,
Run* run,
- Run::SubRunInfo* info, SkGlyphCache** cache,
- SkTypeface** typeface,
- const SkDescriptor** desc,
+ Run::SubRunInfo* info,
+ SkAutoGlyphCache* lazyCache,
int glyphCount, size_t vertexStride,
GrColor color, SkScalar transX,
SkScalar transY) const {
+ SkASSERT(lazyCache);
static_assert(!regenGlyphs || regenTexCoords, "must regenTexCoords along regenGlyphs");
GrBatchTextStrike* strike = nullptr;
if (regenTexCoords) {
info->resetBulkUseToken();
- // We can reuse if we have a valid strike and our descriptors / typeface are the
- // same. The override descriptor is only for the non distance field text within
- // a run
- const SkDescriptor* newDesc = (run->fOverrideDescriptor && !info->drawAsDistanceFields()) ?
- run->fOverrideDescriptor->getDesc() :
- run->fDescriptor.getDesc();
- if (!*cache || !SkTypeface::Equal(*typeface, run->fTypeface) ||
- !(**desc == *newDesc)) {
- if (*cache) {
- SkGlyphCache::AttachCache(*cache);
- }
- *desc = newDesc;
- *cache = SkGlyphCache::DetachCache(run->fTypeface, run->fEffects, *desc);
- *typeface = run->fTypeface;
+ const SkDescriptor* desc = (run->fOverrideDescriptor && !info->drawAsDistanceFields())
+ ? run->fOverrideDescriptor->getDesc()
+ : run->fDescriptor.getDesc();
+
+ if (!*lazyCache || (*lazyCache)->getDescriptor() != *desc) {
+ lazyCache->reset(SkGlyphCache::DetachCache(run->fTypeface, run->fEffects, desc));
}
if (regenGlyphs) {
- strike = fontCache->getStrike(*cache);
+ strike = fontCache->getStrike(lazyCache->get());
} else {
strike = info->strike();
}
@@ -187,20 +179,20 @@ void GrAtlasTextBlob::regenInBatch(GrDrawBatch::Target* target,
// Get the id from the old glyph, and use the new strike to lookup
// the glyph.
GrGlyph::PackedID id = fGlyphs[glyphOffset]->fPackedID;
- fGlyphs[glyphOffset] = strike->getGlyph(id, info->maskFormat(), *cache);
+ fGlyphs[glyphOffset] = strike->getGlyph(id, info->maskFormat(), lazyCache->get());
SkASSERT(id == fGlyphs[glyphOffset]->fPackedID);
}
glyph = fGlyphs[glyphOffset];
SkASSERT(glyph && glyph->fMaskFormat == info->maskFormat());
if (!fontCache->hasGlyph(glyph) &&
- !strike->addGlyphToAtlas(target, glyph, *cache, info->maskFormat())) {
+ !strike->addGlyphToAtlas(target, glyph, lazyCache->get(), info->maskFormat())) {
helper->flush();
brokenRun = glyphIdx > 0;
SkDEBUGCODE(bool success =) strike->addGlyphToAtlas(target,
glyph,
- *cache,
+ lazyCache->get(),
info->maskFormat());
SkASSERT(success);
}
@@ -238,7 +230,7 @@ enum RegenMask {
kRegenGlyph = 0x8 | kRegenTex, // we have to regenerate the texture coords when we regen glyphs
// combinations
- kRegenPosCol = kRegenPos | kRegenCol,
+ kRegenPosCol = kRegenPos | kRegenCol,
kRegenPosTex = kRegenPos | kRegenTex,
kRegenPosTexGlyph = kRegenPos | kRegenGlyph,
kRegenPosColTex = kRegenPos | kRegenCol | kRegenTex,
@@ -247,14 +239,13 @@ enum RegenMask {
kRegenColTexGlyph = kRegenCol | kRegenGlyph,
};
-#define REGEN_ARGS target, fontCache, helper, &run, &info, cache, typeface, desc, \
+#define REGEN_ARGS target, fontCache, helper, &run, &info, lazyCache, \
*glyphCount, vertexStride, color, transX, transY
void GrAtlasTextBlob::regenInBatch(GrDrawBatch::Target* target,
GrBatchFontCache* fontCache,
GrBlobRegenHelper *helper,
- int runIndex, int subRunIndex, SkGlyphCache** cache,
- SkTypeface** typeface, const SkDescriptor** desc,
+ int runIndex, int subRunIndex, SkAutoGlyphCache* lazyCache,
size_t vertexStride, const SkMatrix& viewMatrix,
SkScalar x, SkScalar y, GrColor color,
void** vertices, size_t* byteCount, int* glyphCount) {
« no previous file with comments | « src/gpu/text/GrAtlasTextBlob.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698