| 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 fFlattenableDict.set(fFlattenableDict.count() + 1, name); | 241 fFlattenableDict.set(fFlattenableDict.count() + 1, name); |
| 242 } else { | 242 } else { |
| 243 // Read the index. We are guaranteed that the first byte | 243 // Read the index. We are guaranteed that the first byte |
| 244 // is zeroed, so we must shift down a byte. | 244 // is zeroed, so we must shift down a byte. |
| 245 uint32_t index = fReader.readU32() >> 8; | 245 uint32_t index = fReader.readU32() >> 8; |
| 246 if (0 == index) { | 246 if (0 == index) { |
| 247 return nullptr; // writer failed to give us the flattenable | 247 return nullptr; // writer failed to give us the flattenable |
| 248 } | 248 } |
| 249 | 249 |
| 250 SkString* namePtr = fFlattenableDict.find(index); | 250 SkString* namePtr = fFlattenableDict.find(index); |
| 251 SkASSERT(namePtr); | 251 if (!namePtr) { |
| 252 return nullptr; |
| 253 } |
| 252 name = *namePtr; | 254 name = *namePtr; |
| 253 } | 255 } |
| 254 | 256 |
| 255 // Is this the type we wanted ? | 257 // Is this the type we wanted ? |
| 256 const char* cname = name.c_str(); | 258 const char* cname = name.c_str(); |
| 257 SkFlattenable::Type baseType; | 259 SkFlattenable::Type baseType; |
| 258 if (!SkFlattenable::NameToType(cname, &baseType) || (baseType != type)) { | 260 if (!SkFlattenable::NameToType(cname, &baseType) || (baseType != type)) { |
| 259 return nullptr; | 261 return nullptr; |
| 260 } | 262 } |
| 261 | 263 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 274 size_t offset = fReader.offset(); | 276 size_t offset = fReader.offset(); |
| 275 obj = (*factory)(*this); | 277 obj = (*factory)(*this); |
| 276 // check that we read the amount we expected | 278 // check that we read the amount we expected |
| 277 size_t sizeRead = fReader.offset() - offset; | 279 size_t sizeRead = fReader.offset() - offset; |
| 278 this->validate(sizeRecorded == sizeRead); | 280 this->validate(sizeRecorded == sizeRead); |
| 279 if (fError) { | 281 if (fError) { |
| 280 obj = nullptr; | 282 obj = nullptr; |
| 281 } | 283 } |
| 282 return obj.release(); | 284 return obj.release(); |
| 283 } | 285 } |
| OLD | NEW |