OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #ifndef SkClipStack_DEFINED | 8 #ifndef SkClipStack_DEFINED |
9 #define SkClipStack_DEFINED | 9 #define SkClipStack_DEFINED |
10 | 10 |
11 #include "SkDeque.h" | 11 #include "SkDeque.h" |
12 #include "SkPath.h" | 12 #include "SkPath.h" |
13 #include "SkRect.h" | 13 #include "SkRect.h" |
14 #include "SkRRect.h" | 14 #include "SkRRect.h" |
15 #include "SkRegion.h" | 15 #include "SkRegion.h" |
16 #include "SkTDArray.h" | 16 #include "SkTDArray.h" |
17 #include "SkTLazy.h" | 17 #include "SkTLazy.h" |
18 | 18 |
| 19 class SkCanvasClipVisitor; |
19 | 20 |
20 // Because a single save/restore state can have multiple clips, this class | 21 // Because a single save/restore state can have multiple clips, this class |
21 // stores the stack depth (fSaveCount) and clips (fDeque) separately. | 22 // stores the stack depth (fSaveCount) and clips (fDeque) separately. |
22 // Each clip in fDeque stores the stack state to which it belongs | 23 // Each clip in fDeque stores the stack state to which it belongs |
23 // (i.e., the fSaveCount in force when it was added). Restores are thus | 24 // (i.e., the fSaveCount in force when it was added). Restores are thus |
24 // implemented by removing clips from fDeque that have an fSaveCount larger | 25 // implemented by removing clips from fDeque that have an fSaveCount larger |
25 // then the freshly decremented count. | 26 // then the freshly decremented count. |
26 class SK_API SkClipStack { | 27 class SK_API SkClipStack { |
27 public: | 28 public: |
28 enum BoundsType { | 29 enum BoundsType { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 Element(const SkPath& path, SkRegion::Op op, bool doAA) { | 68 Element(const SkPath& path, SkRegion::Op op, bool doAA) { |
68 this->initPath(0, path, op, doAA); | 69 this->initPath(0, path, op, doAA); |
69 } | 70 } |
70 | 71 |
71 bool operator== (const Element& element) const; | 72 bool operator== (const Element& element) const; |
72 bool operator!= (const Element& element) const { return !(*this == eleme
nt); } | 73 bool operator!= (const Element& element) const { return !(*this == eleme
nt); } |
73 | 74 |
74 //!< Call to get the type of the clip element. | 75 //!< Call to get the type of the clip element. |
75 Type getType() const { return fType; } | 76 Type getType() const { return fType; } |
76 | 77 |
| 78 //!< Call to get the save count associated with this clip element. |
| 79 int getSaveCount() const { return fSaveCount; } |
| 80 |
77 //!< Call if getType() is kPath to get the path. | 81 //!< Call if getType() is kPath to get the path. |
78 const SkPath& getPath() const { SkASSERT(kPath_Type == fType); return *f
Path.get(); } | 82 const SkPath& getPath() const { SkASSERT(kPath_Type == fType); return *f
Path.get(); } |
79 | 83 |
80 //!< Call if getType() is kRRect to get the round-rect. | 84 //!< Call if getType() is kRRect to get the round-rect. |
81 const SkRRect& getRRect() const { SkASSERT(kRRect_Type == fType); return
fRRect; } | 85 const SkRRect& getRRect() const { SkASSERT(kRRect_Type == fType); return
fRRect; } |
82 | 86 |
83 //!< Call if getType() is kRect to get the rect. | 87 //!< Call if getType() is kRect to get the rect. |
84 const SkRect& getRect() const { | 88 const SkRect& getRect() const { |
85 SkASSERT(kRect_Type == fType && (fRRect.isRect() || fRRect.isEmpty()
)); | 89 SkASSERT(kRect_Type == fType && (fRRect.isRect() || fRRect.isEmpty()
)); |
86 return fRRect.getBounds(); | 90 return fRRect.getBounds(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 153 } |
150 } | 154 } |
151 | 155 |
152 /** | 156 /** |
153 * Is the clip shape inverse filled. | 157 * Is the clip shape inverse filled. |
154 */ | 158 */ |
155 bool isInverseFilled() const { | 159 bool isInverseFilled() const { |
156 return kPath_Type == fType && fPath.get()->isInverseFillType(); | 160 return kPath_Type == fType && fPath.get()->isInverseFillType(); |
157 } | 161 } |
158 | 162 |
| 163 /** |
| 164 * Replay this clip into the visitor. |
| 165 */ |
| 166 void replay(SkCanvasClipVisitor*) const; |
| 167 |
159 private: | 168 private: |
160 friend class SkClipStack; | 169 friend class SkClipStack; |
161 | 170 |
162 SkTLazy<SkPath> fPath; | 171 SkTLazy<SkPath> fPath; |
163 SkRRect fRRect; | 172 SkRRect fRRect; |
164 int fSaveCount; // save count of stack when this element was
added. | 173 int fSaveCount; // save count of stack when this element was
added. |
165 SkRegion::Op fOp; | 174 SkRegion::Op fOp; |
166 Type fType; | 175 Type fType; |
167 bool fDoAA; | 176 bool fDoAA; |
168 | 177 |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 */ | 451 */ |
443 void restoreTo(int saveCount); | 452 void restoreTo(int saveCount); |
444 | 453 |
445 /** | 454 /** |
446 * Return the next unique generation ID. | 455 * Return the next unique generation ID. |
447 */ | 456 */ |
448 static int32_t GetNextGenID(); | 457 static int32_t GetNextGenID(); |
449 }; | 458 }; |
450 | 459 |
451 #endif | 460 #endif |
OLD | NEW |