diff options
author | 2016-06-22 10:19:16 -0700 | |
---|---|---|
committer | 2016-06-22 10:19:16 -0700 | |
commit | 632d004677de66a985d05c25a25e25272c740ede (patch) | |
tree | ed2ef0aeabf4529faebdb551a8168cff77d0f253 /src | |
parent | 3917cf4ef76dabecd340f1e4cd7999802809e5ca (diff) |
Add guards around access to font cache global fields.
BUG=589439
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2082423002
Review-Url: https://codereview.chromium.org/2082423002
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkGlyphCache.cpp | 20 | ||||
-rw-r--r-- | src/core/SkGlyphCache_Globals.h | 17 |
2 files changed, 25 insertions, 12 deletions
diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp index 30d00b2463..6d978a6b5f 100644 --- a/src/core/SkGlyphCache.cpp +++ b/src/core/SkGlyphCache.cpp @@ -470,6 +470,21 @@ void SkGlyphCache::invokeAndRemoveAuxProcs() { /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// +size_t SkGlyphCache_Globals::getTotalMemoryUsed() const { + SkAutoExclusive ac(fLock); + return fTotalMemoryUsed; +} + +int SkGlyphCache_Globals::getCacheCountUsed() const { + SkAutoExclusive ac(fLock); + return fCacheCount; +} + +int SkGlyphCache_Globals::getCacheCountLimit() const { + SkAutoExclusive ac(fLock); + return fCacheCountLimit; +} + size_t SkGlyphCache_Globals::setCacheSizeLimit(size_t newLimit) { static const size_t minLimit = 256 * 1024; if (newLimit < minLimit) { @@ -484,6 +499,11 @@ size_t SkGlyphCache_Globals::setCacheSizeLimit(size_t newLimit) { return prevLimit; } +size_t SkGlyphCache_Globals::getCacheSizeLimit() const { + SkAutoExclusive ac(fLock); + return fCacheSizeLimit; +} + int SkGlyphCache_Globals::setCacheCountLimit(int newCount) { if (newCount < 0) { newCount = 0; diff --git a/src/core/SkGlyphCache_Globals.h b/src/core/SkGlyphCache_Globals.h index e1825a2f0f..4d7fe22d80 100644 --- a/src/core/SkGlyphCache_Globals.h +++ b/src/core/SkGlyphCache_Globals.h @@ -42,13 +42,13 @@ public: } } - SkSpinlock fLock; + mutable SkSpinlock fLock; SkGlyphCache* internalGetHead() const { return fHead; } SkGlyphCache* internalGetTail() const; - size_t getTotalMemoryUsed() const { return fTotalMemoryUsed; } - int getCacheCountUsed() const { return fCacheCount; } + size_t getTotalMemoryUsed() const; + int getCacheCountUsed() const; #ifdef SK_DEBUG void validate() const; @@ -56,19 +56,12 @@ public: void validate() const {} #endif - int getCacheCountLimit() const { return fCacheCountLimit; } + int getCacheCountLimit() const; int setCacheCountLimit(int limit); - size_t getCacheSizeLimit() const { return fCacheSizeLimit; } + size_t getCacheSizeLimit() const; size_t setCacheSizeLimit(size_t limit); - // returns true if this cache is over-budget either due to size limit - // or count limit. - bool isOverBudget() const { - return fCacheCount > fCacheCountLimit || - fTotalMemoryUsed > fCacheSizeLimit; - } - void purgeAll(); // does not change budget // call when a glyphcache is available for caching (i.e. not in use) |