diff options
author | Jim Van Verth <jvanverth@google.com> | 2017-12-13 09:26:37 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-13 14:54:42 +0000 |
commit | 76d917cef19aabfdc1247336f58237800bd71875 (patch) | |
tree | 6e6be4dc09150c4d9e8f74bb80c866f5062278ed /src/gpu/text/GrTextBlobCache.h | |
parent | 1fbdb61f1389f01ce1cf1b7950e03a84811a9f38 (diff) |
Ensure we flush TextBlobCache message queue.
If we create and delete TextBlobs without actually renderering them,
their deletion messages can back up in the message queue. This adds
a routine to GrContext to ensure these messages get flushed.
Bug: 703297
Change-Id: Icc222373ac2a954dc3b77190cad79070ea562ba2
Reviewed-on: https://skia-review.googlesource.com/82686
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/text/GrTextBlobCache.h')
-rw-r--r-- | src/gpu/text/GrTextBlobCache.h | 52 |
1 files changed, 3 insertions, 49 deletions
diff --git a/src/gpu/text/GrTextBlobCache.h b/src/gpu/text/GrTextBlobCache.h index b294534775..dc7e4c5844 100644 --- a/src/gpu/text/GrTextBlobCache.h +++ b/src/gpu/text/GrTextBlobCache.h @@ -102,6 +102,8 @@ public: static void PostPurgeBlobMessage(uint32_t); + void purgeStaleBlobs(); + private: using BitmapBlobList = SkTInternalLList<GrAtlasTextBlob>; @@ -166,55 +168,7 @@ private: this->checkPurge(rawBlobPtr); } - void checkPurge(GrAtlasTextBlob* blob = nullptr) { - // First, purge all stale blob IDs. - { - SkTArray<PurgeBlobMessage> msgs; - fPurgeBlobInbox.poll(&msgs); - - for (const auto& msg : msgs) { - auto* idEntry = fBlobIDCache.find(msg.fID); - if (!idEntry) { - // no cache entries for id - continue; - } - - // remove all blob entries from the LRU list - for (const auto& blob : idEntry->fBlobs) { - fBlobList.remove(blob.get()); - } - - // drop the idEntry itself (unrefs all blobs) - fBlobIDCache.remove(msg.fID); - } - } - - // If we are still overbudget, then unref until we are below budget again - if (fPool.size() > fBudget) { - BitmapBlobList::Iter iter; - iter.init(fBlobList, BitmapBlobList::Iter::kTail_IterStart); - GrAtlasTextBlob* lruBlob = nullptr; - while (fPool.size() > fBudget && (lruBlob = iter.get()) && lruBlob != blob) { - // Backup the iterator before removing and unrefing the blob - iter.prev(); - - this->remove(lruBlob); - } - - // If we break out of the loop with lruBlob == blob, then we haven't purged enough - // use the call back and try to free some more. If we are still overbudget after this, - // then this single textblob is over our budget - if (blob && lruBlob == blob) { - (*fCallback)(fData); - } - -#ifdef SPEW_BUDGET_MESSAGE - if (fPool.size() > fBudget) { - SkDebugf("Single textblob is larger than our whole budget"); - } -#endif - } - } + void checkPurge(GrAtlasTextBlob* blob = nullptr); static const int kMinGrowthSize = 1 << 16; static const int kDefaultBudget = 1 << 22; |