diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-10-20 13:18:37 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-10-20 13:18:37 +0000 |
commit | d40da64fcdecde1a2909cc42ca41eac6315bb162 (patch) | |
tree | 4327a3289828c195f0125aa0e2a752bce9d98de7 /src | |
parent | c961442926c40300c6d2397b07633f1e2d56fdd9 (diff) |
add typefacecache to be purged in SkGraphics::Term()
git-svn-id: http://skia.googlecode.com/svn/trunk@2504 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkGraphics.cpp | 2 | ||||
-rw-r--r-- | src/core/SkTypefaceCache.cpp | 9 | ||||
-rw-r--r-- | src/core/SkTypefaceCache.h | 8 |
3 files changed, 19 insertions, 0 deletions
diff --git a/src/core/SkGraphics.cpp b/src/core/SkGraphics.cpp index 8102aca8ee..2da0856d86 100644 --- a/src/core/SkGraphics.cpp +++ b/src/core/SkGraphics.cpp @@ -108,9 +108,11 @@ void SkGraphics::Init() { /////////////////////////////////////////////////////////////////////////////// #include "SkGlyphCache.h" +#include "SkTypefaceCache.h" void SkGraphics::Term() { SkGraphics::SetFontCacheUsed(0); + SkTypefaceCache::PurgeAll(); SkGlobals::Term(); } diff --git a/src/core/SkTypefaceCache.cpp b/src/core/SkTypefaceCache.cpp index fc013cd149..8d86005473 100644 --- a/src/core/SkTypefaceCache.cpp +++ b/src/core/SkTypefaceCache.cpp @@ -66,6 +66,11 @@ void SkTypefaceCache::purge(int numToPurge) { } } +void SkTypefaceCache::purgeAll() { + this->purge(fArray.count()); + fArray.reset(); +} + /////////////////////////////////////////////////////////////////////////////// SkTypefaceCache& SkTypefaceCache::Get() { @@ -95,6 +100,10 @@ SkTypeface* SkTypefaceCache::FindByProc(FindProc proc, void* ctx) { return Get().findByProc(proc, ctx); } +void SkTypefaceCache::PurgeAll() { + Get().purgeAll(); +} + /////////////////////////////////////////////////////////////////////////////// #ifdef SK_DEBUG diff --git a/src/core/SkTypefaceCache.h b/src/core/SkTypefaceCache.h index ce351e5fc4..b788d21e4a 100644 --- a/src/core/SkTypefaceCache.h +++ b/src/core/SkTypefaceCache.h @@ -53,6 +53,13 @@ public: static SkTypeface* FindByProc(FindProc proc, void* ctx); /** + * This will unref all of the typefaces in the cache. Normally this is + * handled automatically as needed. This function is exposed for clients + * that explicitly want to purge the entire cache (e.g. to look for leaks). + */ + static void PurgeAll(); + + /** * Debugging only: dumps the status of the typefaces in the cache */ static void Dump(); @@ -64,6 +71,7 @@ private: SkTypeface* findByID(SkFontID findID) const; SkTypeface* findByProc(FindProc proc, void* ctx) const; void purge(int count); + void purgeAll(); struct Rec { SkTypeface* fFace; |