Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 9 #include "SkErrorInternals.h" | 9 #include "SkErrorInternals.h" |
| 10 #include "SkImage.h" | 10 #include "SkImage.h" |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 if (0 == index) { | 341 if (0 == index) { |
| 342 return nullptr; // writer failed to give us the flattenable | 342 return nullptr; // writer failed to give us the flattenable |
| 343 } | 343 } |
| 344 index -= 1; // we stored the index-base-1 | 344 index -= 1; // we stored the index-base-1 |
| 345 if ((unsigned)index >= (unsigned)fFactoryCount) { | 345 if ((unsigned)index >= (unsigned)fFactoryCount) { |
| 346 this->validate(false); | 346 this->validate(false); |
| 347 return nullptr; | 347 return nullptr; |
| 348 } | 348 } |
| 349 factory = fFactoryArray[index]; | 349 factory = fFactoryArray[index]; |
| 350 } else { | 350 } else { |
| 351 factory = (SkFlattenable::Factory)readFunctionPtr(); | 351 SkString name; |
| 352 if (nullptr == factory) { | 352 this->readString(&name); |
| 353 return nullptr; // writer failed to give us the flattenable | 353 |
| 354 // Check if a custom Factory has been specified for this flattenable. | |
|
reed1
2016/04/11 15:07:48
Is this order (checking custom first) important? D
msarett
2016/04/19 18:03:50
Yes I think we should check custom first. I've th
| |
| 355 factory = getCustomFactory(name.c_str()); | |
| 356 if (!factory) { | |
| 357 factory = SkFlattenable::NameToFactory(name.c_str()); | |
| 358 if (!factory) { | |
| 359 return nullptr; // writer failed to give us the flattenable | |
| 360 } | |
| 354 } | 361 } |
| 355 } | 362 } |
| 356 | 363 |
| 357 // if we get here, factory may still be null, but if that is the case, the | 364 // if we get here, factory may still be null, but if that is the case, the |
| 358 // failure was ours, not the writer. | 365 // failure was ours, not the writer. |
| 359 sk_sp<SkFlattenable> obj; | 366 sk_sp<SkFlattenable> obj; |
| 360 uint32_t sizeRecorded = fReader.readU32(); | 367 uint32_t sizeRecorded = fReader.readU32(); |
| 361 if (factory) { | 368 if (factory) { |
| 362 size_t offset = fReader.offset(); | 369 size_t offset = fReader.offset(); |
| 363 obj = (*factory)(*this); | 370 obj = (*factory)(*this); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 384 return; | 391 return; |
| 385 } | 392 } |
| 386 } else { | 393 } else { |
| 387 if (nullptr == this->readFunctionPtr()) { | 394 if (nullptr == this->readFunctionPtr()) { |
| 388 return; | 395 return; |
| 389 } | 396 } |
| 390 } | 397 } |
| 391 uint32_t sizeRecorded = fReader.readU32(); | 398 uint32_t sizeRecorded = fReader.readU32(); |
| 392 fReader.skip(sizeRecorded); | 399 fReader.skip(sizeRecorded); |
| 393 } | 400 } |
| OLD | NEW |