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

Unified Diff: src/core/SkOrderedReadBuffer.cpp

Issue 15713015: Read and write pixel offset when serializing bitmaps. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 7 months 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 | « no previous file | src/core/SkOrderedWriteBuffer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkOrderedReadBuffer.cpp
diff --git a/src/core/SkOrderedReadBuffer.cpp b/src/core/SkOrderedReadBuffer.cpp
index 7f0a14e16be881d12f8e2f8c2a3f1c41eb0a4b37..e8250ddfa3560108a033da2bd838863aeab36b17 100644
--- a/src/core/SkOrderedReadBuffer.cpp
+++ b/src/core/SkOrderedReadBuffer.cpp
@@ -192,10 +192,15 @@ void SkOrderedReadBuffer::readBitmap(SkBitmap* bitmap) {
// The writer stored false, meaning the SkBitmap was not stored in an SkBitmapHeap.
const size_t length = this->readUInt();
if (length > 0) {
- // A non-zero size means the SkBitmap was encoded.
+ // A non-zero size means the SkBitmap was encoded. Read the data and pixel
+ // offset.
const void* data = this->skip(length);
+ const int32_t xOffset = fReader.readS32();
+ const int32_t yOffset = fReader.readS32();
if (fBitmapDecoder != NULL && fBitmapDecoder(data, length, bitmap)) {
if (bitmap->width() == width && bitmap->height() == height) {
+ // If the width and height match, there should be no offset.
+ SkASSERT(0 == xOffset && 0 == yOffset);
return;
}
@@ -204,16 +209,8 @@ void SkOrderedReadBuffer::readBitmap(SkBitmap* bitmap) {
// the encoded width and height.
SkASSERT(width <= bitmap->width() && height <= bitmap->height());
- // FIXME: Once the writer is changed to record the (x,y) offset,
- // they will be used to store the correct portion of the picture.
SkBitmap subsetBm;
-#ifdef BUMP_PICTURE_VERSION
- int32_t x = fReader.readS32();
- int32_t y = fReader.readS32();
- SkIRect subset = SkIRect::MakeXYWH(x, y, width, height);
-#else
- SkIRect subset = SkIRect::MakeWH(width, height);
-#endif
+ SkIRect subset = SkIRect::MakeXYWH(xOffset, yOffset, width, height);
if (bitmap->extractSubset(&subsetBm, subset)) {
bitmap->swap(subsetBm);
return;
« no previous file with comments | « no previous file | src/core/SkOrderedWriteBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698