reed@google.com | 5c3d147 | 2011-02-22 19:12:23 +0000 | [diff] [blame^] | 1 | #ifndef SkClipStack_DEFINED |
| 2 | #define SkClipStack_DEFINED |
| 3 | |
| 4 | #include "SkDeque.h" |
| 5 | #include "SkRegion.h" |
| 6 | |
| 7 | class SkRect; |
| 8 | class SkPath; |
| 9 | |
| 10 | class SkClipStack { |
| 11 | public: |
| 12 | SkClipStack(); |
| 13 | ~SkClipStack() {} |
| 14 | |
| 15 | void reset(); |
| 16 | |
| 17 | int getSaveCount() const { return fSaveCount; } |
| 18 | void save(); |
| 19 | void restore(); |
| 20 | |
| 21 | void clipDevRect(const SkIRect& ir, |
| 22 | SkRegion::Op op = SkRegion::kIntersect_Op) { |
| 23 | SkRect r; |
| 24 | r.set(ir); |
| 25 | this->clipDevRect(r, op); |
| 26 | } |
| 27 | void clipDevRect(const SkRect&, SkRegion::Op = SkRegion::kIntersect_Op); |
| 28 | void clipDevPath(const SkPath&, SkRegion::Op = SkRegion::kIntersect_Op); |
| 29 | |
| 30 | class B2FIter { |
| 31 | public: |
| 32 | B2FIter(const SkClipStack& stack); |
| 33 | |
| 34 | struct Clip { |
| 35 | const SkRect* fRect; // if non-null, this is a rect clip |
| 36 | const SkPath* fPath; // if non-null, this is a path clip |
| 37 | SkRegion::Op fOp; |
| 38 | }; |
| 39 | |
| 40 | /** |
| 41 | * Return the clip for this element in the iterator. If next() returns |
| 42 | * NULL, then the iterator is done. The type of clip is determined by |
| 43 | * the pointers fRect and fPath: |
| 44 | * |
| 45 | * fRect==NULL fPath!=NULL path clip |
| 46 | * fRect!=NULL fPath==NULL rect clip |
| 47 | * fRect==NULL fPath==NULL empty clip |
| 48 | */ |
| 49 | const Clip* next(); |
| 50 | |
| 51 | private: |
| 52 | Clip fClip; |
| 53 | SkDeque::F2BIter fIter; |
| 54 | }; |
| 55 | |
| 56 | private: |
| 57 | friend class B2FIter; |
| 58 | struct Rec; |
| 59 | |
| 60 | SkDeque fDeque; |
| 61 | int fSaveCount; |
| 62 | }; |
| 63 | |
| 64 | #endif |
| 65 | |