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

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

Issue 876923003: [SkSVGDevice] Initial clipping support (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: win build warning Created 5 years, 10 months 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/SkCanvas.cpp ('k') | no next file » | 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 2011 Google Inc. 2 * Copyright 2011 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkClipStack.h" 9 #include "SkClipStack.h"
10 #include "SkPath.h" 10 #include "SkPath.h"
11 #include "SkPathOps.h"
11 #include "SkThread.h" 12 #include "SkThread.h"
12 13
13 #include <new> 14 #include <new>
14 15
15 16
16 // 0-2 are reserved for invalid, empty & wide-open 17 // 0-2 are reserved for invalid, empty & wide-open
17 static const int32_t kFirstUnreservedGenID = 3; 18 static const int32_t kFirstUnreservedGenID = 3;
18 int32_t SkClipStack::gGenID = kFirstUnreservedGenID; 19 int32_t SkClipStack::gGenID = kFirstUnreservedGenID;
19 20
20 SkClipStack::Element::Element(const Element& that) { 21 SkClipStack::Element::Element(const Element& that) {
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 } 659 }
659 } 660 }
660 if (SkRegion::kReplace_Op == element->getOp()) { 661 if (SkRegion::kReplace_Op == element->getOp()) {
661 break; 662 break;
662 } 663 }
663 element = iter.prev(); 664 element = iter.prev();
664 } 665 }
665 return true; 666 return true;
666 } 667 }
667 668
669 bool SkClipStack::asPath(SkPath *path) const {
670 bool isAA = false;
671
672 path->reset();
673 path->setFillType(SkPath::kInverseEvenOdd_FillType);
674
675 SkClipStack::Iter iter(*this, SkClipStack::Iter::kBottom_IterStart);
676 while (const SkClipStack::Element* element = iter.next()) {
677 SkPath operand;
678 if (element->getType() != SkClipStack::Element::kEmpty_Type) {
679 element->asPath(&operand);
680 }
681
682 SkRegion::Op elementOp = element->getOp();
683 if (elementOp == SkRegion::kReplace_Op) {
684 *path = operand;
685 } else {
686 Op(*path, operand, (SkPathOp)elementOp, path);
687 }
688
689 // if the prev and curr clips disagree about aa -vs- not, favor the aa r equest.
690 // perhaps we need an API change to avoid this sort of mixed-signals abo ut
691 // clipping.
692 isAA = (isAA || element->isAA());
693 }
694
695 return isAA;
696 }
697
668 void SkClipStack::pushElement(const Element& element) { 698 void SkClipStack::pushElement(const Element& element) {
669 // Use reverse iterator instead of back because Rect path may need previous 699 // Use reverse iterator instead of back because Rect path may need previous
670 SkDeque::Iter iter(fDeque, SkDeque::Iter::kBack_IterStart); 700 SkDeque::Iter iter(fDeque, SkDeque::Iter::kBack_IterStart);
671 Element* prior = (Element*) iter.prev(); 701 Element* prior = (Element*) iter.prev();
672 702
673 if (prior) { 703 if (prior) {
674 if (prior->canBeIntersectedInPlace(fSaveCount, element.getOp())) { 704 if (prior->canBeIntersectedInPlace(fSaveCount, element.getOp())) {
675 switch (prior->fType) { 705 switch (prior->fType) {
676 case Element::kEmpty_Type: 706 case Element::kEmpty_Type:
677 SkDEBUGCODE(prior->checkEmpty();) 707 SkDEBUGCODE(prior->checkEmpty();)
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 931
902 void SkClipStack::dump() const { 932 void SkClipStack::dump() const {
903 B2TIter iter(*this); 933 B2TIter iter(*this);
904 const Element* e; 934 const Element* e;
905 while ((e = iter.next())) { 935 while ((e = iter.next())) {
906 e->dump(); 936 e->dump();
907 SkDebugf("\n"); 937 SkDebugf("\n");
908 } 938 }
909 } 939 }
910 #endif 940 #endif
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698