Ensure that streams written using SkFlattenableBuffer's can be read with readByteArra...
authordjsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 23 Jan 2013 13:40:40 +0000 (13:40 +0000)
committerdjsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 23 Jan 2013 13:40:40 +0000 (13:40 +0000)
Review URL: https://codereview.appspot.com/7138063

git-svn-id: http://skia.googlecode.com/svn/trunk@7335 2bbb7eff-a529-9590-31e7-b0007b416f81

src/core/SkOrderedWriteBuffer.cpp

index 7db0312..de26587 100644 (file)
@@ -132,7 +132,12 @@ void SkOrderedWriteBuffer::writePath(const SkPath& path) {
 }
 
 size_t SkOrderedWriteBuffer::writeStream(SkStream* stream, size_t length) {
-    return fWriter.readFromStream(stream, length);
+    fWriter.write32(length);
+    size_t bytesWritten = fWriter.readFromStream(stream, length);
+    if (bytesWritten < length) {
+        fWriter.reservePad(length - bytesWritten);
+    }
+    return bytesWritten;
 }
 
 bool SkOrderedWriteBuffer::writeToStream(SkWStream* stream) {