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

Side by Side Diff: src/core/SkWriteBuffer.cpp

Issue 2334123003: Add SkColor4f serialization (Closed)
Patch Set: Switched to memcpy, rebased Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « src/core/SkValidatingReadBuffer.cpp ('k') | tests/SerializationTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 void SkBinaryWriteBuffer::writeColor4f(const SkColor4f& color) {
82 fWriter.write(&color, sizeof(SkColor4f));
83 }
84
85 void SkBinaryWriteBuffer::writeColor4fArray(const SkColor4f* color, uint32_t cou nt) {
86 fWriter.write32(count);
87 fWriter.write(color, count * sizeof(SkColor4f));
88 }
89
81 void SkBinaryWriteBuffer::writePoint(const SkPoint& point) { 90 void SkBinaryWriteBuffer::writePoint(const SkPoint& point) {
82 fWriter.writeScalar(point.fX); 91 fWriter.writeScalar(point.fX);
83 fWriter.writeScalar(point.fY); 92 fWriter.writeScalar(point.fY);
84 } 93 }
85 94
86 void SkBinaryWriteBuffer::writePointArray(const SkPoint* point, uint32_t count) { 95 void SkBinaryWriteBuffer::writePointArray(const SkPoint* point, uint32_t count) {
87 fWriter.write32(count); 96 fWriter.write32(count);
88 fWriter.write(point, count * sizeof(SkPoint)); 97 fWriter.write(point, count * sizeof(SkPoint));
89 } 98 }
90 99
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 // make room for the size of the flattened object 295 // make room for the size of the flattened object
287 (void)fWriter.reserve(sizeof(uint32_t)); 296 (void)fWriter.reserve(sizeof(uint32_t));
288 // record the current size, so we can subtract after the object writes. 297 // record the current size, so we can subtract after the object writes.
289 size_t offset = fWriter.bytesWritten(); 298 size_t offset = fWriter.bytesWritten();
290 // now flatten the object 299 // now flatten the object
291 flattenable->flatten(*this); 300 flattenable->flatten(*this);
292 size_t objSize = fWriter.bytesWritten() - offset; 301 size_t objSize = fWriter.bytesWritten() - offset;
293 // record the obj's size 302 // record the obj's size
294 fWriter.overwriteTAt(offset - sizeof(uint32_t), SkToU32(objSize)); 303 fWriter.overwriteTAt(offset - sizeof(uint32_t), SkToU32(objSize));
295 } 304 }
OLDNEW
« no previous file with comments | « src/core/SkValidatingReadBuffer.cpp ('k') | tests/SerializationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698