blob: f6dac691f4fc374b70d18e66518cc9e511f105e5 [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
joshualittb7133be2015-04-08 09:08:31 -070010GrTextBlobCache::~GrTextBlobCache() {
Florin Malita3304c442017-03-09 22:42:58 +000011 this->freeAll();
joshualittb7133be2015-04-08 09:08:31 -070012}
13
joshualitt26ffc002015-04-16 11:24:04 -070014void GrTextBlobCache::freeAll() {
Florin Malita33fdb8d2017-03-07 16:51:57 -050015 fBlobIDCache.foreach([this](uint32_t, BlobIDCacheEntry* entry) {
Florin Malita3304c442017-03-09 22:42:58 +000016 for (auto* blob : entry->fBlobs) {
17 fBlobList.remove(blob);
18 blob->unref();
Florin Malita33fdb8d2017-03-07 16:51:57 -050019 }
20 });
21
22 fBlobIDCache.reset();
joshualitt20ccd402016-01-05 08:56:56 -080023
24 // There should be no allocations in the memory pool at this point
25 SkASSERT(fPool.isEmpty());
Florin Malita33fdb8d2017-03-07 16:51:57 -050026 SkASSERT(fBlobList.isEmpty());
joshualitt26ffc002015-04-16 11:24:04 -070027}