blob: f1162e2634c1500b376427ef83c0a3b4d825b5fd [file] [log] [blame]
joshualittb7133be2015-04-08 09:08:31 -07001/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "GrTextBlobCache.h"
9
Florin Malita4a01ac92017-03-13 16:45:28 -040010DECLARE_SKMESSAGEBUS_MESSAGE(GrTextBlobCache::PurgeBlobMessage)
11
joshualittb7133be2015-04-08 09:08:31 -070012GrTextBlobCache::~GrTextBlobCache() {
Florin Malitac337c9e2017-03-10 18:02:29 +000013 SkDEBUGCODE(this->freeAll();)
joshualittb7133be2015-04-08 09:08:31 -070014}
15
joshualitt26ffc002015-04-16 11:24:04 -070016void GrTextBlobCache::freeAll() {
Florin Malita33fdb8d2017-03-07 16:51:57 -050017 fBlobIDCache.foreach([this](uint32_t, BlobIDCacheEntry* entry) {
Florin Malitac337c9e2017-03-10 18:02:29 +000018 for (const auto& blob : entry->fBlobs) {
19 fBlobList.remove(blob.get());
Florin Malita33fdb8d2017-03-07 16:51:57 -050020 }
21 });
22
23 fBlobIDCache.reset();
joshualitt20ccd402016-01-05 08:56:56 -080024
25 // There should be no allocations in the memory pool at this point
26 SkASSERT(fPool.isEmpty());
Florin Malita33fdb8d2017-03-07 16:51:57 -050027 SkASSERT(fBlobList.isEmpty());
joshualitt26ffc002015-04-16 11:24:04 -070028}
Florin Malita4a01ac92017-03-13 16:45:28 -040029
30void GrTextBlobCache::PostPurgeBlobMessage(uint32_t id) {
31 SkASSERT(id != SK_InvalidGenID);
32 SkMessageBus<PurgeBlobMessage>::Post(PurgeBlobMessage({id}));
33}