add textblob cache freeall
BUG=skia:
Review URL: https://codereview.chromium.org/1088683004
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 8e611b0..be40479 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -193,6 +193,7 @@
fBatchFontCache->freeAll();
fFontCache->freeAll();
fLayerCache->freeAll();
+ fTextBlobCache->freeAll();
}
void GrContext::resetContext(uint32_t state) {
diff --git a/src/gpu/GrTextBlobCache.cpp b/src/gpu/GrTextBlobCache.cpp
index fe0ccf6..d32e24b 100644
--- a/src/gpu/GrTextBlobCache.cpp
+++ b/src/gpu/GrTextBlobCache.cpp
@@ -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 @@
#endif
return cacheBlob;
}
+
+void GrTextBlobCache::freeAll() {
+ SkTDynamicHash<BitmapTextBlob, BitmapTextBlob::Key>::Iter iter(&fCache);
+ while (!iter.done()) {
+ (&(*iter))->unref();
+ ++iter;
+ }
+ fCache.rewind();
+}
diff --git a/src/gpu/GrTextBlobCache.h b/src/gpu/GrTextBlobCache.h
index a110a03..1776c69 100644
--- a/src/gpu/GrTextBlobCache.h
+++ b/src/gpu/GrTextBlobCache.h
@@ -115,6 +115,8 @@
fBlobList.addToHead(blob);
}
+ void freeAll();
+
private:
// TODO move to SkTextBlob
void BlobGlyphCount(int* glyphCount, int* runCount, const SkTextBlob* blob) {