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

Unified Diff: src/gpu/GrTextStrike.cpp

Issue 24608002: First pass at font cache refactor: Create an atlas manager per texture (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Make sure to set the MaskFormat Created 7 years, 3 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/GrTypes.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 47b6216665ae0626e08e111c985ee29930be8f0b..5798e5f3505581dfcb75aad37e8570c534be12e3 100644
--- a/src/gpu/GrTextStrike.cpp
+++ b/src/gpu/GrTextStrike.cpp
@@ -23,14 +23,18 @@ static int g_PurgeCount = 0;
GrFontCache::GrFontCache(GrGpu* gpu) : fGpu(gpu) {
gpu->ref();
- fAtlasMgr = NULL;
+ for (int i = 0; i < kMaskFormatCount; ++i) {
+ fAtlasMgr[i] = NULL;
+ }
fHead = fTail = NULL;
}
GrFontCache::~GrFontCache() {
fCache.deleteAll();
- delete fAtlasMgr;
+ for (int i = 0; i < kMaskFormatCount; ++i) {
+ delete fAtlasMgr[i];
+ }
fGpu->unref();
#if FONT_CACHE_STATS
GrPrintf("Num purges: %d\n", g_PurgeCount);
@@ -39,12 +43,13 @@ GrFontCache::~GrFontCache() {
GrTextStrike* GrFontCache::generateStrike(GrFontScaler* scaler,
const Key& key) {
- if (NULL == fAtlasMgr) {
- fAtlasMgr = SkNEW_ARGS(GrAtlasMgr, (fGpu));
+ GrMaskFormat format = scaler->getMaskFormat();
+ if (NULL == fAtlasMgr[format]) {
+ fAtlasMgr[format] = SkNEW_ARGS(GrAtlasMgr, (fGpu, format));
}
GrTextStrike* strike = SkNEW_ARGS(GrTextStrike,
(this, scaler->getKey(),
- scaler->getMaskFormat(), fAtlasMgr));
+ scaler->getMaskFormat(), fAtlasMgr[format]));
fCache.insert(key, strike);
if (fHead) {
@@ -62,8 +67,10 @@ GrTextStrike* GrFontCache::generateStrike(GrFontScaler* scaler,
void GrFontCache::freeAll() {
fCache.deleteAll();
- delete fAtlasMgr;
- fAtlasMgr = NULL;
+ for (int i = 0; i < kMaskFormatCount; ++i) {
+ delete fAtlasMgr[i];
+ fAtlasMgr[i] = NULL;
+ }
fHead = NULL;
fTail = NULL;
}
@@ -249,7 +256,6 @@ bool GrTextStrike::getGlyphAtlas(GrGlyph* glyph, GrFontScaler* scaler,
GrAtlas* atlas = fAtlasMgr->addToAtlas(&fAtlas, glyph->width(),
glyph->height(), storage.get(),
- fMaskFormat,
&glyph->fAtlasLocation);
if (NULL == atlas) {
return false;
« include/gpu/GrTypes.h ('K') | « src/gpu/GrTextStrike.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698