aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkGlyphCache_Globals.h
diff options
context:
space:
mode:
authorGravatar herb <herb@google.com>2015-09-15 07:03:03 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-09-15 07:03:03 -0700
commit014ffdb01ea5317614a1569efc30c50f06434222 (patch)
tree3ddd6142fe30a488a982bc7b72406c7a835cf366 /src/core/SkGlyphCache_Globals.h
parent474df7fc03e58b85ef256cc314aa439316fcd38d (diff)
Parallel cache.
Diffstat (limited to 'src/core/SkGlyphCache_Globals.h')
-rw-r--r--src/core/SkGlyphCache_Globals.h29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/core/SkGlyphCache_Globals.h b/src/core/SkGlyphCache_Globals.h
index e1825a2f0f..3736ace414 100644
--- a/src/core/SkGlyphCache_Globals.h
+++ b/src/core/SkGlyphCache_Globals.h
@@ -26,8 +26,9 @@
class SkGlyphCache_Globals {
public:
SkGlyphCache_Globals() {
+
fHead = nullptr;
- fTotalMemoryUsed = 0;
+ fTotalMemoryUsed.store(0);
fCacheSizeLimit = SK_DEFAULT_FONT_CACHE_LIMIT;
fCacheCount = 0;
fCacheCountLimit = SK_DEFAULT_FONT_CACHE_COUNT_LIMIT;
@@ -47,7 +48,8 @@ public:
SkGlyphCache* internalGetHead() const { return fHead; }
SkGlyphCache* internalGetTail() const;
- size_t getTotalMemoryUsed() const { return fTotalMemoryUsed; }
+ size_t getTotalMemoryUsed() const { return fTotalMemoryUsed.load(); }
+ void increaseTotalMemoryUsed(size_t increase) { fTotalMemoryUsed.fetch_add(increase);}
int getCacheCountUsed() const { return fCacheCount; }
#ifdef SK_DEBUG
@@ -66,29 +68,30 @@ public:
// or count limit.
bool isOverBudget() const {
return fCacheCount > fCacheCountLimit ||
- fTotalMemoryUsed > fCacheSizeLimit;
+ fTotalMemoryUsed.load() > fCacheSizeLimit;
}
void purgeAll(); // does not change budget
// call when a glyphcache is available for caching (i.e. not in use)
- void attachCacheToHead(SkGlyphCache*);
-
- // can only be called when the mutex is already held
- void internalDetachCache(SkGlyphCache*);
void internalAttachCacheToHead(SkGlyphCache*);
-private:
- SkGlyphCache* fHead;
- size_t fTotalMemoryUsed;
- size_t fCacheSizeLimit;
- int32_t fCacheCountLimit;
- int32_t fCacheCount;
+ // can only be called when the mutex is already held
+ void internalMoveToHead(SkGlyphCache *);
// Checkout budgets, modulated by the specified min-bytes-needed-to-purge,
// and attempt to purge caches to match.
// Returns number of bytes freed.
+ void internalDetachCache(SkGlyphCache* cache);
size_t internalPurge(size_t minBytesNeeded = 0);
+
+private:
+ SkGlyphCache* fHead;
+ SkAtomic<size_t> fTotalMemoryUsed;
+ size_t fCacheSizeLimit;
+ int32_t fCacheCountLimit;
+ int32_t fCacheCount;
+
};
#endif