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

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

Issue 130913018: Templetized SkWriter32 readTAt() & overwriteTAt() (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Win build fix Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkWriteBuffer.h" 9 #include "SkWriteBuffer.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 void SkWriteBuffer::writeBool(bool value) { 48 void SkWriteBuffer::writeBool(bool value) {
49 fWriter.writeBool(value); 49 fWriter.writeBool(value);
50 } 50 }
51 51
52 void SkWriteBuffer::writeFixed(SkFixed value) { 52 void SkWriteBuffer::writeFixed(SkFixed value) {
53 fWriter.write32(value); 53 fWriter.write32(value);
54 } 54 }
55 55
56 void SkWriteBuffer::writeScalar(SkScalar value) { 56 void SkWriteBuffer::writeScalar(SkScalar value) {
57 fWriter.writeScalar(value); 57 fWriter.writeT<SkScalar>(value);
58 } 58 }
59 59
60 void SkWriteBuffer::writeScalarArray(const SkScalar* value, uint32_t count) { 60 void SkWriteBuffer::writeScalarArray(const SkScalar* value, uint32_t count) {
61 fWriter.write32(count); 61 fWriter.write32(count);
62 fWriter.write(value, count * sizeof(SkScalar)); 62 fWriter.write(value, count * sizeof(SkScalar));
63 } 63 }
64 64
65 void SkWriteBuffer::writeInt(int32_t value) { 65 void SkWriteBuffer::writeInt(int32_t value) {
66 fWriter.write32(value); 66 fWriter.write32(value);
67 } 67 }
(...skipping 26 matching lines...) Expand all
94 void SkWriteBuffer::writeColor(const SkColor& color) { 94 void SkWriteBuffer::writeColor(const SkColor& color) {
95 fWriter.write32(color); 95 fWriter.write32(color);
96 } 96 }
97 97
98 void SkWriteBuffer::writeColorArray(const SkColor* color, uint32_t count) { 98 void SkWriteBuffer::writeColorArray(const SkColor* color, uint32_t count) {
99 fWriter.write32(count); 99 fWriter.write32(count);
100 fWriter.write(color, count * sizeof(SkColor)); 100 fWriter.write(color, count * sizeof(SkColor));
101 } 101 }
102 102
103 void SkWriteBuffer::writePoint(const SkPoint& point) { 103 void SkWriteBuffer::writePoint(const SkPoint& point) {
104 fWriter.writeScalar(point.fX); 104 fWriter.writeT<SkScalar>(point.fX);
105 fWriter.writeScalar(point.fY); 105 fWriter.writeT<SkScalar>(point.fY);
106 } 106 }
107 107
108 void SkWriteBuffer::writePointArray(const SkPoint* point, uint32_t count) { 108 void SkWriteBuffer::writePointArray(const SkPoint* point, uint32_t count) {
109 fWriter.write32(count); 109 fWriter.write32(count);
110 fWriter.write(point, count * sizeof(SkPoint)); 110 fWriter.write(point, count * sizeof(SkPoint));
111 } 111 }
112 112
113 void SkWriteBuffer::writeMatrix(const SkMatrix& matrix) { 113 void SkWriteBuffer::writeMatrix(const SkMatrix& matrix) {
114 fWriter.writeMatrix(matrix); 114 fWriter.writeMatrix(matrix);
115 } 115 }
116 116
117 void SkWriteBuffer::writeIRect(const SkIRect& rect) { 117 void SkWriteBuffer::writeIRect(const SkIRect& rect) {
118 fWriter.write(&rect, sizeof(SkIRect)); 118 fWriter.write(&rect, sizeof(SkIRect));
119 } 119 }
120 120
121 void SkWriteBuffer::writeRect(const SkRect& rect) { 121 void SkWriteBuffer::writeRect(const SkRect& rect) {
122 fWriter.writeRect(rect); 122 fWriter.writeT<SkRect>(rect);
123 } 123 }
124 124
125 void SkWriteBuffer::writeRegion(const SkRegion& region) { 125 void SkWriteBuffer::writeRegion(const SkRegion& region) {
126 fWriter.writeRegion(region); 126 fWriter.writeRegion(region);
127 } 127 }
128 128
129 void SkWriteBuffer::writePath(const SkPath& path) { 129 void SkWriteBuffer::writePath(const SkPath& path) {
130 fWriter.writePath(path); 130 fWriter.writePath(path);
131 } 131 }
132 132
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 } 314 }
315 315
316 // make room for the size of the flattened object 316 // make room for the size of the flattened object
317 (void)fWriter.reserve(sizeof(uint32_t)); 317 (void)fWriter.reserve(sizeof(uint32_t));
318 // record the current size, so we can subtract after the object writes. 318 // record the current size, so we can subtract after the object writes.
319 size_t offset = fWriter.bytesWritten(); 319 size_t offset = fWriter.bytesWritten();
320 // now flatten the object 320 // now flatten the object
321 flattenable->flatten(*this); 321 flattenable->flatten(*this);
322 size_t objSize = fWriter.bytesWritten() - offset; 322 size_t objSize = fWriter.bytesWritten() - offset;
323 // record the obj's size 323 // record the obj's size
324 fWriter.write32At(offset - sizeof(uint32_t), SkToU32(objSize)); 324 fWriter.writeTAt<uint32_t>(offset - sizeof(uint32_t), SkToU32(objSize));
325 } 325 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698