OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2007 The Android Open Source Project | 3 * Copyright 2007 The Android Open Source Project |
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 | 9 |
10 #include "SkPictureFlat.h" | 10 #include "SkPictureFlat.h" |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 if (!InternalOnly_StreamIsSKP(stream, &info)) { | 424 if (!InternalOnly_StreamIsSKP(stream, &info)) { |
425 return NULL; | 425 return NULL; |
426 } | 426 } |
427 | 427 |
428 // Check to see if there is a playback to recreate. | 428 // Check to see if there is a playback to recreate. |
429 if (stream->readBool()) { | 429 if (stream->readBool()) { |
430 SkPictureData* data = SkPictureData::CreateFromStream(stream, info, proc
); | 430 SkPictureData* data = SkPictureData::CreateFromStream(stream, info, proc
); |
431 if (NULL == data) { | 431 if (NULL == data) { |
432 return NULL; | 432 return NULL; |
433 } | 433 } |
434 return Forwardport(SkPicture(data, info.fWidth, info.fHeight)); | 434 const SkPicture src(data, info.fWidth, info.fHeight); |
| 435 return Forwardport(src); |
435 } | 436 } |
436 | 437 |
437 return NULL; | 438 return NULL; |
438 } | 439 } |
439 | 440 |
440 // fRecord OK | 441 // fRecord OK |
441 SkPicture* SkPicture::CreateFromBuffer(SkReadBuffer& buffer) { | 442 SkPicture* SkPicture::CreateFromBuffer(SkReadBuffer& buffer) { |
442 SkPictInfo info; | 443 SkPictInfo info; |
443 | 444 |
444 if (!InternalOnly_BufferIsSKP(buffer, &info)) { | 445 if (!InternalOnly_BufferIsSKP(buffer, &info)) { |
445 return NULL; | 446 return NULL; |
446 } | 447 } |
447 | 448 |
448 // Check to see if there is a playback to recreate. | 449 // Check to see if there is a playback to recreate. |
449 if (buffer.readBool()) { | 450 if (buffer.readBool()) { |
450 SkPictureData* data = SkPictureData::CreateFromBuffer(buffer, info); | 451 SkPictureData* data = SkPictureData::CreateFromBuffer(buffer, info); |
451 if (NULL == data) { | 452 if (NULL == data) { |
452 return NULL; | 453 return NULL; |
453 } | 454 } |
454 return Forwardport(SkPicture(data, info.fWidth, info.fHeight)); | 455 const SkPicture src(data, info.fWidth, info.fHeight); |
| 456 return Forwardport(src); |
455 } | 457 } |
456 | 458 |
457 return NULL; | 459 return NULL; |
458 } | 460 } |
459 | 461 |
460 // fRecord OK | 462 // fRecord OK |
461 void SkPicture::createHeader(SkPictInfo* info) const { | 463 void SkPicture::createHeader(SkPictInfo* info) const { |
462 // Copy magic bytes at the beginning of the header | 464 // Copy magic bytes at the beginning of the header |
463 SkASSERT(sizeof(kMagic) == 8); | 465 SkASSERT(sizeof(kMagic) == 8); |
464 SkASSERT(sizeof(kMagic) == sizeof(info->fMagic)); | 466 SkASSERT(sizeof(kMagic) == sizeof(info->fMagic)); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 int SkPicture::approximateOpCount() const { | 624 int SkPicture::approximateOpCount() const { |
623 SkASSERT(fRecord.get() || fData.get()); | 625 SkASSERT(fRecord.get() || fData.get()); |
624 if (fRecord.get()) { | 626 if (fRecord.get()) { |
625 return fRecord->count(); | 627 return fRecord->count(); |
626 } | 628 } |
627 if (fData.get()) { | 629 if (fData.get()) { |
628 return fData->opCount(); | 630 return fData->opCount(); |
629 } | 631 } |
630 return 0; | 632 return 0; |
631 } | 633 } |
OLD | NEW |