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

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

Issue 2290653002: change readTypeface to return sk_sp (Closed)
Patch Set: Created 4 years, 3 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.h ('k') | no next file » | 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 2013 Google Inc. 2 * Copyright 2013 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkErrorInternals.h" 9 #include "SkErrorInternals.h"
10 #include "SkValidatingReadBuffer.h" 10 #include "SkValidatingReadBuffer.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 bool SkValidatingReadBuffer::readScalarArray(SkScalar* values, size_t size) { 203 bool SkValidatingReadBuffer::readScalarArray(SkScalar* values, size_t size) {
204 return readArray(values, size, sizeof(SkScalar)); 204 return readArray(values, size, sizeof(SkScalar));
205 } 205 }
206 206
207 uint32_t SkValidatingReadBuffer::getArrayCount() { 207 uint32_t SkValidatingReadBuffer::getArrayCount() {
208 const size_t inc = sizeof(uint32_t); 208 const size_t inc = sizeof(uint32_t);
209 fError = fError || !IsPtrAlign4(fReader.peek()) || !fReader.isAvailable(inc) ; 209 fError = fError || !IsPtrAlign4(fReader.peek()) || !fReader.isAvailable(inc) ;
210 return fError ? 0 : *(uint32_t*)fReader.peek(); 210 return fError ? 0 : *(uint32_t*)fReader.peek();
211 } 211 }
212 212
213 SkTypeface* SkValidatingReadBuffer::readTypeface() {
214 SkASSERT(false);
215 // TODO: Implement this (securely) when needed
216 return nullptr;
217 }
218
219 bool SkValidatingReadBuffer::validateAvailable(size_t size) { 213 bool SkValidatingReadBuffer::validateAvailable(size_t size) {
220 return this->validate((size <= SK_MaxU32) && fReader.isAvailable(static_cast <uint32_t>(size))); 214 return this->validate((size <= SK_MaxU32) && fReader.isAvailable(static_cast <uint32_t>(size)));
221 } 215 }
222 216
223 SkFlattenable* SkValidatingReadBuffer::readFlattenable(SkFlattenable::Type type) { 217 SkFlattenable* SkValidatingReadBuffer::readFlattenable(SkFlattenable::Type type) {
224 // The validating read buffer always uses strings and string-indices for unf lattening. 218 // The validating read buffer always uses strings and string-indices for unf lattening.
225 SkASSERT(0 == this->factoryCount()); 219 SkASSERT(0 == this->factoryCount());
226 220
227 uint8_t firstByte = this->peekByte(); 221 uint8_t firstByte = this->peekByte();
228 if (fError) { 222 if (fError) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 size_t offset = fReader.offset(); 270 size_t offset = fReader.offset();
277 obj = (*factory)(*this); 271 obj = (*factory)(*this);
278 // check that we read the amount we expected 272 // check that we read the amount we expected
279 size_t sizeRead = fReader.offset() - offset; 273 size_t sizeRead = fReader.offset() - offset;
280 this->validate(sizeRecorded == sizeRead); 274 this->validate(sizeRecorded == sizeRead);
281 if (fError) { 275 if (fError) {
282 obj = nullptr; 276 obj = nullptr;
283 } 277 }
284 return obj.release(); 278 return obj.release();
285 } 279 }
OLDNEW
« no previous file with comments | « src/core/SkValidatingReadBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698