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 | |
ctguil@chromium.org | 7ffb1b2 | 2011-03-15 21:27:08 +0000 | [diff] [blame] | 10 | class SK_API SkClipStack { |
reed@google.com | 5c3d147 | 2011-02-22 19:12:23 +0000 | [diff] [blame] | 11 | public: |
| 12 | SkClipStack(); |
vandebo@chromium.org | 1e1c36f | 2011-05-03 16:26:09 +0000 | [diff] [blame^] | 13 | SkClipStack(const SkClipStack& b); |
reed@google.com | 5c3d147 | 2011-02-22 19:12:23 +0000 | [diff] [blame] | 14 | ~SkClipStack() {} |
| 15 | |
vandebo@chromium.org | 1e1c36f | 2011-05-03 16:26:09 +0000 | [diff] [blame^] | 16 | SkClipStack& operator=(const SkClipStack& b); |
| 17 | bool operator==(const SkClipStack& b) const; |
| 18 | bool operator!=(const SkClipStack& b) const { return !(*this == b); } |
| 19 | |
reed@google.com | 5c3d147 | 2011-02-22 19:12:23 +0000 | [diff] [blame] | 20 | void reset(); |
| 21 | |
| 22 | int getSaveCount() const { return fSaveCount; } |
| 23 | void save(); |
| 24 | void restore(); |
| 25 | |
| 26 | void clipDevRect(const SkIRect& ir, |
| 27 | SkRegion::Op op = SkRegion::kIntersect_Op) { |
| 28 | SkRect r; |
| 29 | r.set(ir); |
| 30 | this->clipDevRect(r, op); |
| 31 | } |
| 32 | void clipDevRect(const SkRect&, SkRegion::Op = SkRegion::kIntersect_Op); |
| 33 | void clipDevPath(const SkPath&, SkRegion::Op = SkRegion::kIntersect_Op); |
| 34 | |
| 35 | class B2FIter { |
| 36 | public: |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 37 | /** |
| 38 | * Creates an uninitialized iterator. Must be reset() |
| 39 | */ |
| 40 | B2FIter(); |
| 41 | |
reed@google.com | 5c3d147 | 2011-02-22 19:12:23 +0000 | [diff] [blame] | 42 | B2FIter(const SkClipStack& stack); |
| 43 | |
| 44 | struct Clip { |
| 45 | const SkRect* fRect; // if non-null, this is a rect clip |
| 46 | const SkPath* fPath; // if non-null, this is a path clip |
| 47 | SkRegion::Op fOp; |
| 48 | }; |
| 49 | |
| 50 | /** |
| 51 | * Return the clip for this element in the iterator. If next() returns |
| 52 | * NULL, then the iterator is done. The type of clip is determined by |
| 53 | * the pointers fRect and fPath: |
| 54 | * |
| 55 | * fRect==NULL fPath!=NULL path clip |
| 56 | * fRect!=NULL fPath==NULL rect clip |
| 57 | * fRect==NULL fPath==NULL empty clip |
| 58 | */ |
| 59 | const Clip* next(); |
| 60 | |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 61 | /** |
| 62 | * Restarts the iterator on a clip stack. |
| 63 | */ |
| 64 | void reset(const SkClipStack& stack); |
| 65 | |
reed@google.com | 5c3d147 | 2011-02-22 19:12:23 +0000 | [diff] [blame] | 66 | private: |
| 67 | Clip fClip; |
| 68 | SkDeque::F2BIter fIter; |
| 69 | }; |
| 70 | |
| 71 | private: |
| 72 | friend class B2FIter; |
| 73 | struct Rec; |
| 74 | |
| 75 | SkDeque fDeque; |
| 76 | int fSaveCount; |
| 77 | }; |
| 78 | |
| 79 | #endif |
| 80 | |