OLD | NEW |
---|---|
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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
281 factory = fFactoryArray[index]; | 281 factory = fFactoryArray[index]; |
282 } else if (fFactoryTDArray) { | 282 } else if (fFactoryTDArray) { |
283 int32_t index = fReader.readU32(); | 283 int32_t index = fReader.readU32(); |
284 if (0 == index) { | 284 if (0 == index) { |
285 return NULL; // writer failed to give us the flattenable | 285 return NULL; // writer failed to give us the flattenable |
286 } | 286 } |
287 index -= 1; // we stored the index-base-1 | 287 index -= 1; // we stored the index-base-1 |
288 factory = (*fFactoryTDArray)[index]; | 288 factory = (*fFactoryTDArray)[index]; |
289 } else { | 289 } else { |
290 factory = (SkFlattenable::Factory)readFunctionPtr(); | 290 factory = (SkFlattenable::Factory)readFunctionPtr(); |
291 if (NULL == factory) { | 291 if (NULL == factory || NULL == SkFlattenable::FactoryToName(factory)) { |
sugoi
2013/08/16 20:58:46
I quickly realized that using SkFlattenable::Facto
| |
292 return NULL; // writer failed to give us the flattenable | 292 return NULL; // writer failed to give us a valid factory |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
sugoi
2013/08/13 15:20:26
At this point, if possible, I'd like to be able to
| |
296 // if we get here, factory may still be null, but if that is the case, the | 296 // if we get here, factory may still be null, but if that is the case, the |
297 // failure was ours, not the writer. | 297 // failure was ours, not the writer. |
298 SkFlattenable* obj = NULL; | 298 SkFlattenable* obj = NULL; |
299 uint32_t sizeRecorded = fReader.readU32(); | 299 uint32_t sizeRecorded = fReader.readU32(); |
300 if (factory) { | 300 if (factory) { |
301 uint32_t offset = fReader.offset(); | 301 uint32_t offset = fReader.offset(); |
302 obj = (*factory)(*this); | 302 obj = (*factory)(*this); |
303 // check that we read the amount we expected | 303 // check that we read the amount we expected |
304 uint32_t sizeRead = fReader.offset() - offset; | 304 uint32_t sizeRead = fReader.offset() - offset; |
305 if (sizeRecorded != sizeRead) { | 305 if (sizeRecorded != sizeRead) { |
306 // we could try to fix up the offset... | 306 // we could try to fix up the offset... |
307 sk_throw(); | 307 sk_throw(); |
308 } | 308 } |
309 } else { | 309 } else { |
310 // we must skip the remaining data | 310 // we must skip the remaining data |
311 fReader.skip(sizeRecorded); | 311 fReader.skip(sizeRecorded); |
312 } | 312 } |
313 return obj; | 313 return obj; |
314 } | 314 } |
OLD | NEW |