Chromium Code Reviews| Index: src/core/SkOrderedWriteBuffer.cpp |
| diff --git a/src/core/SkOrderedWriteBuffer.cpp b/src/core/SkOrderedWriteBuffer.cpp |
| index e458bfe597595c584b9e9d747a9bd6e6f4631b2d..d4de7a0b76f760b415b0d7b09b6f7c57c42f6a6b 100644 |
| --- a/src/core/SkOrderedWriteBuffer.cpp |
| +++ b/src/core/SkOrderedWriteBuffer.cpp |
| @@ -145,6 +145,10 @@ bool SkOrderedWriteBuffer::writeToStream(SkWStream* stream) { |
| } |
| void SkOrderedWriteBuffer::writeBitmap(const SkBitmap& bitmap) { |
| + // Record the width and height. |
| + this->writeInt(bitmap.width()); |
| + this->writeInt(bitmap.height()); |
| + |
| // Record information about the bitmap in one of three ways, in order of priority: |
| // 1. If there is an SkBitmapHeap, store it in the heap. The client can avoid serializing the |
| // bitmap entirely or serialize it later as desired. |
| @@ -159,6 +163,9 @@ void SkOrderedWriteBuffer::writeBitmap(const SkBitmap& bitmap) { |
| SkASSERT(NULL == fBitmapEncoder); |
| // Bitmap was not encoded. Record a zero, implying that the reader need not decode. |
| this->writeUInt(0); |
|
djsollen
2013/04/25 19:20:36
Per our discussion, since we are updating the pict
scroggo
2013/04/25 20:19:13
Done.
|
| + // Record a bool value of true, to state that an SkBitmapHeap was used to store the |
| + // SkBitmap. A value of false would have been written if the SkBitmapHeap was not used. |
| + this->writeBool(true); |
| int32_t slot = fBitmapHeap->insert(bitmap); |
| fWriter.write32(slot); |
| // crbug.com/155875 |
| @@ -180,7 +187,7 @@ void SkOrderedWriteBuffer::writeBitmap(const SkBitmap& bitmap) { |
| // Write the length to indicate that the bitmap was encoded successfully, followed |
| // by the actual data. This must match the case where fBitmapEncoder is used so the |
| // reader need not know the difference. |
| - this->writeUInt(data->size()); |
| + this->writeUInt(SkToU32(data->size())); |
| fWriter.writePad(data->data(), data->size()); |
| encoded = true; |
| } |
| @@ -194,7 +201,7 @@ void SkOrderedWriteBuffer::writeBitmap(const SkBitmap& bitmap) { |
| // by the actual data. This must match the case where the original data is used so the |
| // reader need not know the difference. |
| size_t length = stream.getOffset(); |
| - this->writeUInt(length); |
| + this->writeUInt(SkToU32(length)); |
| if (stream.read(fWriter.reservePad(length), 0, length)) { |
| encoded = true; |
| } else { |
| @@ -203,13 +210,11 @@ void SkOrderedWriteBuffer::writeBitmap(const SkBitmap& bitmap) { |
| } |
| } |
| } |
| - if (encoded) { |
| - // Write the width and height in case the reader does not have a decoder. |
| - this->writeInt(bitmap.width()); |
| - this->writeInt(bitmap.height()); |
| - } else { |
| + if (!encoded) { |
| // Bitmap was not encoded. Record a zero, implying that the reader need not decode. |
| this->writeUInt(0); |
| + // An SkBitmapHeap was not used. Record a boolean value of false. |
| + this->writeBool(false); |
| bitmap.flatten(*this); |
| } |
| } |