diff options
author | Herb Derby <herb@google.com> | 2018-04-26 12:59:08 -0400 |
---|---|---|
committer | Herb Derby <herb@google.com> | 2018-04-26 18:46:45 +0000 |
commit | d238d2fb6741e4dded7b6ebe7a3e3a11bd3f6ac9 (patch) | |
tree | 24aa4296900095021a6737c63e939c1db4d7144d | |
parent | 47ed6f10ef1d6c29512f95e88a7e51456c4d8f87 (diff) |
Track tail of strike cache
Change-Id: Ic5d5ae5d4c45d0bc5b82dd2257752184a8b529d0
Reviewed-on: https://skia-review.googlesource.com/123935
Commit-Queue: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Auto-Submit: Herb Derby <herb@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
-rw-r--r-- | src/core/SkStrikeCache.cpp | 16 | ||||
-rw-r--r-- | src/core/SkStrikeCache.h | 3 |
2 files changed, 8 insertions, 11 deletions
diff --git a/src/core/SkStrikeCache.cpp b/src/core/SkStrikeCache.cpp index 0fb36aaf14..04a1a80030 100644 --- a/src/core/SkStrikeCache.cpp +++ b/src/core/SkStrikeCache.cpp @@ -342,16 +342,6 @@ void SkStrikeCache::forEachStrike(std::function<void(const SkGlyphCache&)> visit } } -SkStrikeCache::Node* SkStrikeCache::internalGetTail() const { - Node* node = fHead; - if (node) { - while (node->fNext) { - node = node->fNext; - } - } - return node; -} - size_t SkStrikeCache::internalPurge(size_t minBytesNeeded) { this->validate(); @@ -416,6 +406,10 @@ void SkStrikeCache::internalAttachToHead(Node* node) { } fHead = node; + if (fTail == nullptr) { + fTail = node; + } + fCacheCount += 1; fTotalMemoryUsed += node->fCache.getMemoryUsed(); } @@ -432,6 +426,8 @@ void SkStrikeCache::internalDetachCache(Node* node) { } if (node->fNext) { node->fNext->fPrev = node->fPrev; + } else { + fTail = node->fPrev; } node->fPrev = node->fNext = nullptr; } diff --git a/src/core/SkStrikeCache.h b/src/core/SkStrikeCache.h index d4dc13927c..3e199da1e9 100644 --- a/src/core/SkStrikeCache.h +++ b/src/core/SkStrikeCache.h @@ -144,7 +144,7 @@ private: // The following methods can only be called when mutex is already held. Node* internalGetHead() const { return fHead; } - Node* internalGetTail() const; + Node* internalGetTail() const { return fTail; } void internalDetachCache(Node*); void internalAttachToHead(Node*); @@ -157,6 +157,7 @@ private: mutable SkSpinlock fLock; Node* fHead{nullptr}; + Node* fTail{nullptr}; size_t fTotalMemoryUsed{0}; size_t fCacheSizeLimit{SK_DEFAULT_FONT_CACHE_LIMIT}; int32_t fCacheCountLimit{SK_DEFAULT_FONT_CACHE_COUNT_LIMIT}; |