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 "SkData.h" | 10 #include "SkData.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 | 71 |
72 void SkBinaryWriteBuffer::writeColor(SkColor color) { | 72 void SkBinaryWriteBuffer::writeColor(SkColor color) { |
73 fWriter.write32(color); | 73 fWriter.write32(color); |
74 } | 74 } |
75 | 75 |
76 void SkBinaryWriteBuffer::writeColorArray(const SkColor* color, uint32_t count) { | 76 void SkBinaryWriteBuffer::writeColorArray(const SkColor* color, uint32_t count) { |
77 fWriter.write32(count); | 77 fWriter.write32(count); |
78 fWriter.write(color, count * sizeof(SkColor)); | 78 fWriter.write(color, count * sizeof(SkColor)); |
79 } | 79 } |
80 | 80 |
81 static_assert(SK_SCALAR_IS_FLOAT, "Color4f serialization needs updating"); | |
82 void SkBinaryWriteBuffer::writeColor4f(const SkColor4f& color) { | |
reed1
2016/09/13 23:18:07
I've bee using just write to make these simpler/fa
| |
83 fWriter.writeScalar(color.fR); | |
84 fWriter.writeScalar(color.fG); | |
85 fWriter.writeScalar(color.fB); | |
86 fWriter.writeScalar(color.fA); | |
87 } | |
88 | |
89 void SkBinaryWriteBuffer::writeColor4fArray(const SkColor4f* color, uint32_t cou nt) { | |
90 fWriter.write32(count); | |
91 fWriter.write(color, count * sizeof(SkColor4f)); | |
92 } | |
93 | |
81 void SkBinaryWriteBuffer::writePoint(const SkPoint& point) { | 94 void SkBinaryWriteBuffer::writePoint(const SkPoint& point) { |
82 fWriter.writeScalar(point.fX); | 95 fWriter.writeScalar(point.fX); |
83 fWriter.writeScalar(point.fY); | 96 fWriter.writeScalar(point.fY); |
84 } | 97 } |
85 | 98 |
86 void SkBinaryWriteBuffer::writePointArray(const SkPoint* point, uint32_t count) { | 99 void SkBinaryWriteBuffer::writePointArray(const SkPoint* point, uint32_t count) { |
87 fWriter.write32(count); | 100 fWriter.write32(count); |
88 fWriter.write(point, count * sizeof(SkPoint)); | 101 fWriter.write(point, count * sizeof(SkPoint)); |
89 } | 102 } |
90 | 103 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 // make room for the size of the flattened object | 299 // make room for the size of the flattened object |
287 (void)fWriter.reserve(sizeof(uint32_t)); | 300 (void)fWriter.reserve(sizeof(uint32_t)); |
288 // record the current size, so we can subtract after the object writes. | 301 // record the current size, so we can subtract after the object writes. |
289 size_t offset = fWriter.bytesWritten(); | 302 size_t offset = fWriter.bytesWritten(); |
290 // now flatten the object | 303 // now flatten the object |
291 flattenable->flatten(*this); | 304 flattenable->flatten(*this); |
292 size_t objSize = fWriter.bytesWritten() - offset; | 305 size_t objSize = fWriter.bytesWritten() - offset; |
293 // record the obj's size | 306 // record the obj's size |
294 fWriter.overwriteTAt(offset - sizeof(uint32_t), SkToU32(objSize)); | 307 fWriter.overwriteTAt(offset - sizeof(uint32_t), SkToU32(objSize)); |
295 } | 308 } |
OLD | NEW |