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

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: Compiling 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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 dst.fLocalMat = src.fLocalMat; 675 dst.fLocalMat = src.fLocalMat;
676 dst.fPreMat = src.fPreMat; 676 dst.fPreMat = src.fPreMat;
677 dst.fPreMat.postConcat(fFillBounds.ctm()); 677 dst.fPreMat.postConcat(fFillBounds.ctm());
678 if (src.fPaint) { 678 if (src.fPaint) {
679 dst.fPaint = SkNEW_ARGS(SkPaint, (*src.fPaint)); 679 dst.fPaint = SkNEW_ARGS(SkPaint, (*src.fPaint));
680 } 680 }
681 dst.fSaveLayerOpID = src.fSaveLayerOpID; 681 dst.fSaveLayerOpID = src.fSaveLayerOpID;
682 dst.fRestoreOpID = src.fRestoreOpID; 682 dst.fRestoreOpID = src.fRestoreOpID;
683 dst.fHasNestedLayers = src.fHasNestedLayers; 683 dst.fHasNestedLayers = src.fHasNestedLayers;
684 dst.fIsNested = fSaveLayersInStack > 0 || src.fIsNested; 684 dst.fIsNested = fSaveLayersInStack > 0 || src.fIsNested;
685
686 dst.fKeySize = fSaveLayerOpStack.count() + src.fKeySize;
687 dst.fKey = SkNEW_ARRAY(int, dst.fKeySize);
688 memcpy(dst.fKey, fSaveLayerOpStack.begin(), fSaveLayerOpStack.count( ) * sizeof(int));
689 memcpy(&dst.fKey[fSaveLayerOpStack.count()], src.fKey, src.fKeySize * sizeof(int));
685 } 690 }
686 } 691 }
687 692
688 // Inform all the saveLayers already on the stack that they now have a 693 // Inform all the saveLayers already on the stack that they now have a
689 // nested saveLayer inside them 694 // nested saveLayer inside them
690 void updateStackForSaveLayer() { 695 void updateStackForSaveLayer() {
691 for (int index = fSaveLayerStack.count() - 1; index >= 0; --index) { 696 for (int index = fSaveLayerStack.count() - 1; index >= 0; --index) {
692 if (fSaveLayerStack[index].fHasNestedSaveLayer) { 697 if (fSaveLayerStack[index].fHasNestedSaveLayer) {
693 break; 698 break;
694 } 699 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 block.fBounds = fFillBounds.getBounds(sli.fStartIndex); 735 block.fBounds = fFillBounds.getBounds(sli.fStartIndex);
731 block.fLocalMat = fFillBounds.ctm(); 736 block.fLocalMat = fFillBounds.ctm();
732 block.fPreMat = SkMatrix::I(); 737 block.fPreMat = SkMatrix::I();
733 if (sli.fPaint) { 738 if (sli.fPaint) {
734 block.fPaint = SkNEW_ARGS(SkPaint, (*sli.fPaint)); 739 block.fPaint = SkNEW_ARGS(SkPaint, (*sli.fPaint));
735 } 740 }
736 block.fSaveLayerOpID = sli.fStartIndex; 741 block.fSaveLayerOpID = sli.fStartIndex;
737 block.fRestoreOpID = fFillBounds.currentOp(); 742 block.fRestoreOpID = fFillBounds.currentOp();
738 block.fHasNestedLayers = sli.fHasNestedSaveLayer; 743 block.fHasNestedLayers = sli.fHasNestedSaveLayer;
739 block.fIsNested = fSaveLayersInStack > 0; 744 block.fIsNested = fSaveLayersInStack > 0;
745
746 block.fKeySize = fSaveLayerOpStack.count();
747 block.fKey = SkNEW_ARRAY(int, block.fKeySize);
748 memcpy(block.fKey, fSaveLayerOpStack.begin(), block.fKeySize * sizeof(in t));
740 } 749 }
741 750
742 // Used to collect saveLayer information for layer hoisting 751 // Used to collect saveLayer information for layer hoisting
743 int fSaveLayersInStack; 752 int fSaveLayersInStack;
744 SkTDArray<SaveLayerInfo> fSaveLayerStack; 753 SkTDArray<SaveLayerInfo> fSaveLayerStack;
745 SkLayerInfo* fAccelData; 754 SkTDArray<int> fSaveLayerOpStack;
755 SkLayerInfo* fAccelData;
746 756
747 SkRecords::FillBounds fFillBounds; 757 SkRecords::FillBounds fFillBounds;
748 }; 758 };
749 759
750 } // namespace SkRecords 760 } // namespace SkRecords
751 761
752 void SkRecordFillBounds(const SkRect& cullRect, const SkRecord& record, SkBBoxHi erarchy* bbh) { 762 void SkRecordFillBounds(const SkRect& cullRect, const SkRecord& record, SkBBoxHi erarchy* bbh) {
753 SkRecords::FillBounds visitor(cullRect, record); 763 SkRecords::FillBounds visitor(cullRect, record);
754 764
755 for (unsigned curOp = 0; curOp < record.count(); curOp++) { 765 for (unsigned curOp = 0; curOp < record.count(); curOp++) {
756 visitor.setCurrentOp(curOp); 766 visitor.setCurrentOp(curOp);
757 record.visit<void>(curOp, visitor); 767 record.visit<void>(curOp, visitor);
758 } 768 }
759 769
760 visitor.cleanUp(bbh); 770 visitor.cleanUp(bbh);
761 } 771 }
762 772
763 void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record, 773 void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record,
764 SkBBoxHierarchy* bbh, SkLayerInfo* data) { 774 SkBBoxHierarchy* bbh, SkLayerInfo* data) {
765 SkRecords::CollectLayers visitor(cullRect, record, data); 775 SkRecords::CollectLayers visitor(cullRect, record, data);
766 776
767 for (unsigned curOp = 0; curOp < record.count(); curOp++) { 777 for (unsigned curOp = 0; curOp < record.count(); curOp++) {
768 visitor.setCurrentOp(curOp); 778 visitor.setCurrentOp(curOp);
769 record.visit<void>(curOp, visitor); 779 record.visit<void>(curOp, visitor);
770 } 780 }
771 781
772 visitor.cleanUp(bbh); 782 visitor.cleanUp(bbh);
773 } 783 }
774 784
OLDNEW
« src/core/SkLayerInfo.h ('K') | « src/core/SkLayerInfo.h ('k') | src/gpu/GrLayerCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698