| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkWriteBuffer.h" | 8 #include "SkWriteBuffer.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkBitmapHeap.h" | 10 #include "SkBitmapHeap.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 67 } |
| 68 | 68 |
| 69 void SkWriteBuffer::write32(int32_t value) { | 69 void SkWriteBuffer::write32(int32_t value) { |
| 70 fWriter.write32(value); | 70 fWriter.write32(value); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void SkWriteBuffer::writeString(const char* value) { | 73 void SkWriteBuffer::writeString(const char* value) { |
| 74 fWriter.writeString(value); | 74 fWriter.writeString(value); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void SkWriteBuffer::writeEncodedString(const void* value, size_t byteLength, | |
| 78 SkPaint::TextEncoding encoding) { | |
| 79 fWriter.writeInt(encoding); | |
| 80 fWriter.writeInt(SkToU32(byteLength)); | |
| 81 fWriter.write(value, byteLength); | |
| 82 } | |
| 83 | |
| 84 | |
| 85 void SkWriteBuffer::writeColor(const SkColor& color) { | 77 void SkWriteBuffer::writeColor(const SkColor& color) { |
| 86 fWriter.write32(color); | 78 fWriter.write32(color); |
| 87 } | 79 } |
| 88 | 80 |
| 89 void SkWriteBuffer::writeColorArray(const SkColor* color, uint32_t count) { | 81 void SkWriteBuffer::writeColorArray(const SkColor* color, uint32_t count) { |
| 90 fWriter.write32(count); | 82 fWriter.write32(count); |
| 91 fWriter.write(color, count * sizeof(SkColor)); | 83 fWriter.write(color, count * sizeof(SkColor)); |
| 92 } | 84 } |
| 93 | 85 |
| 94 void SkWriteBuffer::writePoint(const SkPoint& point) { | 86 void SkWriteBuffer::writePoint(const SkPoint& point) { |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 // make room for the size of the flattened object | 301 // make room for the size of the flattened object |
| 310 (void)fWriter.reserve(sizeof(uint32_t)); | 302 (void)fWriter.reserve(sizeof(uint32_t)); |
| 311 // record the current size, so we can subtract after the object writes. | 303 // record the current size, so we can subtract after the object writes. |
| 312 size_t offset = fWriter.bytesWritten(); | 304 size_t offset = fWriter.bytesWritten(); |
| 313 // now flatten the object | 305 // now flatten the object |
| 314 flattenable->flatten(*this); | 306 flattenable->flatten(*this); |
| 315 size_t objSize = fWriter.bytesWritten() - offset; | 307 size_t objSize = fWriter.bytesWritten() - offset; |
| 316 // record the obj's size | 308 // record the obj's size |
| 317 fWriter.overwriteTAt(offset - sizeof(uint32_t), SkToU32(objSize)); | 309 fWriter.overwriteTAt(offset - sizeof(uint32_t), SkToU32(objSize)); |
| 318 } | 310 } |
| OLD | NEW |