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

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: Created 7 years, 1 month 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..74cd5a414f96c8a379ae06f141fe44befdc72905 100644
--- a/src/image/SkDataPixelRef.cpp
+++ b/src/image/SkDataPixelRef.cpp
@@ -9,16 +9,24 @@
#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(const_cast<void*>(fData->data()), rowBytes, NULL);
}
SkDataPixelRef::~SkDataPixelRef() {
fData->unref();
}
-void* SkDataPixelRef::onLockPixels(SkColorTable** ct) {
+void* SkDataPixelRef::onLockPixels(SkImageInfo* info, size_t* rowBytes,
+ SkColorTable** ct) {
+ *info = fInfo;
+ *rowBytes = fRB;
*ct = NULL;
return const_cast<void*>(fData->data());
}
@@ -29,11 +37,14 @@ void SkDataPixelRef::onUnlockPixels() {
void SkDataPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const {
scroggo 2013/11/19 18:17:09 We need to flatten (and unflatten) fInfo.
reed1 2013/11/20 20:56:56 doh!
this->INHERITED::flatten(buffer);
+
buffer.writeDataAsByteArray(fData);
+ buffer.write32(fRB);
}
SkDataPixelRef::SkDataPixelRef(SkFlattenableReadBuffer& buffer)
: INHERITED(buffer, NULL) {
fData = buffer.readByteArrayAsData();
- this->setPreLocked(const_cast<void*>(fData->data()), NULL);
+ fRB = buffer.read32();
+ this->setPreLocked(const_cast<void*>(fData->data()), fRB, NULL);
}

Powered by Google App Engine
This is Rietveld 408576698