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 | |
bsalomon@google.com | 57788b5 | 2011-02-22 21:00:31 +0000 | [diff] [blame] | 7 | struct SkRect; |
reed@google.com | 5c3d147 | 2011-02-22 19:12:23 +0000 | [diff] [blame] | 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: |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame^] | 32 | /** |
| 33 | * Creates an uninitialized iterator. Must be reset() |
| 34 | */ |
| 35 | B2FIter(); |
| 36 | |
reed@google.com | 5c3d147 | 2011-02-22 19:12:23 +0000 | [diff] [blame] | 37 | B2FIter(const SkClipStack& stack); |
| 38 | |
| 39 | struct Clip { |
| 40 | const SkRect* fRect; // if non-null, this is a rect clip |
| 41 | const SkPath* fPath; // if non-null, this is a path clip |
| 42 | SkRegion::Op fOp; |
| 43 | }; |
| 44 | |
| 45 | /** |
| 46 | * Return the clip for this element in the iterator. If next() returns |
| 47 | * NULL, then the iterator is done. The type of clip is determined by |
| 48 | * the pointers fRect and fPath: |
| 49 | * |
| 50 | * fRect==NULL fPath!=NULL path clip |
| 51 | * fRect!=NULL fPath==NULL rect clip |
| 52 | * fRect==NULL fPath==NULL empty clip |
| 53 | */ |
| 54 | const Clip* next(); |
| 55 | |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame^] | 56 | /** |
| 57 | * Restarts the iterator on a clip stack. |
| 58 | */ |
| 59 | void reset(const SkClipStack& stack); |
| 60 | |
reed@google.com | 5c3d147 | 2011-02-22 19:12:23 +0000 | [diff] [blame] | 61 | private: |
| 62 | Clip fClip; |
| 63 | SkDeque::F2BIter fIter; |
| 64 | }; |
| 65 | |
| 66 | private: |
| 67 | friend class B2FIter; |
| 68 | struct Rec; |
| 69 | |
| 70 | SkDeque fDeque; |
| 71 | int fSaveCount; |
| 72 | }; |
| 73 | |
| 74 | #endif |
| 75 | |