Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Unified Diff: src/lazy/SkLruImageCache.cpp

Issue 12433020: Improvements/additions to SkImageCache/SkLazyPixelRef. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Modified a comment. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
}

Powered by Google App Engine
This is Rietveld 408576698