Index: src/lazy/SkCachingPixelRef.cpp |
diff --git a/src/lazy/SkCachingPixelRef.cpp b/src/lazy/SkCachingPixelRef.cpp |
index b7eaf574aac436223220923d7cd00fab2faa66af..2419e37d7d325b8c4b398397e3cb89ea632a13d5 100644 |
--- a/src/lazy/SkCachingPixelRef.cpp |
+++ b/src/lazy/SkCachingPixelRef.cpp |
@@ -8,7 +8,6 @@ |
#include "SkCachingPixelRef.h" |
#include "SkScaledImageCache.h" |
- |
bool SkCachingPixelRef::Install(SkImageGenerator* generator, |
SkBitmap* dst) { |
SkImageInfo info; |
@@ -31,10 +30,10 @@ bool SkCachingPixelRef::Install(SkImageGenerator* generator, |
SkCachingPixelRef::SkCachingPixelRef(SkImageGenerator* generator, |
const SkImageInfo& info, |
size_t rowBytes) |
- : fImageGenerator(generator) |
+ : INHERITED(info) |
+ , fImageGenerator(generator) |
, fErrorInDecoding(false) |
, fScaledCacheId(NULL) |
- , fInfo(info) |
, fRowBytes(rowBytes) { |
SkASSERT(fImageGenerator != NULL); |
} |
@@ -44,31 +43,32 @@ SkCachingPixelRef::~SkCachingPixelRef() { |
// Assert always unlock before unref. |
} |
-void* SkCachingPixelRef::onLockPixels(SkColorTable** colorTable) { |
- (void)colorTable; |
+bool SkCachingPixelRef::onNewLockPixels(LockRec* rec) { |
if (fErrorInDecoding) { |
- return NULL; // don't try again. |
+ return false; // don't try again. |
} |
+ |
+ const SkImageInfo& info = this->info(); |
SkBitmap bitmap; |
SkASSERT(NULL == fScaledCacheId); |
fScaledCacheId = SkScaledImageCache::FindAndLock(this->getGenerationID(), |
- fInfo.fWidth, |
- fInfo.fHeight, |
+ info.fWidth, |
+ info.fHeight, |
&bitmap); |
if (NULL == fScaledCacheId) { |
// Cache has been purged, must re-decode. |
- if ((!bitmap.setConfig(fInfo, fRowBytes)) || !bitmap.allocPixels()) { |
+ if ((!bitmap.setConfig(info, fRowBytes)) || !bitmap.allocPixels()) { |
fErrorInDecoding = true; |
- return NULL; |
+ return false; |
} |
SkAutoLockPixels autoLockPixels(bitmap); |
- if (!fImageGenerator->getPixels(fInfo, bitmap.getPixels(), fRowBytes)) { |
+ if (!fImageGenerator->getPixels(info, bitmap.getPixels(), fRowBytes)) { |
fErrorInDecoding = true; |
- return NULL; |
+ return false; |
} |
fScaledCacheId = SkScaledImageCache::AddAndLock(this->getGenerationID(), |
- fInfo.fWidth, |
- fInfo.fHeight, |
+ info.fWidth, |
+ info.fHeight, |
bitmap); |
SkASSERT(fScaledCacheId != NULL); |
} |
@@ -78,6 +78,7 @@ void* SkCachingPixelRef::onLockPixels(SkColorTable** colorTable) { |
SkAutoLockPixels autoLockPixels(bitmap); |
void* pixels = bitmap.getPixels(); |
SkASSERT(pixels != NULL); |
+ |
// At this point, the autoLockPixels will unlockPixels() |
// to remove bitmap's lock on the pixels. We will then |
// destroy bitmap. The *only* guarantee that this pointer |
@@ -86,7 +87,10 @@ void* SkCachingPixelRef::onLockPixels(SkColorTable** colorTable) { |
// bitmap (SkScaledImageCache::Rec.fBitmap) that holds a |
// reference to the concrete PixelRef while this record is |
// locked. |
- return pixels; |
+ rec->fPixels = pixels; |
+ rec->fColorTable = NULL; |
+ rec->fRowBytes = bitmap.rowBytes(); |
+ return true; |
} |
void SkCachingPixelRef::onUnlockPixels() { |