joshualitt | b7133be | 2015-04-08 09:08:31 -0700 | [diff] [blame] | 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 | |
joshualitt | b7133be | 2015-04-08 09:08:31 -0700 | [diff] [blame] | 10 | GrTextBlobCache::~GrTextBlobCache() { |
Florin Malita | 3304c44 | 2017-03-09 22:42:58 +0000 | [diff] [blame] | 11 | this->freeAll(); |
joshualitt | b7133be | 2015-04-08 09:08:31 -0700 | [diff] [blame] | 12 | } |
| 13 | |
joshualitt | 26ffc00 | 2015-04-16 11:24:04 -0700 | [diff] [blame] | 14 | void GrTextBlobCache::freeAll() { |
Florin Malita | 33fdb8d | 2017-03-07 16:51:57 -0500 | [diff] [blame] | 15 | fBlobIDCache.foreach([this](uint32_t, BlobIDCacheEntry* entry) { |
Florin Malita | 3304c44 | 2017-03-09 22:42:58 +0000 | [diff] [blame] | 16 | for (auto* blob : entry->fBlobs) { |
| 17 | fBlobList.remove(blob); |
| 18 | blob->unref(); |
Florin Malita | 33fdb8d | 2017-03-07 16:51:57 -0500 | [diff] [blame] | 19 | } |
| 20 | }); |
| 21 | |
| 22 | fBlobIDCache.reset(); |
joshualitt | 20ccd40 | 2016-01-05 08:56:56 -0800 | [diff] [blame] | 23 | |
| 24 | // There should be no allocations in the memory pool at this point |
| 25 | SkASSERT(fPool.isEmpty()); |
Florin Malita | 33fdb8d | 2017-03-07 16:51:57 -0500 | [diff] [blame] | 26 | SkASSERT(fBlobList.isEmpty()); |
joshualitt | 26ffc00 | 2015-04-16 11:24:04 -0700 | [diff] [blame] | 27 | } |