OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkThread.h" | 8 #include "SkThread.h" |
9 #include "SkPurgeableImageCache.h" | 9 #include "SkPurgeableImageCache.h" |
10 #include "SkPurgeableMemoryBlock.h" | 10 #include "SkPurgeableMemoryBlock.h" |
11 | 11 |
12 #ifdef SK_DEBUG | 12 #ifdef SK_DEBUG |
13 #include "SkTSearch.h" | 13 #include "SkTSearch.h" |
14 #endif | 14 #endif |
15 | 15 |
16 SK_DEFINE_INST_COUNT(SkPurgeableImageCache) | |
17 SK_DECLARE_STATIC_MUTEX(gPurgeableImageMutex); | 16 SK_DECLARE_STATIC_MUTEX(gPurgeableImageMutex); |
18 | 17 |
19 SkImageCache* SkPurgeableImageCache::Create() { | 18 SkImageCache* SkPurgeableImageCache::Create() { |
20 if (!SkPurgeableMemoryBlock::IsSupported()) { | 19 if (!SkPurgeableMemoryBlock::IsSupported()) { |
21 return NULL; | 20 return NULL; |
22 } | 21 } |
23 SkAutoMutexAcquire ac(&gPurgeableImageMutex); | 22 SkAutoMutexAcquire ac(&gPurgeableImageMutex); |
24 static SkPurgeableImageCache gCache; | 23 static SkPurgeableImageCache gCache; |
25 gCache.ref(); | 24 gCache.ref(); |
26 return &gCache; | 25 return &gCache; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 void SkPurgeableImageCache::removeRec(intptr_t ID) { | 150 void SkPurgeableImageCache::removeRec(intptr_t ID) { |
152 #ifdef SK_DEBUG | 151 #ifdef SK_DEBUG |
153 int index = this->findRec(ID); | 152 int index = this->findRec(ID); |
154 SkASSERT(index >= 0); | 153 SkASSERT(index >= 0); |
155 fRecs.remove(index); | 154 fRecs.remove(index); |
156 #endif | 155 #endif |
157 SkPurgeableMemoryBlock* block = reinterpret_cast<SkPurgeableMemoryBlock*>(ID
); | 156 SkPurgeableMemoryBlock* block = reinterpret_cast<SkPurgeableMemoryBlock*>(ID
); |
158 SkASSERT(!block->isPinned()); | 157 SkASSERT(!block->isPinned()); |
159 SkDELETE(block); | 158 SkDELETE(block); |
160 } | 159 } |
OLD | NEW |