add textblob cache freeall

BUG=skia:

Review URL: https://codereview.chromium.org/1088683004
This commit is contained in:
joshualitt 2015-04-16 11:24:04 -07:00 committed by Commit bot
parent 8dc7c3a839
commit 26ffc00bfa
3 changed files with 13 additions and 5 deletions

View File

@ -193,6 +193,7 @@ void GrContext::abandonContext() {
fBatchFontCache->freeAll();
fFontCache->freeAll();
fLayerCache->freeAll();
fTextBlobCache->freeAll();
}
void GrContext::resetContext(uint32_t state) {

View File

@ -10,11 +10,7 @@
static const int kVerticesPerGlyph = 4;
GrTextBlobCache::~GrTextBlobCache() {
SkTDynamicHash<BitmapTextBlob, BitmapTextBlob::Key>::Iter iter(&fCache);
while (!iter.done()) {
(&(*iter))->unref();
++iter;
}
this->freeAll();
}
GrAtlasTextContext::BitmapTextBlob* GrTextBlobCache::createBlob(int glyphCount, int runCount,
@ -48,3 +44,12 @@ GrAtlasTextContext::BitmapTextBlob* GrTextBlobCache::createBlob(int glyphCount,
#endif
return cacheBlob;
}
void GrTextBlobCache::freeAll() {
SkTDynamicHash<BitmapTextBlob, BitmapTextBlob::Key>::Iter iter(&fCache);
while (!iter.done()) {
(&(*iter))->unref();
++iter;
}
fCache.rewind();
}

View File

@ -115,6 +115,8 @@ public:
fBlobList.addToHead(blob);
}
void freeAll();
private:
// TODO move to SkTextBlob
void BlobGlyphCount(int* glyphCount, int* runCount, const SkTextBlob* blob) {