diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-11-08 20:03:48 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-11-08 20:03:48 +0000 |
commit | 073c90769e4cc7bf14323c1cab59339463604ecd (patch) | |
tree | 158e249b9ca5506617c6059fc04ad1b9ba5ea768 | |
parent | fe701129857924f76a0d752d4c964b3c5e4b49fe (diff) |
use new PurgeFontCache() api
git-svn-id: http://skia.googlecode.com/svn/trunk@2633 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | bench/FontScalerBench.cpp | 3 | ||||
-rw-r--r-- | include/core/SkGraphics.h | 21 | ||||
-rw-r--r-- | samplecode/SampleApp.cpp | 3 | ||||
-rw-r--r-- | src/core/SkGraphics.cpp | 20 |
4 files changed, 18 insertions, 29 deletions
diff --git a/bench/FontScalerBench.cpp b/bench/FontScalerBench.cpp index 4255f67bad..4ac6a35e08 100644 --- a/bench/FontScalerBench.cpp +++ b/bench/FontScalerBench.cpp @@ -37,7 +37,8 @@ protected: // this is critical - we want to time the creation process, so we // explicitly flush our cache before each run - SkGraphics::SetFontCacheUsed(0); + SkGraphics::PurgeFontCache(); + for (int ps = 9; ps <= 24; ps += 2) { paint.setTextSize(SkIntToScalar(ps)); canvas->drawText(fText.c_str(), fText.size(), diff --git a/include/core/SkGraphics.h b/include/core/SkGraphics.h index d6af865931..17a26116f9 100644 --- a/include/core/SkGraphics.h +++ b/include/core/SkGraphics.h @@ -23,20 +23,6 @@ public: */ static void GetVersion(int32_t* major, int32_t* minor, int32_t* patch); - // Font Cache routines - - /** - * Return the (approximate) number of bytes used by the font cache. - */ - static size_t GetFontCacheUsed(); - - /** - * Attempt to purge the font cache until <= the specified amount remains - * in the cache. Specifying 0 will attempt to purge the entire cache. - * Returns true if some amount was purged from the font cache. - */ - static bool SetFontCacheUsed(size_t usageInBytes); - /** * Return the max number of bytes that should be used by the font cache. * If the cache needs to allocate more, it will purge previous entries. @@ -53,6 +39,13 @@ public: */ static size_t SetFontCacheLimit(size_t bytes); + /** + * For debugging purposes, this will attempt to purge the font cache. It + * does not change the limit, but will cause subsequent font measures and + * draws to be recreated, since they will no longer be in the cache. + */ + static void PurgeFontCache(); + private: /** This is automatically called by SkGraphics::Init(), and must be implemented by the host OS. This allows the host OS to register a callback diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index 17778fb540..7284cac624 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -1434,9 +1434,6 @@ bool SampleWindow::onHandleChar(SkUnichar uni) { } switch (uni) { - case 'd': - SkGraphics::SetFontCacheUsed(0); - return true; case 'f': // only toggleFPS(); diff --git a/src/core/SkGraphics.cpp b/src/core/SkGraphics.cpp index e91b647665..542a1997ab 100644 --- a/src/core/SkGraphics.cpp +++ b/src/core/SkGraphics.cpp @@ -113,6 +113,8 @@ void SkGraphics::Init() { SkDebugf("SkGraphics: sizeof(%s) = %d\n", gTypeSize[i].fTypeName, gTypeSize[i].fSizeOf); } + SkDebugf("SkGraphics: font cache limit %dK\n", + GetFontCacheLimit() >> 10); #endif } @@ -123,19 +125,11 @@ void SkGraphics::Init() { #include "SkTypefaceCache.h" void SkGraphics::Term() { - SkGraphics::SetFontCacheUsed(0); + SkGlyphCache::SetCacheUsed(0); SkTypefaceCache::PurgeAll(); SkGlobals::Term(); } -size_t SkGraphics::GetFontCacheUsed() { - return SkGlyphCache::GetCacheUsed(); -} - -bool SkGraphics::SetFontCacheUsed(size_t usageInBytes) { - return SkGlyphCache::SetCacheUsed(usageInBytes); -} - #ifndef SK_DEFAULT_FONT_CACHE_LIMIT #define SK_DEFAULT_FONT_CACHE_LIMIT (2 * 1024 * 1024) #endif @@ -157,9 +151,13 @@ size_t SkGraphics::SetFontCacheLimit(size_t bytes) { gFontCacheLimit = bytes; // trigger a purge if the new size is smaller that our currently used amount - if (bytes < GetFontCacheUsed()) { - SetFontCacheUsed(bytes); + if (bytes < SkGlyphCache::GetCacheUsed()) { + SkGlyphCache::SetCacheUsed(bytes); } return prev; } +void SkGraphics::PurgeFontCache() { + SkGlyphCache::SetCacheUsed(0); +} + |