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

Unified Diff: src/lazy/SkDiscardablePixelRef.cpp

Issue 68973005: Expand pixelref to return SkImageInfo and rowbytes (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: new convention: require SkImageInfo in constructor 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
Index: src/lazy/SkDiscardablePixelRef.cpp
diff --git a/src/lazy/SkDiscardablePixelRef.cpp b/src/lazy/SkDiscardablePixelRef.cpp
index 4e19c7f65b9c011e6e2ab424a5e05a67218f2986..fcb70c7b401a7bf871b0a0d23304f83bba3d450c 100644
--- a/src/lazy/SkDiscardablePixelRef.cpp
+++ b/src/lazy/SkDiscardablePixelRef.cpp
@@ -12,8 +12,8 @@ SkDiscardablePixelRef::SkDiscardablePixelRef(SkImageGenerator* generator,
const SkImageInfo& info,
size_t size,
size_t rowBytes)
- : fGenerator(generator)
- , fInfo(info)
+ : INHERITED(info)
+ , fGenerator(generator)
, fSize(size)
, fRowBytes(rowBytes)
, fDiscardableMemory(NULL) {
@@ -29,22 +29,29 @@ SkDiscardablePixelRef::~SkDiscardablePixelRef() {
SkDELETE(fGenerator);
}
-void* SkDiscardablePixelRef::onLockPixels(SkColorTable**) {
+bool SkDiscardablePixelRef::onNewLockPixels(LockRec* rec) {
if (fDiscardableMemory != NULL) {
if (fDiscardableMemory->lock()) {
- return fDiscardableMemory->data();
+ rec->fPixels = fDiscardableMemory->data();
+ rec->fColorTable = NULL;
+ rec->fRowBytes = fRowBytes;
+ return true;
}
fDiscardableMemory = NULL;
}
fDiscardableMemory = SkDiscardableMemory::Create(fSize);
if (NULL == fDiscardableMemory) {
- return NULL; // Memory allocation failed.
+ return false; // Memory allocation failed.
}
void* pixels = fDiscardableMemory->data();
- if (!fGenerator->getPixels(fInfo, pixels, fRowBytes)) {
- return NULL; // TODO(halcanary) Find out correct thing to do.
+ if (!fGenerator->getPixels(this->info(), pixels, fRowBytes)) {
+ return false; // TODO(halcanary) Find out correct thing to do.
}
- return pixels;
+
+ rec->fPixels = pixels;
+ rec->fColorTable = NULL;
+ rec->fRowBytes = fRowBytes;
+ return true;
}
void SkDiscardablePixelRef::onUnlockPixels() {
if (fDiscardableMemory != NULL) {

Powered by Google App Engine
This is Rietveld 408576698