Index: src/lazy/SkLruImageCache.cpp |
diff --git a/src/lazy/SkLruImageCache.cpp b/src/lazy/SkLruImageCache.cpp |
index 54f26fb5dcbf8263e143b12ce9efe846b5f1da38..160c16cf374e4ec7545133692189e0d2c01e95e1 100644 |
--- a/src/lazy/SkLruImageCache.cpp |
+++ b/src/lazy/SkLruImageCache.cpp |
@@ -74,16 +74,21 @@ SkLruImageCache::~SkLruImageCache() { |
} |
#ifdef SK_DEBUG |
-SkImageCache::CacheStatus SkLruImageCache::getCacheStatus(intptr_t ID) const { |
+SkImageCache::PinStatus SkLruImageCache::getPinStatus(intptr_t ID) const { |
SkAutoMutexAcquire ac(&fMutex); |
CachedPixels* pixels = this->findByID(ID); |
if (NULL == pixels) { |
- return SkImageCache::kThrownAway_CacheStatus; |
+ return SkImageCache::kThrownAway_PinStatus; |
} |
if (pixels->isLocked()) { |
- return SkImageCache::kPinned_CacheStatus; |
+ return SkImageCache::kPinned_PinStatus; |
} |
- return SkImageCache::kUnpinned_CacheStatus; |
+ return SkImageCache::kNeedsPin_PinStatus; |
+} |
+ |
+void SkLruImageCache::purgeAllCaches() { |
+ SkAutoMutexAcquire ac(&fMutex); |
+ this->purgeTilAtOrBelow(0); |
} |
#endif |
@@ -108,7 +113,7 @@ void* SkLruImageCache::allocAndPinCache(size_t bytes, intptr_t* ID) { |
return pixels->getData(); |
} |
-void* SkLruImageCache::pinCache(intptr_t ID) { |
+void* SkLruImageCache::pinCache(intptr_t ID, SkImageCache::PurgeStatus* status) { |
SkASSERT(ID != SkImageCache::UNINITIALIZED_ID); |
SkAutoMutexAcquire ac(&fMutex); |
CachedPixels* pixels = this->findByID(ID); |
@@ -119,6 +124,9 @@ void* SkLruImageCache::pinCache(intptr_t ID) { |
fLRU.remove(pixels); |
fLRU.addToHead(pixels); |
} |
+ SkASSERT(status != NULL); |
+ // This cache will never return pinned memory whose data has been overwritten. |
+ *status = SkImageCache::kNotPurged_PurgeStatus; |
pixels->lock(); |
return pixels->getData(); |
} |