diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-16 18:52:29 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-16 18:52:29 +0000 |
commit | 52cb2c7cdf87f1e7d4b5d24b3609aaa514a26c10 (patch) | |
tree | e08a00f732002604bb69738992362fbba3d9dc03 /include | |
parent | e504de0a50f268189399567f58183c8c6a27b2af (diff) |
Extended SkDeque's reverse iteration capability to SkClipStack
http://codereview.appspot.com/6409046/
git-svn-id: http://skia.googlecode.com/svn/trunk@4631 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkClipStack.h | 58 |
1 files changed, 51 insertions, 7 deletions
diff --git a/include/core/SkClipStack.h b/include/core/SkClipStack.h index 709db56a3f..7d1bbcfef2 100644 --- a/include/core/SkClipStack.h +++ b/include/core/SkClipStack.h @@ -38,14 +38,23 @@ public: void clipDevRect(const SkRect&, SkRegion::Op, bool doAA); void clipDevPath(const SkPath&, SkRegion::Op, bool doAA); - class B2FIter { +private: + struct Rec; + +public: + class Iter { public: + enum IterStart { + kFront_IterStart = SkDeque::Iter::kFront_IterStart, + kBack_IterStart = SkDeque::Iter::kBack_IterStart + }; + /** * Creates an uninitialized iterator. Must be reset() */ - B2FIter(); + Iter(); - B2FIter(const SkClipStack& stack); + Iter(const SkClipStack& stack, IterStart startLoc); struct Clip { Clip() : fRect(NULL), fPath(NULL), fOp(SkRegion::kIntersect_Op), @@ -68,20 +77,55 @@ public: * fRect==NULL fPath==NULL empty clip */ const Clip* next(); + const Clip* prev(); /** * Restarts the iterator on a clip stack. */ - void reset(const SkClipStack& stack); + void reset(const SkClipStack& stack, IterStart startLoc); private: Clip fClip; - SkDeque::F2BIter fIter; + SkDeque::Iter fIter; + + /** + * updateClip updates fClip to the current state of fIter. It unifies + * functionality needed by both next() and prev(). + */ + const Clip* updateClip(const SkClipStack::Rec* rec); + }; + + // Inherit privately from Iter to prevent access to reverse iteration + class B2FIter : private Iter { + public: + B2FIter() {} + + /** + * Wrap Iter's 2 parameter ctor to force initialization to the + * beginning of the deque + */ + B2FIter(const SkClipStack& stack) + : INHERITED(stack, kFront_IterStart) { + } + + using Iter::Clip; + using Iter::next; + + /** + * Wrap Iter::reset to force initialization to the + * beginning of the deque + */ + void reset(const SkClipStack& stack) { + this->INHERITED::reset(stack, kFront_IterStart); + } + + private: + + typedef Iter INHERITED; }; private: - friend class B2FIter; - struct Rec; + friend class Iter; SkDeque fDeque; int fSaveCount; |