aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/lazy/SkDiscardablePixelRef.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-13 19:45:58 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-13 19:45:58 +0000
commitbf790232f6d94b54239dbc210d8beee7411ca458 (patch)
tree7944f60fbc7329035d186d0ff5645858c7df4781 /src/lazy/SkDiscardablePixelRef.cpp
parent0efb21bd1cd359b732a59753f3c1da096aab561a (diff)
Update all callsites to use info for pixelrefs
#define SK_SUPPORT_LEGACY_PIXELREF_CONSTRUCTOR in chrome to keep old API signature (for now) BUG= R=scroggo@google.com Review URL: https://codereview.chromium.org/100723005 git-svn-id: http://skia.googlecode.com/svn/trunk@12677 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/lazy/SkDiscardablePixelRef.cpp')
-rw-r--r--src/lazy/SkDiscardablePixelRef.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/lazy/SkDiscardablePixelRef.cpp b/src/lazy/SkDiscardablePixelRef.cpp
index f551436b3b..160ca5b4fb 100644
--- a/src/lazy/SkDiscardablePixelRef.cpp
+++ b/src/lazy/SkDiscardablePixelRef.cpp
@@ -9,19 +9,17 @@
#include "SkDiscardableMemory.h"
#include "SkImageGenerator.h"
-SkDiscardablePixelRef::SkDiscardablePixelRef(SkImageGenerator* generator,
- const SkImageInfo& info,
- size_t size,
+SkDiscardablePixelRef::SkDiscardablePixelRef(const SkImageInfo& info,
+ SkImageGenerator* generator,
size_t rowBytes,
SkDiscardableMemory::Factory* fact)
- : fGenerator(generator)
+ : INHERITED(info)
+ , fGenerator(generator)
, fDMFactory(fact)
- , fInfo(info)
- , fSize(size)
, fRowBytes(rowBytes)
- , fDiscardableMemory(NULL) {
+ , fDiscardableMemory(NULL)
+{
SkASSERT(fGenerator != NULL);
- SkASSERT(fSize > 0);
SkASSERT(fRowBytes > 0);
// The SkImageGenerator contract requires fGenerator to always
// decode the same image on each call to getPixels().
@@ -46,16 +44,19 @@ void* SkDiscardablePixelRef::onLockPixels(SkColorTable**) {
SkDELETE(fDiscardableMemory);
fDiscardableMemory = NULL;
}
+
+ const size_t size = this->info().getSafeSize(fRowBytes);
+
if (fDMFactory != NULL) {
- fDiscardableMemory = fDMFactory->create(fSize);
+ fDiscardableMemory = fDMFactory->create(size);
} else {
- fDiscardableMemory = SkDiscardableMemory::Create(fSize);
+ fDiscardableMemory = SkDiscardableMemory::Create(size);
}
if (NULL == fDiscardableMemory) {
return NULL; // Memory allocation failed.
}
void* pixels = fDiscardableMemory->data();
- if (!fGenerator->getPixels(fInfo, pixels, fRowBytes)) {
+ if (!fGenerator->getPixels(this->info(), pixels, fRowBytes)) {
fDiscardableMemory->unlock();
SkDELETE(fDiscardableMemory);
fDiscardableMemory = NULL;
@@ -84,10 +85,7 @@ bool SkInstallDiscardablePixelRef(SkImageGenerator* generator,
return dst->allocPixels(NULL, NULL);
}
SkAutoTUnref<SkDiscardablePixelRef> ref(SkNEW_ARGS(SkDiscardablePixelRef,
- (generator, info,
- dst->getSize(),
- dst->rowBytes(),
- factory)));
+ (info, generator, dst->rowBytes(), factory)));
dst->setPixelRef(ref);
return true;
}