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 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 } | 632 } |
633 | 633 |
634 // fRecord OK | 634 // fRecord OK |
635 uint32_t SkPicture::uniqueID() const { | 635 uint32_t SkPicture::uniqueID() const { |
636 if (SK_InvalidGenID == fUniqueID) { | 636 if (SK_InvalidGenID == fUniqueID) { |
637 fUniqueID = next_picture_generation_id(); | 637 fUniqueID = next_picture_generation_id(); |
638 } | 638 } |
639 return fUniqueID; | 639 return fUniqueID; |
640 } | 640 } |
641 | 641 |
| 642 static SkRecord* optimized(SkRecord* r) { |
| 643 SkRecordOptimize(r); |
| 644 return r; |
| 645 } |
| 646 |
642 // fRecord OK | 647 // fRecord OK |
643 SkPicture::SkPicture(SkScalar width, SkScalar height, SkRecord* record, SkBBoxHi
erarchy* bbh) | 648 SkPicture::SkPicture(SkScalar width, SkScalar height, SkRecord* record, SkBBoxHi
erarchy* bbh) |
644 : fCullWidth(width) | 649 : fCullWidth(width) |
645 , fCullHeight(height) | 650 , fCullHeight(height) |
646 , fRecord(record) | 651 , fRecord(optimized(record)) |
647 , fBBH(SkSafeRef(bbh)) | 652 , fBBH(SkSafeRef(bbh)) |
648 , fAnalysis(*record) { | 653 , fAnalysis(*fRecord) { |
649 // TODO: move optimization before we construct fAnalysis? | |
650 SkRecordOptimize(record); | |
651 // TODO: delay as much of this work until just before first playback? | 654 // TODO: delay as much of this work until just before first playback? |
652 if (fBBH.get()) { | 655 if (fBBH.get()) { |
653 SkRecordFillBounds(*record, fBBH.get()); | 656 SkRecordFillBounds(*fRecord, fBBH.get()); |
654 } | 657 } |
655 this->needsNewGenID(); | 658 this->needsNewGenID(); |
656 } | 659 } |
657 | 660 |
658 // Note that we are assuming that this entry point will only be called from | 661 // Note that we are assuming that this entry point will only be called from |
659 // one thread. Currently the only client of this method is | 662 // one thread. Currently the only client of this method is |
660 // SkGpuDevice::EXPERIMENTAL_optimize which should be only called from a single | 663 // SkGpuDevice::EXPERIMENTAL_optimize which should be only called from a single |
661 // thread. | 664 // thread. |
662 void SkPicture::addDeletionListener(DeletionListener* listener) const { | 665 void SkPicture::addDeletionListener(DeletionListener* listener) const { |
663 SkASSERT(listener); | 666 SkASSERT(listener); |
(...skipping 13 matching lines...) Expand all Loading... |
677 int SkPicture::approximateOpCount() const { | 680 int SkPicture::approximateOpCount() const { |
678 SkASSERT(fRecord.get() || fData.get()); | 681 SkASSERT(fRecord.get() || fData.get()); |
679 if (fRecord.get()) { | 682 if (fRecord.get()) { |
680 return fRecord->count(); | 683 return fRecord->count(); |
681 } | 684 } |
682 if (fData.get()) { | 685 if (fData.get()) { |
683 return fData->opCount(); | 686 return fData->opCount(); |
684 } | 687 } |
685 return 0; | 688 return 0; |
686 } | 689 } |
OLD | NEW |