| Index: src/lazy/SkCachingPixelRef.cpp
|
| diff --git a/src/lazy/SkCachingPixelRef.cpp b/src/lazy/SkCachingPixelRef.cpp
|
| index c59682854bc04e56e47ae9e504606387c95da69e..6d97aaeee97e6ca1d2984ab5de0bcef04b7f7e5c 100644
|
| --- a/src/lazy/SkCachingPixelRef.cpp
|
| +++ b/src/lazy/SkCachingPixelRef.cpp
|
| @@ -30,13 +30,11 @@ SkCachingPixelRef::SkCachingPixelRef(const SkImageInfo& info,
|
| : INHERITED(info)
|
| , fImageGenerator(generator)
|
| , fErrorInDecoding(false)
|
| - , fScaledCacheId(NULL)
|
| , fRowBytes(rowBytes) {
|
| SkASSERT(fImageGenerator != NULL);
|
| }
|
| SkCachingPixelRef::~SkCachingPixelRef() {
|
| SkDELETE(fImageGenerator);
|
| - SkASSERT(NULL == fScaledCacheId);
|
| // Assert always unlock before unref.
|
| }
|
|
|
| @@ -46,48 +44,28 @@ bool SkCachingPixelRef::onNewLockPixels(LockRec* rec) {
|
| }
|
|
|
| const SkImageInfo& info = this->info();
|
| - SkBitmap bitmap;
|
| - SkASSERT(NULL == fScaledCacheId);
|
| - fScaledCacheId = SkBitmapCache::FindAndLock(this->getGenerationID(), info.fWidth, info.fHeight,
|
| - &bitmap);
|
| - if (NULL == fScaledCacheId) {
|
| + if (!SkBitmapCache::Find(this->getGenerationID(), info.fWidth, info.fHeight, &fLockedBitmap)) {
|
| // Cache has been purged, must re-decode.
|
| - if (!bitmap.allocPixels(info, fRowBytes)) {
|
| + if (!fLockedBitmap.allocPixels(info, fRowBytes)) {
|
| fErrorInDecoding = true;
|
| return false;
|
| }
|
| - SkAutoLockPixels autoLockPixels(bitmap);
|
| - if (!fImageGenerator->getPixels(info, bitmap.getPixels(), fRowBytes)) {
|
| + if (!fImageGenerator->getPixels(info, fLockedBitmap.getPixels(), fRowBytes)) {
|
| fErrorInDecoding = true;
|
| return false;
|
| }
|
| - fScaledCacheId = SkBitmapCache::AddAndLock(this->getGenerationID(),
|
| - info.fWidth, info.fHeight, bitmap);
|
| - SkASSERT(fScaledCacheId != NULL);
|
| + SkBitmapCache::Add(this->getGenerationID(), info.fWidth, info.fHeight, fLockedBitmap);
|
| }
|
|
|
| - // Now bitmap should contain a concrete PixelRef of the decoded
|
| - // image.
|
| - SkAutoLockPixels autoLockPixels(bitmap);
|
| - void* pixels = bitmap.getPixels();
|
| + // Now bitmap should contain a concrete PixelRef of the decoded image.
|
| + void* pixels = fLockedBitmap.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
|
| - // remains valid is the guarantee made by
|
| - // SkScaledImageCache that it will not destroy the *other*
|
| - // bitmap (SkScaledImageCache::Rec.fBitmap) that holds a
|
| - // reference to the concrete PixelRef while this record is
|
| - // locked.
|
| rec->fPixels = pixels;
|
| rec->fColorTable = NULL;
|
| - rec->fRowBytes = bitmap.rowBytes();
|
| + rec->fRowBytes = fLockedBitmap.rowBytes();
|
| return true;
|
| }
|
|
|
| void SkCachingPixelRef::onUnlockPixels() {
|
| - SkASSERT(fScaledCacheId != NULL);
|
| - SkScaledImageCache::Unlock( static_cast<SkScaledImageCache::ID*>(fScaledCacheId));
|
| - fScaledCacheId = NULL;
|
| + fLockedBitmap.reset();
|
| }
|
|
|