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

Unified Diff: src/gpu/GrTextStrike.cpp

Issue 23120004: Change Atlas recycling to track current flush count and recycle if Atlas not used in current flush. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Disable font cache stats Created 7 years, 4 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
« include/gpu/GrContext.h ('K') | « src/gpu/GrTextStrike.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrTextStrike.cpp
diff --git a/src/gpu/GrTextStrike.cpp b/src/gpu/GrTextStrike.cpp
index 9373351f227ee0c0076af7016d64f3a772a5f9a3..570b0a9ac6aa7b72ea07fd62867d0cb93c1b266e 100644
--- a/src/gpu/GrTextStrike.cpp
+++ b/src/gpu/GrTextStrike.cpp
@@ -86,9 +86,6 @@ void GrFontCache::purgeExceptFor(GrTextStrike* preserveStrike) {
fCache.removeAt(index, strikeToPurge->fFontScalerKey->getHash());
this->detachStrikeFromList(strikeToPurge);
delete strikeToPurge;
- } else {
- // for the remaining strikes, we just mark them unused
- GrAtlas::MarkAllUnused(strikeToPurge->fAtlas);
}
}
#if FONT_CACHE_STATS
@@ -96,7 +93,7 @@ void GrFontCache::purgeExceptFor(GrTextStrike* preserveStrike) {
#endif
}
-void GrFontCache::freeAtlasExceptFor(GrTextStrike* preserveStrike) {
+void GrFontCache::freeAtlasExceptFor(GrTextStrike* preserveStrike, uint64_t currentFlushCount) {
GrTextStrike* strike = fTail;
while (strike) {
if (strike == preserveStrike) {
@@ -105,7 +102,7 @@ void GrFontCache::freeAtlasExceptFor(GrTextStrike* preserveStrike) {
}
GrTextStrike* strikeToPurge = strike;
strike = strikeToPurge->fPrev;
- if (strikeToPurge->removeUnusedAtlases()) {
+ if (strikeToPurge->removeUnusedAtlases(currentFlushCount)) {
if (NULL == strikeToPurge->fAtlas) {
int index = fCache.slowFindIndex(strikeToPurge);
GrAssert(index >= 0);
@@ -184,8 +181,10 @@ GrTextStrike::GrTextStrike(GrFontCache* cache, const GrKey* key,
// SkTDArray::visitAll() (see destructor & removeUnusedAtlases())
static void free_glyph(GrGlyph*& glyph) { glyph->free(); }
+static uint64_t gCurrentFlushCount = 0;
bsalomon 2013/08/13 21:18:28 wha? There can be multiple GrContexts
jvanverth1 2013/08/14 13:24:32 A bit of a hack to get around the fact that visitA
+
static void invalidate_glyph(GrGlyph*& glyph) {
- if (glyph->fAtlas && !glyph->fAtlas->used()) {
+ if (glyph->fAtlas && glyph->fAtlas->lastFlush() < gCurrentFlushCount) {
glyph->fAtlas = NULL;
}
}
@@ -214,14 +213,15 @@ GrGlyph* GrTextStrike::generateGlyph(GrGlyph::PackedID packed,
return glyph;
}
-bool GrTextStrike::removeUnusedAtlases() {
+bool GrTextStrike::removeUnusedAtlases(uint64_t currentFlushCount) {
+ gCurrentFlushCount = currentFlushCount;
fCache.getArray().visitAll(invalidate_glyph);
- return GrAtlas::RemoveUnusedAtlases(fAtlasMgr, &fAtlas);
+ return GrAtlas::RemoveUnusedAtlases(fAtlasMgr, &fAtlas, currentFlushCount);
return false;
}
-bool GrTextStrike::getGlyphAtlas(GrGlyph* glyph, GrFontScaler* scaler) {
+bool GrTextStrike::getGlyphAtlas(GrGlyph* glyph, GrFontScaler* scaler, uint64_t currentFlushCount) {
#if 0 // testing hack to force us to flush our cache often
static int gCounter;
if ((++gCounter % 10) == 0) return false;
@@ -231,7 +231,7 @@ bool GrTextStrike::getGlyphAtlas(GrGlyph* glyph, GrFontScaler* scaler) {
GrAssert(scaler);
GrAssert(fCache.contains(glyph));
if (glyph->fAtlas) {
- glyph->fAtlas->setUsed(true);
+ glyph->fAtlas->setLastFlush(currentFlushCount);
return true;
}
@@ -256,6 +256,6 @@ bool GrTextStrike::getGlyphAtlas(GrGlyph* glyph, GrFontScaler* scaler) {
}
glyph->fAtlas = atlas;
- atlas->setUsed(true);
+ atlas->setLastFlush(currentFlushCount);
return true;
}
« include/gpu/GrContext.h ('K') | « src/gpu/GrTextStrike.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698