diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-12-11 18:04:56 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-12-11 18:04:56 +0000 |
commit | 6965a0a2df9d35cd0a25e1738f0388272d03f399 (patch) | |
tree | c7831828095cbd2ea1efe9b44ab876f1aa374f80 /src/image/SkDataPixelRef.cpp | |
parent | 3a6143d91f06d01f07b3b0e8adfa703a574d2bec (diff) |
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.""""
BUG=
Review URL: https://codereview.chromium.org/110503003
git-svn-id: http://skia.googlecode.com/svn/trunk@12622 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/image/SkDataPixelRef.cpp')
-rw-r--r-- | src/image/SkDataPixelRef.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/image/SkDataPixelRef.cpp b/src/image/SkDataPixelRef.cpp index 7897bf9315..875f933b9c 100644 --- a/src/image/SkDataPixelRef.cpp +++ b/src/image/SkDataPixelRef.cpp @@ -9,18 +9,25 @@ #include "SkData.h" #include "SkFlattenableBuffers.h" -SkDataPixelRef::SkDataPixelRef(SkData* data) : fData(data) { +SkDataPixelRef::SkDataPixelRef(const SkImageInfo& info, + SkData* data, size_t rowBytes) + : INHERITED(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) { - *ct = NULL; - return const_cast<void*>(fData->data()); +bool SkDataPixelRef::onNewLockPixels(LockRec* rec) { + rec->fPixels = const_cast<void*>(fData->data()); + rec->fColorTable = NULL; + rec->fRowBytes = fRB; + return true; } void SkDataPixelRef::onUnlockPixels() { @@ -33,11 +40,15 @@ size_t SkDataPixelRef::getAllocatedSizeInBytes() const { void SkDataPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); + buffer.writeDataAsByteArray(fData); + buffer.write32(fRB); } SkDataPixelRef::SkDataPixelRef(SkFlattenableReadBuffer& buffer) - : INHERITED(buffer, NULL) { + : 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); } |