Revert "simplify freeAll"
This reverts commit 3b6b7478421b4819e0f5ea08c44d90818b2cd739.
Reason for revert: maybe blocking chrome roll, linux-rel failing on ContextLost_WebGL2Blocked
Original change's description:
> simplify freeAll
>
> Change-Id: Ie0c396ee0f92bc16933a137270fc1601faf177f5
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298403
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Commit-Queue: Herb Derby <herb@google.com>
TBR=herb@google.com,robertphillips@google.com
Change-Id: I635ac0b834c0a818285974bcad229ac98f3ebf57
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298745
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/gpu/text/GrTextBlobCache.cpp b/src/gpu/text/GrTextBlobCache.cpp
index f981b59..29c855e 100644
--- a/src/gpu/text/GrTextBlobCache.cpp
+++ b/src/gpu/text/GrTextBlobCache.cpp
@@ -21,6 +21,10 @@
, fMessageBusID(messageBusID)
, fPurgeBlobInbox(messageBusID) { }
+GrTextBlobCache::~GrTextBlobCache() {
+ this->freeAll();
+}
+
sk_sp<GrTextBlob>
GrTextBlobCache::makeCachedBlob(const SkGlyphRunList& glyphRunList, const GrTextBlob::Key& key,
const SkMaskFilterBase::BlurRec& blurRec,
@@ -64,9 +68,18 @@
}
void GrTextBlobCache::freeAll() {
+ fBlobIDCache.foreach([this](uint32_t, BlobIDCacheEntry* entry) {
+ for (const auto& blob : entry->fBlobs) {
+ fBlobList.remove(blob.get());
+ }
+ });
+
fBlobIDCache.reset();
- fBlobList.reset();
+
fCurrentSize = 0;
+
+ // There should be no allocations in the memory pool at this point
+ SkASSERT(fBlobList.isEmpty());
}
void GrTextBlobCache::setBudget(size_t budget) {