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