Remove memory pool use from SkTextBlobCache
Track used size explicitly in the cache enabling DDL to use
the LRU.
Change-Id: I3fef593e9252172dd160fd7636254550b95ca0a2
Reviewed-on: https://skia-review.googlesource.com/130022
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/src/gpu/text/GrTextBlobCache.cpp b/src/gpu/text/GrTextBlobCache.cpp
index 88cbaeb..5b95146 100644
--- a/src/gpu/text/GrTextBlobCache.cpp
+++ b/src/gpu/text/GrTextBlobCache.cpp
@@ -11,7 +11,6 @@
GrTextBlobCache::~GrTextBlobCache() {
this->freeAll();
- delete fPool;
}
void GrTextBlobCache::freeAll() {
@@ -23,8 +22,9 @@
fBlobIDCache.reset();
+ fCurrentSize = 0;
+
// There should be no allocations in the memory pool at this point
- SkASSERT(!fPool || fPool->isEmpty());
SkASSERT(fBlobList.isEmpty());
}
@@ -46,6 +46,7 @@
// remove all blob entries from the LRU list
for (const auto& blob : idEntry->fBlobs) {
+ fCurrentSize -= blob->size();
fBlobList.remove(blob.get());
}
@@ -54,26 +55,16 @@
}
}
-bool GrTextBlobCache::overBudget() const {
- if (fPool) {
- return fPool->size() > fBudget;
- }
-
- // When DDLs are being recorded no GrAtlasTextBlob will be deleted so the cache budget is
- // somewhat meaningless.
- return false;
-}
-
void GrTextBlobCache::checkPurge(GrAtlasTextBlob* blob) {
// First, purge all stale blob IDs.
this->purgeStaleBlobs();
// If we are still over budget, then unref until we are below budget again
- if (this->overBudget()) {
+ if (fCurrentSize > fSizeBudget) {
BitmapBlobList::Iter iter;
iter.init(fBlobList, BitmapBlobList::Iter::kTail_IterStart);
GrAtlasTextBlob* lruBlob = nullptr;
- while (this->overBudget() && (lruBlob = iter.get()) && lruBlob != blob) {
+ while (fCurrentSize > fSizeBudget && (lruBlob = iter.get()) && lruBlob != blob) {
// Backup the iterator before removing and unrefing the blob
iter.prev();
@@ -88,7 +79,7 @@
}
#ifdef SPEW_BUDGET_MESSAGE
- if (this->overBudget()) {
+ if (fCurrentSize > fSizeBudget) {
SkDebugf("Single textblob is larger than our whole budget");
}
#endif