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

Unified Diff: src/core/SkScaledImageCache.cpp

Issue 112833003: add more tests for discardable caches (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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
« no previous file with comments | « no previous file | src/lazy/SkDiscardableMemoryPool.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkScaledImageCache.cpp
diff --git a/src/core/SkScaledImageCache.cpp b/src/core/SkScaledImageCache.cpp
index 5b166887282ebaf7889e779519593e5fa6753ae2..b3956f4a8dbd43d225dccd159eab687e572bd63e 100644
--- a/src/core/SkScaledImageCache.cpp
+++ b/src/core/SkScaledImageCache.cpp
@@ -209,6 +209,7 @@ private:
SkDiscardableMemory* fDM;
size_t fRB;
bool fFirstTime;
+ bool fIsLocked;
typedef SkPixelRef INHERITED;
};
@@ -224,6 +225,7 @@ SkOneShotDiscardablePixelRef::SkOneShotDiscardablePixelRef(const SkImageInfo& in
SkASSERT(dm->data());
fFirstTime = true;
+ fIsLocked = false;
}
SkOneShotDiscardablePixelRef::~SkOneShotDiscardablePixelRef() {
@@ -236,12 +238,18 @@ void* SkOneShotDiscardablePixelRef::onLockPixels(SkColorTable** ctable) {
fFirstTime = false;
return fDM->data();
}
- return fDM->lock() ? fDM->data() : NULL;
+
+ SkASSERT(!fIsLocked);
+ fIsLocked = fDM->lock();
+ return fIsLocked ? fDM->data() : NULL;
}
void SkOneShotDiscardablePixelRef::onUnlockPixels() {
SkASSERT(!fFirstTime);
- fDM->unlock();
+ if (fIsLocked) {
+ fIsLocked = false;
+ fDM->unlock();
+ }
}
size_t SkOneShotDiscardablePixelRef::getAllocatedSizeInBytes() const {
« no previous file with comments | « no previous file | src/lazy/SkDiscardableMemoryPool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698