Revert "Revert of https://codereview.chromium.org/112783004/"
This reverts commit 3293fe57a7507541e9040eab880dcd82c43881f4.
Conflicts:
src/core/SkScaledImageCache.cpp
BUG=
Review URL: https://codereview.chromium.org/108613005
git-svn-id: http://skia.googlecode.com/svn/trunk@12663 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/lazy/SkCachingPixelRef.cpp b/src/lazy/SkCachingPixelRef.cpp
index 667a949..b7eaf57 100644
--- a/src/lazy/SkCachingPixelRef.cpp
+++ b/src/lazy/SkCachingPixelRef.cpp
@@ -90,9 +90,7 @@
}
void SkCachingPixelRef::onUnlockPixels() {
- if (fScaledCacheId != NULL) {
- SkScaledImageCache::Unlock(
- static_cast<SkScaledImageCache::ID*>(fScaledCacheId));
- fScaledCacheId = NULL;
- }
+ SkASSERT(fScaledCacheId != NULL);
+ SkScaledImageCache::Unlock( static_cast<SkScaledImageCache::ID*>(fScaledCacheId));
+ fScaledCacheId = NULL;
}
diff --git a/src/lazy/SkDiscardablePixelRef.cpp b/src/lazy/SkDiscardablePixelRef.cpp
index 0b193ad..f551436 100644
--- a/src/lazy/SkDiscardablePixelRef.cpp
+++ b/src/lazy/SkDiscardablePixelRef.cpp
@@ -56,14 +56,15 @@
}
void* pixels = fDiscardableMemory->data();
if (!fGenerator->getPixels(fInfo, pixels, fRowBytes)) {
- return NULL; // TODO(halcanary) Find out correct thing to do.
+ fDiscardableMemory->unlock();
+ SkDELETE(fDiscardableMemory);
+ fDiscardableMemory = NULL;
+ return NULL;
}
return pixels;
}
void SkDiscardablePixelRef::onUnlockPixels() {
- if (fDiscardableMemory != NULL) {
- fDiscardableMemory->unlock();
- }
+ fDiscardableMemory->unlock();
}
bool SkInstallDiscardablePixelRef(SkImageGenerator* generator,