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>
This commit is contained in:
parent
47ed6f10ef
commit
d238d2fb67
@ -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;
|
||||
}
|
||||
|
@ -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};
|
||||
|
Loading…
Reference in New Issue
Block a user