aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/text/GrTextBlobCache.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-02-14 18:54:01 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-15 13:23:22 +0000
commit303cd58870cf1d0d128ff3f37d1dc26778cad5af (patch)
tree0d063c9072fff57bc50d77e3b15a2247290ec05e /src/gpu/text/GrTextBlobCache.cpp
parentd5811b2d4423cbf561e6ab8251550543d690f376 (diff)
Update GrTextBlobCache for DDL
Although, theoretically, we could update the DDLs to maintain pointers to the GrMemoryPools being used by their GrAtlasTextBlobs this method seems simpler. Change-Id: I4835284630b9cd29eb78cf25bcdfe5c56974a8cb Reviewed-on: https://skia-review.googlesource.com/107345 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'src/gpu/text/GrTextBlobCache.cpp')
-rw-r--r--src/gpu/text/GrTextBlobCache.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/gpu/text/GrTextBlobCache.cpp b/src/gpu/text/GrTextBlobCache.cpp
index 64941efc96..88cbaeb2c7 100644
--- a/src/gpu/text/GrTextBlobCache.cpp
+++ b/src/gpu/text/GrTextBlobCache.cpp
@@ -10,7 +10,8 @@
DECLARE_SKMESSAGEBUS_MESSAGE(GrTextBlobCache::PurgeBlobMessage)
GrTextBlobCache::~GrTextBlobCache() {
- SkDEBUGCODE(this->freeAll();)
+ this->freeAll();
+ delete fPool;
}
void GrTextBlobCache::freeAll() {
@@ -23,7 +24,7 @@ void GrTextBlobCache::freeAll() {
fBlobIDCache.reset();
// There should be no allocations in the memory pool at this point
- SkASSERT(fPool.isEmpty());
+ SkASSERT(!fPool || fPool->isEmpty());
SkASSERT(fBlobList.isEmpty());
}
@@ -53,16 +54,26 @@ void GrTextBlobCache::purgeStaleBlobs() {
}
}
+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 (fPool.size() > fBudget) {
+ if (this->overBudget()) {
BitmapBlobList::Iter iter;
iter.init(fBlobList, BitmapBlobList::Iter::kTail_IterStart);
GrAtlasTextBlob* lruBlob = nullptr;
- while (fPool.size() > fBudget && (lruBlob = iter.get()) && lruBlob != blob) {
+ while (this->overBudget() && (lruBlob = iter.get()) && lruBlob != blob) {
// Backup the iterator before removing and unrefing the blob
iter.prev();
@@ -77,7 +88,7 @@ void GrTextBlobCache::checkPurge(GrAtlasTextBlob* blob) {
}
#ifdef SPEW_BUDGET_MESSAGE
- if (fPool.size() > fBudget) {
+ if (this->overBudget()) {
SkDebugf("Single textblob is larger than our whole budget");
}
#endif