diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-01-06 13:34:39 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-01-06 13:34:39 +0000 |
commit | ba82bd11e2c055f885b2327aa230d2dac8b53f03 (patch) | |
tree | 8e838e01d55b7a6d9ac811d00826d9a38e290f12 /src/lazy | |
parent | 452eecb4436f27e057d4d2df26e3a70020a817b6 (diff) |
Revert "Revert "Revert of https://codereview.chromium.org/110593003/""
This reverts commit 0fef787f33aa38109a0c8427e0098d997efdd5ff.
failed in chrome: https://codereview.chromium.org/124503002/
Review URL: https://codereview.chromium.org/105523008
git-svn-id: http://skia.googlecode.com/svn/trunk@12906 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/lazy')
-rw-r--r-- | src/lazy/SkCachingPixelRef.cpp | 17 | ||||
-rw-r--r-- | src/lazy/SkCachingPixelRef.h | 2 | ||||
-rw-r--r-- | src/lazy/SkDiscardablePixelRef.cpp | 19 | ||||
-rw-r--r-- | src/lazy/SkDiscardablePixelRef.h | 6 |
4 files changed, 15 insertions, 29 deletions
diff --git a/src/lazy/SkCachingPixelRef.cpp b/src/lazy/SkCachingPixelRef.cpp index f1510fb67c..452ea4ed03 100644 --- a/src/lazy/SkCachingPixelRef.cpp +++ b/src/lazy/SkCachingPixelRef.cpp @@ -8,6 +8,7 @@ #include "SkCachingPixelRef.h" #include "SkScaledImageCache.h" + bool SkCachingPixelRef::Install(SkImageGenerator* generator, SkBitmap* dst) { SkImageInfo info; @@ -40,12 +41,13 @@ SkCachingPixelRef::~SkCachingPixelRef() { // Assert always unlock before unref. } -bool SkCachingPixelRef::onNewLockPixels(LockRec* rec) { +void* SkCachingPixelRef::onLockPixels(SkColorTable**) { if (fErrorInDecoding) { - return false; // don't try again. + return NULL; // don't try again. } - + const SkImageInfo& info = this->info(); + SkBitmap bitmap; SkASSERT(NULL == fScaledCacheId); fScaledCacheId = SkScaledImageCache::FindAndLock(this->getGenerationID(), @@ -56,12 +58,12 @@ bool SkCachingPixelRef::onNewLockPixels(LockRec* rec) { // Cache has been purged, must re-decode. if ((!bitmap.setConfig(info, fRowBytes)) || !bitmap.allocPixels()) { fErrorInDecoding = true; - return false; + return NULL; } SkAutoLockPixels autoLockPixels(bitmap); if (!fImageGenerator->getPixels(info, bitmap.getPixels(), fRowBytes)) { fErrorInDecoding = true; - return false; + return NULL; } fScaledCacheId = SkScaledImageCache::AddAndLock(this->getGenerationID(), info.fWidth, @@ -84,10 +86,7 @@ bool SkCachingPixelRef::onNewLockPixels(LockRec* rec) { // 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(); - return true; + return pixels; } void SkCachingPixelRef::onUnlockPixels() { diff --git a/src/lazy/SkCachingPixelRef.h b/src/lazy/SkCachingPixelRef.h index 905ee9bf0d..b1f2fcd669 100644 --- a/src/lazy/SkCachingPixelRef.h +++ b/src/lazy/SkCachingPixelRef.h @@ -40,7 +40,7 @@ public: protected: virtual ~SkCachingPixelRef(); - virtual bool onNewLockPixels(LockRec*) SK_OVERRIDE; + virtual void* onLockPixels(SkColorTable** colorTable) SK_OVERRIDE; virtual void onUnlockPixels() SK_OVERRIDE; virtual bool onLockPixelsAreWritable() const SK_OVERRIDE { return false; } diff --git a/src/lazy/SkDiscardablePixelRef.cpp b/src/lazy/SkDiscardablePixelRef.cpp index abd80f2e0a..2886156102 100644 --- a/src/lazy/SkDiscardablePixelRef.cpp +++ b/src/lazy/SkDiscardablePixelRef.cpp @@ -36,13 +36,10 @@ SkDiscardablePixelRef::~SkDiscardablePixelRef() { SkDELETE(fGenerator); } -bool SkDiscardablePixelRef::onNewLockPixels(LockRec* rec) { +void* SkDiscardablePixelRef::onLockPixels(SkColorTable**) { if (fDiscardableMemory != NULL) { if (fDiscardableMemory->lock()) { - rec->fPixels = fDiscardableMemory->data(); - rec->fColorTable = NULL; - rec->fRowBytes = fRowBytes; - return true; + return fDiscardableMemory->data(); } SkDELETE(fDiscardableMemory); fDiscardableMemory = NULL; @@ -56,23 +53,17 @@ bool SkDiscardablePixelRef::onNewLockPixels(LockRec* rec) { fDiscardableMemory = SkDiscardableMemory::Create(size); } if (NULL == fDiscardableMemory) { - return false; // Memory allocation failed. + return NULL; // Memory allocation failed. } - void* pixels = fDiscardableMemory->data(); if (!fGenerator->getPixels(this->info(), pixels, fRowBytes)) { fDiscardableMemory->unlock(); SkDELETE(fDiscardableMemory); fDiscardableMemory = NULL; - return false; + return NULL; } - - rec->fPixels = pixels; - rec->fColorTable = NULL; - rec->fRowBytes = fRowBytes; - return true; + return pixels; } - void SkDiscardablePixelRef::onUnlockPixels() { fDiscardableMemory->unlock(); } diff --git a/src/lazy/SkDiscardablePixelRef.h b/src/lazy/SkDiscardablePixelRef.h index 4a013fda03..3367096c26 100644 --- a/src/lazy/SkDiscardablePixelRef.h +++ b/src/lazy/SkDiscardablePixelRef.h @@ -28,8 +28,7 @@ public: protected: ~SkDiscardablePixelRef(); - - virtual bool onNewLockPixels(LockRec*) SK_OVERRIDE; + virtual void* onLockPixels(SkColorTable**) SK_OVERRIDE; virtual void onUnlockPixels() SK_OVERRIDE; virtual bool onLockPixelsAreWritable() const SK_OVERRIDE { return false; } @@ -50,12 +49,9 @@ private: SkDiscardablePixelRef(const SkImageInfo&, SkImageGenerator*, size_t rowBytes, SkDiscardableMemory::Factory* factory); - friend bool SkInstallDiscardablePixelRef(SkImageGenerator*, SkBitmap*, SkDiscardableMemory::Factory*); - typedef SkPixelRef INHERITED; }; - #endif // SkDiscardablePixelRef_DEFINED |