| 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) |
| 16 SK_DECLARE_STATIC_MUTEX(gPurgeableImageMutex); | 17 SK_DECLARE_STATIC_MUTEX(gPurgeableImageMutex); |
| 17 | 18 |
| 18 SkImageCache* SkPurgeableImageCache::Create() { | 19 SkImageCache* SkPurgeableImageCache::Create() { |
| 19 if (!SkPurgeableMemoryBlock::IsSupported()) { | 20 if (!SkPurgeableMemoryBlock::IsSupported()) { |
| 20 return NULL; | 21 return NULL; |
| 21 } | 22 } |
| 22 SkAutoMutexAcquire ac(&gPurgeableImageMutex); | 23 SkAutoMutexAcquire ac(&gPurgeableImageMutex); |
| 23 static SkPurgeableImageCache gCache; | 24 static SkPurgeableImageCache gCache; |
| 24 gCache.ref(); | 25 gCache.ref(); |
| 25 return &gCache; | 26 return &gCache; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 void SkPurgeableImageCache::removeRec(intptr_t ID) { | 151 void SkPurgeableImageCache::removeRec(intptr_t ID) { |
| 151 #ifdef SK_DEBUG | 152 #ifdef SK_DEBUG |
| 152 int index = this->findRec(ID); | 153 int index = this->findRec(ID); |
| 153 SkASSERT(index >= 0); | 154 SkASSERT(index >= 0); |
| 154 fRecs.remove(index); | 155 fRecs.remove(index); |
| 155 #endif | 156 #endif |
| 156 SkPurgeableMemoryBlock* block = reinterpret_cast<SkPurgeableMemoryBlock*>(ID
); | 157 SkPurgeableMemoryBlock* block = reinterpret_cast<SkPurgeableMemoryBlock*>(ID
); |
| 157 SkASSERT(!block->isPinned()); | 158 SkASSERT(!block->isPinned()); |
| 158 SkDELETE(block); | 159 SkDELETE(block); |
| 159 } | 160 } |
| OLD | NEW |