| 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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 this->validate(false); | 290 this->validate(false); |
| 291 return nullptr; | 291 return nullptr; |
| 292 } | 292 } |
| 293 | 293 |
| 294 const SkIRect subset = SkIRect::MakeXYWH(originX, originY, width, height); | 294 const SkIRect subset = SkIRect::MakeXYWH(originX, originY, width, height); |
| 295 | 295 |
| 296 sk_sp<SkImage> image = fImageDeserializer->makeFromData(encoded.get(), &subs
et); | 296 sk_sp<SkImage> image = fImageDeserializer->makeFromData(encoded.get(), &subs
et); |
| 297 return image ? image : MakeEmptyImage(width, height); | 297 return image ? image : MakeEmptyImage(width, height); |
| 298 } | 298 } |
| 299 | 299 |
| 300 SkTypeface* SkReadBuffer::readTypeface() { | 300 sk_sp<SkTypeface> SkReadBuffer::readTypeface() { |
| 301 | |
| 302 uint32_t index = fReader.readU32(); | 301 uint32_t index = fReader.readU32(); |
| 303 if (0 == index || index > (unsigned)fTFCount) { | 302 if (0 == index || index > (unsigned)fTFCount) { |
| 304 return nullptr; | 303 return nullptr; |
| 305 } else { | 304 } else { |
| 306 SkASSERT(fTFArray); | 305 SkASSERT(fTFArray); |
| 307 return fTFArray[index - 1]; | 306 return sk_ref_sp(fTFArray[index - 1]); |
| 308 } | 307 } |
| 309 } | 308 } |
| 310 | 309 |
| 311 SkFlattenable* SkReadBuffer::readFlattenable(SkFlattenable::Type ft) { | 310 SkFlattenable* SkReadBuffer::readFlattenable(SkFlattenable::Type ft) { |
| 312 // | 311 // |
| 313 // TODO: confirm that ft matches the factory we decide to use | 312 // TODO: confirm that ft matches the factory we decide to use |
| 314 // | 313 // |
| 315 | 314 |
| 316 SkFlattenable::Factory factory = nullptr; | 315 SkFlattenable::Factory factory = nullptr; |
| 317 | 316 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 if (sizeRecorded != sizeRead) { | 367 if (sizeRecorded != sizeRead) { |
| 369 this->validate(false); | 368 this->validate(false); |
| 370 return nullptr; | 369 return nullptr; |
| 371 } | 370 } |
| 372 } else { | 371 } else { |
| 373 // we must skip the remaining data | 372 // we must skip the remaining data |
| 374 fReader.skip(sizeRecorded); | 373 fReader.skip(sizeRecorded); |
| 375 } | 374 } |
| 376 return obj.release(); | 375 return obj.release(); |
| 377 } | 376 } |
| OLD | NEW |