Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: src/core/SkRecordDraw.cpp

Issue 753253002: Use variable length key (rather than accumulated matrix) as save layer hoisting key (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more cleanup Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 dst.fLocalMat = src.fLocalMat; 685 dst.fLocalMat = src.fLocalMat;
686 dst.fPreMat = src.fPreMat; 686 dst.fPreMat = src.fPreMat;
687 dst.fPreMat.postConcat(fFillBounds.ctm()); 687 dst.fPreMat.postConcat(fFillBounds.ctm());
688 if (src.fPaint) { 688 if (src.fPaint) {
689 dst.fPaint = SkNEW_ARGS(SkPaint, (*src.fPaint)); 689 dst.fPaint = SkNEW_ARGS(SkPaint, (*src.fPaint));
690 } 690 }
691 dst.fSaveLayerOpID = src.fSaveLayerOpID; 691 dst.fSaveLayerOpID = src.fSaveLayerOpID;
692 dst.fRestoreOpID = src.fRestoreOpID; 692 dst.fRestoreOpID = src.fRestoreOpID;
693 dst.fHasNestedLayers = src.fHasNestedLayers; 693 dst.fHasNestedLayers = src.fHasNestedLayers;
694 dst.fIsNested = fSaveLayersInStack > 0 || src.fIsNested; 694 dst.fIsNested = fSaveLayersInStack > 0 || src.fIsNested;
695
696 // Store 'saveLayer ops from enclosing picture' + drawPict op + 'ops from sub-picture'
697 dst.fKeySize = fSaveLayerOpStack.count() + src.fKeySize + 1;
698 dst.fKey = SkNEW_ARRAY(int, dst.fKeySize);
699 memcpy(dst.fKey, fSaveLayerOpStack.begin(), fSaveLayerOpStack.count( ) * sizeof(int));
700 dst.fKey[fSaveLayerOpStack.count()] = fFillBounds.currentOp();
701 memcpy(&dst.fKey[fSaveLayerOpStack.count()+1], src.fKey, src.fKeySiz e * sizeof(int));
695 } 702 }
696 } 703 }
697 704
698 void trackSaveLayers(const DrawPicture& dp) { 705 void trackSaveLayers(const DrawPicture& dp) {
699 this->trackSaveLayersForPicture(dp.picture, dp.paint); 706 this->trackSaveLayersForPicture(dp.picture, dp.paint);
700 } 707 }
701 708
702 void trackSaveLayers(const DrawDrawable& dp) { 709 void trackSaveLayers(const DrawDrawable& dp) {
703 SkASSERT(fPictList); 710 SkASSERT(fPictList);
704 SkASSERT(dp.index >= 0 && dp.index < fPictList->count()); 711 SkASSERT(dp.index >= 0 && dp.index < fPictList->count());
(...skipping 12 matching lines...) Expand all
717 if (fSaveLayerStack[index].fIsSaveLayer) { 724 if (fSaveLayerStack[index].fIsSaveLayer) {
718 break; 725 break;
719 } 726 }
720 } 727 }
721 } 728 }
722 729
723 void pushSaveLayerInfo(bool isSaveLayer, const SkPaint* paint) { 730 void pushSaveLayerInfo(bool isSaveLayer, const SkPaint* paint) {
724 if (isSaveLayer) { 731 if (isSaveLayer) {
725 this->updateStackForSaveLayer(); 732 this->updateStackForSaveLayer();
726 ++fSaveLayersInStack; 733 ++fSaveLayersInStack;
734 fSaveLayerOpStack.push(fFillBounds.currentOp());
727 } 735 }
728 736
729 fSaveLayerStack.push(SaveLayerInfo(fFillBounds.currentOp(), isSaveLayer, paint)); 737 fSaveLayerStack.push(SaveLayerInfo(fFillBounds.currentOp(), isSaveLayer, paint));
730 } 738 }
731 739
732 void popSaveLayerInfo() { 740 void popSaveLayerInfo() {
733 if (fSaveLayerStack.count() <= 0) { 741 if (fSaveLayerStack.count() <= 0) {
734 SkASSERT(false); 742 SkASSERT(false);
735 return; 743 return;
736 } 744 }
737 745
746 SkASSERT(fSaveLayersInStack == fSaveLayerOpStack.count());
747
738 SaveLayerInfo sli; 748 SaveLayerInfo sli;
739 fSaveLayerStack.pop(&sli); 749 fSaveLayerStack.pop(&sli);
740 750
741 if (!sli.fIsSaveLayer) { 751 if (!sli.fIsSaveLayer) {
742 return; 752 return;
743 } 753 }
744 754
745 --fSaveLayersInStack; 755 --fSaveLayersInStack;
746 756
747 SkLayerInfo::BlockInfo& block = fAccelData->addBlock(); 757 SkLayerInfo::BlockInfo& block = fAccelData->addBlock();
748 758
749 SkASSERT(NULL == block.fPicture); // This layer is in the top-most pict ure 759 SkASSERT(NULL == block.fPicture); // This layer is in the top-most pict ure
750 760
751 block.fBounds = fFillBounds.getBounds(sli.fStartIndex); 761 block.fBounds = fFillBounds.getBounds(sli.fStartIndex);
752 block.fLocalMat = fFillBounds.ctm(); 762 block.fLocalMat = fFillBounds.ctm();
753 block.fPreMat = SkMatrix::I(); 763 block.fPreMat = SkMatrix::I();
754 if (sli.fPaint) { 764 if (sli.fPaint) {
755 block.fPaint = SkNEW_ARGS(SkPaint, (*sli.fPaint)); 765 block.fPaint = SkNEW_ARGS(SkPaint, (*sli.fPaint));
756 } 766 }
757 block.fSaveLayerOpID = sli.fStartIndex; 767 block.fSaveLayerOpID = sli.fStartIndex;
758 block.fRestoreOpID = fFillBounds.currentOp(); 768 block.fRestoreOpID = fFillBounds.currentOp();
759 block.fHasNestedLayers = sli.fHasNestedSaveLayer; 769 block.fHasNestedLayers = sli.fHasNestedSaveLayer;
760 block.fIsNested = fSaveLayersInStack > 0; 770 block.fIsNested = fSaveLayersInStack > 0;
771
772 block.fKeySize = fSaveLayerOpStack.count();
773 block.fKey = SkNEW_ARRAY(int, block.fKeySize);
774 memcpy(block.fKey, fSaveLayerOpStack.begin(), block.fKeySize * sizeof(in t));
775
776 fSaveLayerOpStack.pop();
761 } 777 }
762 778
763 // Used to collect saveLayer information for layer hoisting 779 // Used to collect saveLayer information for layer hoisting
764 int fSaveLayersInStack; 780 int fSaveLayersInStack;
765 SkTDArray<SaveLayerInfo> fSaveLayerStack; 781 SkTDArray<SaveLayerInfo> fSaveLayerStack;
766 SkLayerInfo* fAccelData; 782 // The op code indices of all the currently active saveLayers
783 SkTDArray<int> fSaveLayerOpStack;
784 SkLayerInfo* fAccelData;
767 const SkPicture::SnapshotArray* fPictList; 785 const SkPicture::SnapshotArray* fPictList;
768 786
769 SkRecords::FillBounds fFillBounds; 787 SkRecords::FillBounds fFillBounds;
770 }; 788 };
771 789
772 } // namespace SkRecords 790 } // namespace SkRecords
773 791
774 void SkRecordFillBounds(const SkRect& cullRect, const SkRecord& record, SkBBoxHi erarchy* bbh) { 792 void SkRecordFillBounds(const SkRect& cullRect, const SkRecord& record, SkBBoxHi erarchy* bbh) {
775 SkRecords::FillBounds visitor(cullRect, record); 793 SkRecords::FillBounds visitor(cullRect, record);
776 794
(...skipping 11 matching lines...) Expand all
788 SkRecords::CollectLayers visitor(cullRect, record, pictList, data); 806 SkRecords::CollectLayers visitor(cullRect, record, pictList, data);
789 807
790 for (unsigned curOp = 0; curOp < record.count(); curOp++) { 808 for (unsigned curOp = 0; curOp < record.count(); curOp++) {
791 visitor.setCurrentOp(curOp); 809 visitor.setCurrentOp(curOp);
792 record.visit<void>(curOp, visitor); 810 record.visit<void>(curOp, visitor);
793 } 811 }
794 812
795 visitor.cleanUp(bbh); 813 visitor.cleanUp(bbh);
796 } 814 }
797 815
OLDNEW
« no previous file with comments | « src/core/SkMultiPictureDraw.cpp ('k') | src/gpu/GrLayerCache.h » ('j') | src/gpu/GrLayerCache.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698