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 { |