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

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

Issue 37803002: Adding size parameter to read array functions (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Added dox in SkFlattenableBuffers.h Created 7 years, 1 month 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 "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkErrorInternals.h" 10 #include "SkErrorInternals.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 130 }
131 131
132 void SkOrderedReadBuffer::readRegion(SkRegion* region) { 132 void SkOrderedReadBuffer::readRegion(SkRegion* region) {
133 fReader.readRegion(region); 133 fReader.readRegion(region);
134 } 134 }
135 135
136 void SkOrderedReadBuffer::readPath(SkPath* path) { 136 void SkOrderedReadBuffer::readPath(SkPath* path) {
137 fReader.readPath(path); 137 fReader.readPath(path);
138 } 138 }
139 139
140 uint32_t SkOrderedReadBuffer::readByteArray(void* value) { 140 uint32_t SkOrderedReadBuffer::readByteArray(void* value, uint32_t) {
141 const uint32_t length = fReader.readU32(); 141 const uint32_t length = fReader.readU32();
142 memcpy(value, fReader.skip(SkAlign4(length)), length); 142 memcpy(value, fReader.skip(SkAlign4(length)), length);
143 return length; 143 return length;
144 } 144 }
145 145
146 uint32_t SkOrderedReadBuffer::readColorArray(SkColor* colors) { 146 uint32_t SkOrderedReadBuffer::readColorArray(SkColor* colors, uint32_t) {
147 const uint32_t count = fReader.readU32(); 147 const uint32_t count = fReader.readU32();
148 const uint32_t byteLength = count * sizeof(SkColor); 148 const uint32_t byteLength = count * sizeof(SkColor);
149 memcpy(colors, fReader.skip(SkAlign4(byteLength)), byteLength); 149 memcpy(colors, fReader.skip(SkAlign4(byteLength)), byteLength);
150 return count; 150 return count;
151 } 151 }
152 152
153 uint32_t SkOrderedReadBuffer::readIntArray(int32_t* values) { 153 uint32_t SkOrderedReadBuffer::readIntArray(int32_t* values, uint32_t) {
154 const uint32_t count = fReader.readU32(); 154 const uint32_t count = fReader.readU32();
155 const uint32_t byteLength = count * sizeof(int32_t); 155 const uint32_t byteLength = count * sizeof(int32_t);
156 memcpy(values, fReader.skip(SkAlign4(byteLength)), byteLength); 156 memcpy(values, fReader.skip(SkAlign4(byteLength)), byteLength);
157 return count; 157 return count;
158 } 158 }
159 159
160 uint32_t SkOrderedReadBuffer::readPointArray(SkPoint* points) { 160 uint32_t SkOrderedReadBuffer::readPointArray(SkPoint* points, uint32_t) {
161 const uint32_t count = fReader.readU32(); 161 const uint32_t count = fReader.readU32();
162 const uint32_t byteLength = count * sizeof(SkPoint); 162 const uint32_t byteLength = count * sizeof(SkPoint);
163 memcpy(points, fReader.skip(SkAlign4(byteLength)), byteLength); 163 memcpy(points, fReader.skip(SkAlign4(byteLength)), byteLength);
164 return count; 164 return count;
165 } 165 }
166 166
167 uint32_t SkOrderedReadBuffer::readScalarArray(SkScalar* values) { 167 uint32_t SkOrderedReadBuffer::readScalarArray(SkScalar* values, uint32_t) {
168 const uint32_t count = fReader.readU32(); 168 const uint32_t count = fReader.readU32();
169 const uint32_t byteLength = count * sizeof(SkScalar); 169 const uint32_t byteLength = count * sizeof(SkScalar);
170 memcpy(values, fReader.skip(SkAlign4(byteLength)), byteLength); 170 memcpy(values, fReader.skip(SkAlign4(byteLength)), byteLength);
171 return count; 171 return count;
172 } 172 }
173 173
174 uint32_t SkOrderedReadBuffer::getArrayCount() { 174 uint32_t SkOrderedReadBuffer::getArrayCount() {
175 return *(uint32_t*)fReader.peek(); 175 return *(uint32_t*)fReader.peek();
176 } 176 }
177 177
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 if (sizeRecorded != sizeRead) { 309 if (sizeRecorded != sizeRead) {
310 // we could try to fix up the offset... 310 // we could try to fix up the offset...
311 sk_throw(); 311 sk_throw();
312 } 312 }
313 } else { 313 } else {
314 // we must skip the remaining data 314 // we must skip the remaining data
315 fReader.skip(sizeRecorded); 315 fReader.skip(sizeRecorded);
316 } 316 }
317 return obj; 317 return obj;
318 } 318 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698