Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: src/lazy/SkDiscardablePixelRef.cpp

Issue 108303003: Revert "PixelRef now returns (nearly) everything that is currently in SkBitmap. The goal is to refa… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/lazy/SkDiscardablePixelRef.h ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lazy/SkDiscardablePixelRef.cpp
diff --git a/src/lazy/SkDiscardablePixelRef.cpp b/src/lazy/SkDiscardablePixelRef.cpp
index eb35d0fcc4d5cf4c3cc9eed26a0415183afea76b..6a9507c8c76a713bba3c7a85388e3f8e4c78d702 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);
« no previous file with comments | « src/lazy/SkDiscardablePixelRef.h ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698