| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkLayerInfo.h" | 8 #include "SkLayerInfo.h" |
| 9 #include "SkRecordDraw.h" | 9 #include "SkRecordDraw.h" |
| 10 #include "SkPatchUtils.h" | 10 #include "SkPatchUtils.h" |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 | 580 |
| 581 // Used to track the bounds of Save/Restore blocks and the control ops insid
e them. | 581 // Used to track the bounds of Save/Restore blocks and the control ops insid
e them. |
| 582 SkTDArray<SaveBounds> fSaveStack; | 582 SkTDArray<SaveBounds> fSaveStack; |
| 583 SkTDArray<unsigned> fControlIndices; | 583 SkTDArray<unsigned> fControlIndices; |
| 584 }; | 584 }; |
| 585 | 585 |
| 586 // SkRecord visitor to gather saveLayer/restore information. | 586 // SkRecord visitor to gather saveLayer/restore information. |
| 587 class CollectLayers : SkNoncopyable { | 587 class CollectLayers : SkNoncopyable { |
| 588 public: | 588 public: |
| 589 CollectLayers(const SkRect& cullRect, const SkRecord& record, | 589 CollectLayers(const SkRect& cullRect, const SkRecord& record, |
| 590 const SkPicture::SnapshotArray* pictList, SkLayerInfo* accelDa
ta) | 590 const SkBigPicture::SnapshotArray* pictList, SkLayerInfo* acce
lData) |
| 591 : fSaveLayersInStack(0) | 591 : fSaveLayersInStack(0) |
| 592 , fAccelData(accelData) | 592 , fAccelData(accelData) |
| 593 , fPictList(pictList) | 593 , fPictList(pictList) |
| 594 , fFillBounds(cullRect, record) | 594 , fFillBounds(cullRect, record) |
| 595 {} | 595 {} |
| 596 | 596 |
| 597 void setCurrentOp(unsigned currentOp) { fFillBounds.setCurrentOp(currentOp);
} | 597 void setCurrentOp(unsigned currentOp) { fFillBounds.setCurrentOp(currentOp);
} |
| 598 | 598 |
| 599 void cleanUp(SkBBoxHierarchy* bbh) { | 599 void cleanUp(SkBBoxHierarchy* bbh) { |
| 600 // fFillBounds must perform its cleanUp first so that all the bounding | 600 // fFillBounds must perform its cleanUp first so that all the bounding |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 template <typename T> void trackSaveLayers(const T& op) { | 633 template <typename T> void trackSaveLayers(const T& op) { |
| 634 /* most ops aren't involved in saveLayers */ | 634 /* most ops aren't involved in saveLayers */ |
| 635 } | 635 } |
| 636 void trackSaveLayers(const Save& s) { this->pushSaveLayerInfo(false, NULL, N
ULL); } | 636 void trackSaveLayers(const Save& s) { this->pushSaveLayerInfo(false, NULL, N
ULL); } |
| 637 void trackSaveLayers(const SaveLayer& sl) { this->pushSaveLayerInfo(true, sl
.bounds, sl.paint); } | 637 void trackSaveLayers(const SaveLayer& sl) { this->pushSaveLayerInfo(true, sl
.bounds, sl.paint); } |
| 638 void trackSaveLayers(const Restore& r) { this->popSaveLayerInfo(); } | 638 void trackSaveLayers(const Restore& r) { this->popSaveLayerInfo(); } |
| 639 | 639 |
| 640 void trackSaveLayersForPicture(const SkPicture* picture, const SkPaint* pain
t) { | 640 void trackSaveLayersForPicture(const SkPicture* picture, const SkPaint* pain
t) { |
| 641 // For sub-pictures, we wrap their layer information within the parent | 641 // For sub-pictures, we wrap their layer information within the parent |
| 642 // picture's rendering hierarchy | 642 // picture's rendering hierarchy |
| 643 SkPicture::AccelData::Key key = SkLayerInfo::ComputeKey(); | 643 const SkLayerInfo* childData = NULL; |
| 644 | 644 if (const SkBigPicture* bp = picture->asSkBigPicture()) { |
| 645 const SkLayerInfo* childData = | 645 childData = static_cast<const SkLayerInfo*>(bp->accelData()); |
| 646 static_cast<const SkLayerInfo*>(picture->EXPERIMENTAL_getAccelData(k
ey)); | 646 } |
| 647 if (!childData) { | 647 if (!childData) { |
| 648 // If the child layer hasn't been generated with saveLayer data we | 648 // If the child layer hasn't been generated with saveLayer data we |
| 649 // assume the worst (i.e., that it does contain layers which nest | 649 // assume the worst (i.e., that it does contain layers which nest |
| 650 // inside existing layers). Layers within sub-pictures that don't | 650 // inside existing layers). Layers within sub-pictures that don't |
| 651 // have saveLayer data cannot be hoisted. | 651 // have saveLayer data cannot be hoisted. |
| 652 // TODO: could the analysis data be use to fine tune this? | 652 // TODO: could the analysis data be use to fine tune this? |
| 653 this->updateStackForSaveLayer(); | 653 this->updateStackForSaveLayer(); |
| 654 return; | 654 return; |
| 655 } | 655 } |
| 656 | 656 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 | 767 |
| 768 fSaveLayerOpStack.pop(); | 768 fSaveLayerOpStack.pop(); |
| 769 } | 769 } |
| 770 | 770 |
| 771 // Used to collect saveLayer information for layer hoisting | 771 // Used to collect saveLayer information for layer hoisting |
| 772 int fSaveLayersInStack; | 772 int fSaveLayersInStack; |
| 773 SkTDArray<SaveLayerInfo> fSaveLayerStack; | 773 SkTDArray<SaveLayerInfo> fSaveLayerStack; |
| 774 // The op code indices of all the currently active saveLayers | 774 // The op code indices of all the currently active saveLayers |
| 775 SkTDArray<unsigned> fSaveLayerOpStack; | 775 SkTDArray<unsigned> fSaveLayerOpStack; |
| 776 SkLayerInfo* fAccelData; | 776 SkLayerInfo* fAccelData; |
| 777 const SkPicture::SnapshotArray* fPictList; | 777 const SkBigPicture::SnapshotArray* fPictList; |
| 778 | 778 |
| 779 SkRecords::FillBounds fFillBounds; | 779 SkRecords::FillBounds fFillBounds; |
| 780 }; | 780 }; |
| 781 | 781 |
| 782 } // namespace SkRecords | 782 } // namespace SkRecords |
| 783 | 783 |
| 784 void SkRecordFillBounds(const SkRect& cullRect, const SkRecord& record, SkBBoxHi
erarchy* bbh) { | 784 void SkRecordFillBounds(const SkRect& cullRect, const SkRecord& record, SkBBoxHi
erarchy* bbh) { |
| 785 SkRecords::FillBounds visitor(cullRect, record); | 785 SkRecords::FillBounds visitor(cullRect, record); |
| 786 | 786 |
| 787 for (unsigned curOp = 0; curOp < record.count(); curOp++) { | 787 for (unsigned curOp = 0; curOp < record.count(); curOp++) { |
| 788 visitor.setCurrentOp(curOp); | 788 visitor.setCurrentOp(curOp); |
| 789 record.visit<void>(curOp, visitor); | 789 record.visit<void>(curOp, visitor); |
| 790 } | 790 } |
| 791 | 791 |
| 792 visitor.cleanUp(bbh); | 792 visitor.cleanUp(bbh); |
| 793 } | 793 } |
| 794 | 794 |
| 795 void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record, | 795 void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record, |
| 796 const SkPicture::SnapshotArray* pictList, SkBBoxHiera
rchy* bbh, | 796 const SkBigPicture::SnapshotArray* pictList, SkBBoxHi
erarchy* bbh, |
| 797 SkLayerInfo* data) { | 797 SkLayerInfo* data) { |
| 798 SkRecords::CollectLayers visitor(cullRect, record, pictList, data); | 798 SkRecords::CollectLayers visitor(cullRect, record, pictList, data); |
| 799 | 799 |
| 800 for (unsigned curOp = 0; curOp < record.count(); curOp++) { | 800 for (unsigned curOp = 0; curOp < record.count(); curOp++) { |
| 801 visitor.setCurrentOp(curOp); | 801 visitor.setCurrentOp(curOp); |
| 802 record.visit<void>(curOp, visitor); | 802 record.visit<void>(curOp, visitor); |
| 803 } | 803 } |
| 804 | 804 |
| 805 visitor.cleanUp(bbh); | 805 visitor.cleanUp(bbh); |
| 806 } | 806 } |
| 807 | 807 |
| OLD | NEW |