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

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

Issue 1853383002: Revert of Delete SkFlattenable::Type (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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') | src/utils/SkBitmapSourceDeserializer.h » ('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 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 SkTypeface* SkValidatingReadBuffer::readTypeface() { 215 SkTypeface* SkValidatingReadBuffer::readTypeface() {
216 SkASSERT(false); 216 SkASSERT(false);
217 // TODO: Implement this (securely) when needed 217 // TODO: Implement this (securely) when needed
218 return nullptr; 218 return nullptr;
219 } 219 }
220 220
221 bool SkValidatingReadBuffer::validateAvailable(size_t size) { 221 bool SkValidatingReadBuffer::validateAvailable(size_t size) {
222 return this->validate((size <= SK_MaxU32) && fReader.isAvailable(static_cast <uint32_t>(size))); 222 return this->validate((size <= SK_MaxU32) && fReader.isAvailable(static_cast <uint32_t>(size)));
223 } 223 }
224 224
225 SkFlattenable* SkValidatingReadBuffer::readFlattenable() { 225 SkFlattenable* SkValidatingReadBuffer::readFlattenable(SkFlattenable::Type type) {
226 SkString name; 226 SkString name;
227 this->readString(&name); 227 this->readString(&name);
228 if (fError) { 228 if (fError) {
229 return nullptr; 229 return nullptr;
230 } 230 }
231 231
232 // Is this the type we wanted ?
232 const char* cname = name.c_str(); 233 const char* cname = name.c_str();
234 SkFlattenable::Type baseType;
235 if (!SkFlattenable::NameToType(cname, &baseType) || (baseType != type)) {
236 return nullptr;
237 }
238
233 SkFlattenable::Factory factory = SkFlattenable::NameToFactory(cname); 239 SkFlattenable::Factory factory = SkFlattenable::NameToFactory(cname);
234 if (nullptr == factory) { 240 if (nullptr == factory) {
235 return nullptr; // writer failed to give us the flattenable 241 return nullptr; // writer failed to give us the flattenable
236 } 242 }
237 243
238 // if we get here, factory may still be null, but if that is the case, the 244 // if we get here, factory may still be null, but if that is the case, the
239 // failure was ours, not the writer. 245 // failure was ours, not the writer.
240 sk_sp<SkFlattenable> obj; 246 sk_sp<SkFlattenable> obj;
241 uint32_t sizeRecorded = this->readUInt(); 247 uint32_t sizeRecorded = this->readUInt();
242 if (factory) { 248 if (factory) {
(...skipping 15 matching lines...) Expand all
258 264
259 void SkValidatingReadBuffer::skipFlattenable() { 265 void SkValidatingReadBuffer::skipFlattenable() {
260 SkString name; 266 SkString name;
261 this->readString(&name); 267 this->readString(&name);
262 if (fError) { 268 if (fError) {
263 return; 269 return;
264 } 270 }
265 uint32_t sizeRecorded = this->readUInt(); 271 uint32_t sizeRecorded = this->readUInt();
266 this->skip(sizeRecorded); 272 this->skip(sizeRecorded);
267 } 273 }
OLDNEW
« no previous file with comments | « src/core/SkValidatingReadBuffer.h ('k') | src/utils/SkBitmapSourceDeserializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698