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-11 18:19:10 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-11 18:19:10 +0000
commit6a32add491cc736aab95561d137909cd7c5d65ef (patch)
tree4812c0d9561ba12a8460ac2e63fe81bde7819581 /src/lazy/SkDiscardablePixelRef.cpp
parent6965a0a2df9d35cd0a25e1738f0388272d03f399 (diff)
Revert "PixelRef now returns (nearly) everything that is currently in SkBitmap. The goal is to refactor bitmap later to remove redundancy, and more interestingly, remove the chance for a disconnect between the actual (pixelref) rowbytes and config, and the one claimed by the bitmap."""""
This reverts commit d08eca87a0bef10112a211de540f89656a80b86a. BUG= Review URL: https://codereview.chromium.org/108303003 git-svn-id: http://skia.googlecode.com/svn/trunk@12623 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/lazy/SkDiscardablePixelRef.cpp')
-rw-r--r--src/lazy/SkDiscardablePixelRef.cpp38
1 files changed, 15 insertions, 23 deletions
diff --git a/src/lazy/SkDiscardablePixelRef.cpp b/src/lazy/SkDiscardablePixelRef.cpp
index eb35d0fcc4..6a9507c8c7 100644
--- a/src/lazy/SkDiscardablePixelRef.cpp
+++ b/src/lazy/SkDiscardablePixelRef.cpp
@@ -11,15 +11,17 @@
SkDiscardablePixelRef::SkDiscardablePixelRef(SkImageGenerator* generator,
const SkImageInfo& info,
+ size_t size,
size_t rowBytes,
SkDiscardableMemory::Factory* fact)
- : INHERITED(info)
- , fGenerator(generator)
+ : 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().
@@ -33,39 +35,28 @@ 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;
}
-
- const size_t size = this->info().getSafeSize(fRowBytes);
if (fDMFactory != NULL) {
- fDiscardableMemory = fDMFactory->create(size);
+ fDiscardableMemory = fDMFactory->create(fSize);
} else {
- fDiscardableMemory = SkDiscardableMemory::Create(size);
+ fDiscardableMemory = SkDiscardableMemory::Create(fSize);
}
if (NULL == fDiscardableMemory) {
- return false; // Memory allocation failed.
+ return NULL; // Memory allocation failed.
}
-
void* pixels = fDiscardableMemory->data();
- if (!fGenerator->getPixels(this->info(), pixels, fRowBytes)) {
- return false; // TODO(halcanary) Find out correct thing to do.
+ if (!fGenerator->getPixels(fInfo, pixels, fRowBytes)) {
+ return NULL; // TODO(halcanary) Find out correct thing to do.
}
-
- rec->fPixels = pixels;
- rec->fColorTable = NULL;
- rec->fRowBytes = fRowBytes;
- return true;
+ return pixels;
}
-
void SkDiscardablePixelRef::onUnlockPixels() {
if (fDiscardableMemory != NULL) {
fDiscardableMemory->unlock();
@@ -90,6 +81,7 @@ bool SkInstallDiscardablePixelRef(SkImageGenerator* generator,
}
SkAutoTUnref<SkDiscardablePixelRef> ref(SkNEW_ARGS(SkDiscardablePixelRef,
(generator, info,
+ dst->getSize(),
dst->rowBytes(),
factory)));
dst->setPixelRef(ref);