OLD | NEW |
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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 SkFlattenable::Factory factory = SkFlattenable::NameToFactory(cname); | 249 SkFlattenable::Factory factory = SkFlattenable::NameToFactory(cname); |
250 if (NULL == factory) { | 250 if (NULL == factory) { |
251 return NULL; // writer failed to give us the flattenable | 251 return NULL; // writer failed to give us the flattenable |
252 } | 252 } |
253 | 253 |
254 // if we get here, factory may still be null, but if that is the case, the | 254 // if we get here, factory may still be null, but if that is the case, the |
255 // failure was ours, not the writer. | 255 // failure was ours, not the writer. |
256 SkFlattenable* obj = NULL; | 256 SkFlattenable* obj = NULL; |
257 uint32_t sizeRecorded = this->readUInt(); | 257 uint32_t sizeRecorded = this->readUInt(); |
258 if (factory) { | 258 if (factory) { |
259 uint32_t offset = fReader.offset(); | 259 size_t offset = fReader.offset(); |
260 obj = (*factory)(*this); | 260 obj = (*factory)(*this); |
261 // check that we read the amount we expected | 261 // check that we read the amount we expected |
262 uint32_t sizeRead = fReader.offset() - offset; | 262 size_t sizeRead = fReader.offset() - offset; |
263 this->validate(sizeRecorded == sizeRead); | 263 this->validate(sizeRecorded == sizeRead); |
264 if (fError) { | 264 if (fError) { |
265 // we could try to fix up the offset... | 265 // we could try to fix up the offset... |
266 delete obj; | 266 delete obj; |
267 obj = NULL; | 267 obj = NULL; |
268 } | 268 } |
269 } else { | 269 } else { |
270 // we must skip the remaining data | 270 // we must skip the remaining data |
271 this->skip(sizeRecorded); | 271 this->skip(sizeRecorded); |
272 SkASSERT(false); | 272 SkASSERT(false); |
273 } | 273 } |
274 return obj; | 274 return obj; |
275 } | 275 } |
OLD | NEW |