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

Unified Diff: src/image/SkDataPixelRef.cpp

Issue 68973005: Expand pixelref to return SkImageInfo and rowbytes (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: add SK_SUPPORT_LEGACY_ONLOCKPIXELS so we can land in stages for Chrome 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/image/SkDataPixelRef.cpp
diff --git a/src/image/SkDataPixelRef.cpp b/src/image/SkDataPixelRef.cpp
index 0524243366c16cdf079cd8434dcd10d31500fc54..3b3a9d6b5b4d9a6ec50131f5ce1f5a076c1e62bf 100644
--- a/src/image/SkDataPixelRef.cpp
+++ b/src/image/SkDataPixelRef.cpp
@@ -9,18 +9,30 @@
#include "SkData.h"
#include "SkFlattenableBuffers.h"
-SkDataPixelRef::SkDataPixelRef(SkData* data) : fData(data) {
+SkDataPixelRef::SkDataPixelRef(const SkImageInfo& info,
+ SkData* data, size_t rowBytes)
+ : fInfo(info)
+ , fData(data)
+ , fRB(rowBytes)
+{
fData->ref();
- this->setPreLocked(const_cast<void*>(fData->data()), NULL);
+ this->setPreLocked(info, const_cast<void*>(fData->data()), rowBytes, NULL);
}
SkDataPixelRef::~SkDataPixelRef() {
fData->unref();
}
-void* SkDataPixelRef::onLockPixels(SkColorTable** ct) {
- *ct = NULL;
- return const_cast<void*>(fData->data());
+bool SkDataPixelRef::onGetInfo(SkImageInfo* info) {
+ *info = fInfo;
+ return true;
+}
+
+bool SkDataPixelRef::onNewLockPixels(LockRec* rec) {
+ rec->fPixels = const_cast<void*>(fData->data());
+ rec->fColorTable = NULL;
+ rec->fRowBytes = fRB;
+ return true;
}
void SkDataPixelRef::onUnlockPixels() {
@@ -29,11 +41,17 @@ void SkDataPixelRef::onUnlockPixels() {
void SkDataPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
+
+ fInfo.flatten(buffer);
buffer.writeDataAsByteArray(fData);
+ buffer.write32(fRB);
}
SkDataPixelRef::SkDataPixelRef(SkFlattenableReadBuffer& buffer)
- : INHERITED(buffer, NULL) {
+ : INHERITED(buffer, NULL)
+{
+ fInfo.unflatten(buffer);
fData = buffer.readByteArrayAsData();
- this->setPreLocked(const_cast<void*>(fData->data()), NULL);
+ fRB = buffer.read32();
+ this->setPreLocked(fInfo, const_cast<void*>(fData->data()), fRB, NULL);
}

Powered by Google App Engine
This is Rietveld 408576698