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

Unified Diff: src/core/SkScaledImageCache.cpp

Issue 93673005: Revert of ensure that we call onUnlock only when we onLock succeeded (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 | « src/core/SkPixelRef.cpp ('k') | src/images/SkImageRef_ashmem.cpp » ('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 1b8ad524622801add8d92921dbb730c9f428e4c2..b3956f4a8dbd43d225dccd159eab687e572bd63e 100644
--- a/src/core/SkScaledImageCache.cpp
+++ b/src/core/SkScaledImageCache.cpp
@@ -209,6 +209,7 @@
SkDiscardableMemory* fDM;
size_t fRB;
bool fFirstTime;
+ bool fIsLocked;
typedef SkPixelRef INHERITED;
};
@@ -224,6 +225,7 @@
SkASSERT(dm->data());
fFirstTime = true;
+ fIsLocked = false;
}
SkOneShotDiscardablePixelRef::~SkOneShotDiscardablePixelRef() {
@@ -233,16 +235,21 @@
void* SkOneShotDiscardablePixelRef::onLockPixels(SkColorTable** ctable) {
if (fFirstTime) {
// we're already locked
- SkASSERT(fDM->data());
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 | « src/core/SkPixelRef.cpp ('k') | src/images/SkImageRef_ashmem.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698