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 #if 0 | |
435 const SkPicture src(data, info.fWidth, info.fHeight); | 434 const SkPicture src(data, info.fWidth, info.fHeight); |
436 return Forwardport(src); | 435 return Forwardport(src); |
437 #else | |
438 return SkNEW_ARGS(SkPicture, (data, info.fWidth, info.fHeight)); | |
439 #endif | |
440 } | 436 } |
441 | 437 |
442 return NULL; | 438 return NULL; |
443 } | 439 } |
444 | 440 |
445 // fRecord OK | 441 // fRecord OK |
446 SkPicture* SkPicture::CreateFromBuffer(SkReadBuffer& buffer) { | 442 SkPicture* SkPicture::CreateFromBuffer(SkReadBuffer& buffer) { |
447 SkPictInfo info; | 443 SkPictInfo info; |
448 | 444 |
449 if (!InternalOnly_BufferIsSKP(buffer, &info)) { | 445 if (!InternalOnly_BufferIsSKP(buffer, &info)) { |
450 return NULL; | 446 return NULL; |
451 } | 447 } |
452 | 448 |
453 // Check to see if there is a playback to recreate. | 449 // Check to see if there is a playback to recreate. |
454 if (buffer.readBool()) { | 450 if (buffer.readBool()) { |
455 SkPictureData* data = SkPictureData::CreateFromBuffer(buffer, info); | 451 SkPictureData* data = SkPictureData::CreateFromBuffer(buffer, info); |
456 if (NULL == data) { | 452 if (NULL == data) { |
457 return NULL; | 453 return NULL; |
458 } | 454 } |
459 #if 0 | |
460 const SkPicture src(data, info.fWidth, info.fHeight); | 455 const SkPicture src(data, info.fWidth, info.fHeight); |
461 return Forwardport(src); | 456 return Forwardport(src); |
462 #else | |
463 return SkNEW_ARGS(SkPicture, (data, info.fWidth, info.fHeight)); | |
464 #endif | |
465 } | 457 } |
466 | 458 |
467 return NULL; | 459 return NULL; |
468 } | 460 } |
469 | 461 |
470 // fRecord OK | 462 // fRecord OK |
471 void SkPicture::createHeader(SkPictInfo* info) const { | 463 void SkPicture::createHeader(SkPictInfo* info) const { |
472 // Copy magic bytes at the beginning of the header | 464 // Copy magic bytes at the beginning of the header |
473 SkASSERT(sizeof(kMagic) == 8); | 465 SkASSERT(sizeof(kMagic) == 8); |
474 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... |
632 int SkPicture::approximateOpCount() const { | 624 int SkPicture::approximateOpCount() const { |
633 SkASSERT(fRecord.get() || fData.get()); | 625 SkASSERT(fRecord.get() || fData.get()); |
634 if (fRecord.get()) { | 626 if (fRecord.get()) { |
635 return fRecord->count(); | 627 return fRecord->count(); |
636 } | 628 } |
637 if (fData.get()) { | 629 if (fData.get()) { |
638 return fData->opCount(); | 630 return fData->opCount(); |
639 } | 631 } |
640 return 0; | 632 return 0; |
641 } | 633 } |
OLD | NEW |