1 #ifndef SkClipStack_DEFINED 2 #define SkClipStack_DEFINED 3 4 #include "SkDeque.h" 5 #include "SkRegion.h" 6 7 struct SkRect; 8 class SkPath; 9 10 class SK_API SkClipStack { 11 public: 12 SkClipStack(); 13 SkClipStack(const SkClipStack& b); ~SkClipStack()14 ~SkClipStack() {} 15 16 SkClipStack& operator=(const SkClipStack& b); 17 bool operator==(const SkClipStack& b) const; 18 bool operator!=(const SkClipStack& b) const { return !(*this == b); } 19 20 void reset(); 21 getSaveCount()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: 37 /** 38 * Creates an uninitialized iterator. Must be reset() 39 */ 40 B2FIter(); 41 42 B2FIter(const SkClipStack& stack); 43 44 struct Clip { 45 friend bool operator==(const Clip& a, const Clip& b); 46 friend bool operator!=(const Clip& a, const Clip& b); 47 const SkRect* fRect; // if non-null, this is a rect clip 48 const SkPath* fPath; // if non-null, this is a path clip 49 SkRegion::Op fOp; 50 }; 51 52 /** 53 * Return the clip for this element in the iterator. If next() returns 54 * NULL, then the iterator is done. The type of clip is determined by 55 * the pointers fRect and fPath: 56 * 57 * fRect==NULL fPath!=NULL path clip 58 * fRect!=NULL fPath==NULL rect clip 59 * fRect==NULL fPath==NULL empty clip 60 */ 61 const Clip* next(); 62 63 /** 64 * Restarts the iterator on a clip stack. 65 */ 66 void reset(const SkClipStack& stack); 67 68 private: 69 Clip fClip; 70 SkDeque::F2BIter fIter; 71 }; 72 73 private: 74 friend class B2FIter; 75 struct Rec; 76 77 SkDeque fDeque; 78 int fSaveCount; 79 }; 80 81 #endif 82 83