Line data Source code
1 : /*
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 :
10 0 : DECLARE_SKMESSAGEBUS_MESSAGE(GrTextBlobCache::PurgeBlobMessage)
11 :
12 0 : GrTextBlobCache::~GrTextBlobCache() {
13 0 : SkDEBUGCODE(this->freeAll();)
14 0 : }
15 :
16 0 : void GrTextBlobCache::freeAll() {
17 0 : fBlobIDCache.foreach([this](uint32_t, BlobIDCacheEntry* entry) {
18 0 : for (const auto& blob : entry->fBlobs) {
19 0 : fBlobList.remove(blob.get());
20 : }
21 0 : });
22 :
23 0 : fBlobIDCache.reset();
24 :
25 : // There should be no allocations in the memory pool at this point
26 0 : SkASSERT(fPool.isEmpty());
27 0 : SkASSERT(fBlobList.isEmpty());
28 0 : }
29 :
30 0 : void GrTextBlobCache::PostPurgeBlobMessage(uint32_t id) {
31 0 : SkASSERT(id != SK_InvalidGenID);
32 0 : SkMessageBus<PurgeBlobMessage>::Post(PurgeBlobMessage({id}));
33 0 : }
|