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

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

Issue 803183003: Fix layer hoisting image filter corner cases (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix unit test 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
« no previous file with comments | « src/core/SkLayerInfo.h ('k') | src/gpu/GrLayerCache.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 } 601 }
602 602
603 template <typename T> void operator()(const T& op) { 603 template <typename T> void operator()(const T& op) {
604 fFillBounds(op); 604 fFillBounds(op);
605 this->trackSaveLayers(op); 605 this->trackSaveLayers(op);
606 } 606 }
607 607
608 private: 608 private:
609 struct SaveLayerInfo { 609 struct SaveLayerInfo {
610 SaveLayerInfo() { } 610 SaveLayerInfo() { }
611 SaveLayerInfo(int opIndex, bool isSaveLayer, const SkPaint* paint) 611 SaveLayerInfo(int opIndex, bool isSaveLayer, const SkRect* bounds, const SkPaint* paint)
612 : fStartIndex(opIndex) 612 : fStartIndex(opIndex)
613 , fIsSaveLayer(isSaveLayer) 613 , fIsSaveLayer(isSaveLayer)
614 , fHasNestedSaveLayer(false) 614 , fHasNestedSaveLayer(false)
615 , fBounds(bounds ? *bounds : SkRect::MakeEmpty())
615 , fPaint(paint) { 616 , fPaint(paint) {
616 } 617 }
617 618
618 int fStartIndex; 619 int fStartIndex;
619 bool fIsSaveLayer; 620 bool fIsSaveLayer;
620 bool fHasNestedSaveLayer; 621 bool fHasNestedSaveLayer;
622 SkRect fBounds;
621 const SkPaint* fPaint; 623 const SkPaint* fPaint;
622 }; 624 };
623 625
624 template <typename T> void trackSaveLayers(const T& op) { 626 template <typename T> void trackSaveLayers(const T& op) {
625 /* most ops aren't involved in saveLayers */ 627 /* most ops aren't involved in saveLayers */
626 } 628 }
627 void trackSaveLayers(const Save& s) { this->pushSaveLayerInfo(false, NULL); } 629 void trackSaveLayers(const Save& s) { this->pushSaveLayerInfo(false, NULL, N ULL); }
628 void trackSaveLayers(const SaveLayer& sl) { this->pushSaveLayerInfo(true, sl .paint); } 630 void trackSaveLayers(const SaveLayer& sl) { this->pushSaveLayerInfo(true, sl .bounds, sl.paint); }
629 void trackSaveLayers(const Restore& r) { this->popSaveLayerInfo(); } 631 void trackSaveLayers(const Restore& r) { this->popSaveLayerInfo(); }
630 632
631 void trackSaveLayersForPicture(const SkPicture* picture, const SkPaint* pain t) { 633 void trackSaveLayersForPicture(const SkPicture* picture, const SkPaint* pain t) {
632 // For sub-pictures, we wrap their layer information within the parent 634 // For sub-pictures, we wrap their layer information within the parent
633 // picture's rendering hierarchy 635 // picture's rendering hierarchy
634 SkPicture::AccelData::Key key = SkLayerInfo::ComputeKey(); 636 SkPicture::AccelData::Key key = SkLayerInfo::ComputeKey();
635 637
636 const SkLayerInfo* childData = 638 const SkLayerInfo* childData =
637 static_cast<const SkLayerInfo*>(picture->EXPERIMENTAL_getAccelData(k ey)); 639 static_cast<const SkLayerInfo*>(picture->EXPERIMENTAL_getAccelData(k ey));
638 if (!childData) { 640 if (!childData) {
(...skipping 16 matching lines...) Expand all
655 657
656 this->updateStackForSaveLayer(); 658 this->updateStackForSaveLayer();
657 659
658 SkLayerInfo::BlockInfo& dst = fAccelData->addBlock(); 660 SkLayerInfo::BlockInfo& dst = fAccelData->addBlock();
659 661
660 // If src.fPicture is NULL the layer is in dp.picture; otherwise 662 // If src.fPicture is NULL the layer is in dp.picture; otherwise
661 // it belongs to a sub-picture. 663 // it belongs to a sub-picture.
662 dst.fPicture = src.fPicture ? src.fPicture : picture; 664 dst.fPicture = src.fPicture ? src.fPicture : picture;
663 dst.fPicture->ref(); 665 dst.fPicture->ref();
664 dst.fBounds = newBound; 666 dst.fBounds = newBound;
667 dst.fSrcBounds = src.fSrcBounds;
665 dst.fLocalMat = src.fLocalMat; 668 dst.fLocalMat = src.fLocalMat;
666 dst.fPreMat = src.fPreMat; 669 dst.fPreMat = src.fPreMat;
667 dst.fPreMat.postConcat(fFillBounds.ctm()); 670 dst.fPreMat.postConcat(fFillBounds.ctm());
668 if (src.fPaint) { 671 if (src.fPaint) {
669 dst.fPaint = SkNEW_ARGS(SkPaint, (*src.fPaint)); 672 dst.fPaint = SkNEW_ARGS(SkPaint, (*src.fPaint));
670 } 673 }
671 dst.fSaveLayerOpID = src.fSaveLayerOpID; 674 dst.fSaveLayerOpID = src.fSaveLayerOpID;
672 dst.fRestoreOpID = src.fRestoreOpID; 675 dst.fRestoreOpID = src.fRestoreOpID;
673 dst.fHasNestedLayers = src.fHasNestedLayers; 676 dst.fHasNestedLayers = src.fHasNestedLayers;
674 dst.fIsNested = fSaveLayersInStack > 0 || src.fIsNested; 677 dst.fIsNested = fSaveLayersInStack > 0 || src.fIsNested;
(...skipping 25 matching lines...) Expand all
700 if (fSaveLayerStack[index].fHasNestedSaveLayer) { 703 if (fSaveLayerStack[index].fHasNestedSaveLayer) {
701 break; 704 break;
702 } 705 }
703 fSaveLayerStack[index].fHasNestedSaveLayer = true; 706 fSaveLayerStack[index].fHasNestedSaveLayer = true;
704 if (fSaveLayerStack[index].fIsSaveLayer) { 707 if (fSaveLayerStack[index].fIsSaveLayer) {
705 break; 708 break;
706 } 709 }
707 } 710 }
708 } 711 }
709 712
710 void pushSaveLayerInfo(bool isSaveLayer, const SkPaint* paint) { 713 void pushSaveLayerInfo(bool isSaveLayer, const SkRect* bounds, const SkPaint * paint) {
711 if (isSaveLayer) { 714 if (isSaveLayer) {
712 this->updateStackForSaveLayer(); 715 this->updateStackForSaveLayer();
713 ++fSaveLayersInStack; 716 ++fSaveLayersInStack;
714 fSaveLayerOpStack.push(fFillBounds.currentOp()); 717 fSaveLayerOpStack.push(fFillBounds.currentOp());
715 } 718 }
716 719
717 fSaveLayerStack.push(SaveLayerInfo(fFillBounds.currentOp(), isSaveLayer, paint)); 720 fSaveLayerStack.push(SaveLayerInfo(fFillBounds.currentOp(), isSaveLayer, bounds, paint));
718 } 721 }
719 722
720 void popSaveLayerInfo() { 723 void popSaveLayerInfo() {
721 if (fSaveLayerStack.count() <= 0) { 724 if (fSaveLayerStack.count() <= 0) {
722 SkASSERT(false); 725 SkASSERT(false);
723 return; 726 return;
724 } 727 }
725 728
726 SkASSERT(fSaveLayersInStack == fSaveLayerOpStack.count()); 729 SkASSERT(fSaveLayersInStack == fSaveLayerOpStack.count());
727 730
728 SaveLayerInfo sli; 731 SaveLayerInfo sli;
729 fSaveLayerStack.pop(&sli); 732 fSaveLayerStack.pop(&sli);
730 733
731 if (!sli.fIsSaveLayer) { 734 if (!sli.fIsSaveLayer) {
732 return; 735 return;
733 } 736 }
734 737
735 --fSaveLayersInStack; 738 --fSaveLayersInStack;
736 739
737 SkLayerInfo::BlockInfo& block = fAccelData->addBlock(); 740 SkLayerInfo::BlockInfo& block = fAccelData->addBlock();
738 741
739 SkASSERT(NULL == block.fPicture); // This layer is in the top-most pict ure 742 SkASSERT(NULL == block.fPicture); // This layer is in the top-most pict ure
740 743
741 block.fBounds = fFillBounds.getBounds(sli.fStartIndex); 744 block.fBounds = fFillBounds.getBounds(sli.fStartIndex);
742 block.fLocalMat = fFillBounds.ctm(); 745 block.fLocalMat = fFillBounds.ctm();
743 block.fPreMat = SkMatrix::I(); 746 block.fPreMat = SkMatrix::I();
744 if (sli.fPaint) { 747 if (sli.fPaint) {
745 block.fPaint = SkNEW_ARGS(SkPaint, (*sli.fPaint)); 748 block.fPaint = SkNEW_ARGS(SkPaint, (*sli.fPaint));
746 } 749 }
750
751 block.fSrcBounds = sli.fBounds;
747 block.fSaveLayerOpID = sli.fStartIndex; 752 block.fSaveLayerOpID = sli.fStartIndex;
748 block.fRestoreOpID = fFillBounds.currentOp(); 753 block.fRestoreOpID = fFillBounds.currentOp();
749 block.fHasNestedLayers = sli.fHasNestedSaveLayer; 754 block.fHasNestedLayers = sli.fHasNestedSaveLayer;
750 block.fIsNested = fSaveLayersInStack > 0; 755 block.fIsNested = fSaveLayersInStack > 0;
751 756
752 block.fKeySize = fSaveLayerOpStack.count(); 757 block.fKeySize = fSaveLayerOpStack.count();
753 block.fKey = SkNEW_ARRAY(unsigned, block.fKeySize); 758 block.fKey = SkNEW_ARRAY(unsigned, block.fKeySize);
754 memcpy(block.fKey, fSaveLayerOpStack.begin(), block.fKeySize * sizeof(un signed)); 759 memcpy(block.fKey, fSaveLayerOpStack.begin(), block.fKeySize * sizeof(un signed));
755 760
756 fSaveLayerOpStack.pop(); 761 fSaveLayerOpStack.pop();
(...skipping 29 matching lines...) Expand all
786 SkRecords::CollectLayers visitor(cullRect, record, pictList, data); 791 SkRecords::CollectLayers visitor(cullRect, record, pictList, data);
787 792
788 for (unsigned curOp = 0; curOp < record.count(); curOp++) { 793 for (unsigned curOp = 0; curOp < record.count(); curOp++) {
789 visitor.setCurrentOp(curOp); 794 visitor.setCurrentOp(curOp);
790 record.visit<void>(curOp, visitor); 795 record.visit<void>(curOp, visitor);
791 } 796 }
792 797
793 visitor.cleanUp(bbh); 798 visitor.cleanUp(bbh);
794 } 799 }
795 800
OLDNEW
« no previous file with comments | « src/core/SkLayerInfo.h ('k') | src/gpu/GrLayerCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698