epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2010 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 10 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 11 | #ifndef GrClipIterator_DEFINED |
| 12 | #define GrClipIterator_DEFINED |
| 13 | |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 14 | #include "GrPath.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 15 | #include "GrRect.h" |
| 16 | |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 17 | /** |
| 18 | * A clip is a list of paths and/or rects with set operations to combine them. |
| 19 | */ |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 20 | class GrClipIterator { |
| 21 | public: |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 22 | virtual ~GrClipIterator() {} |
| 23 | |
| 24 | /** |
| 25 | * Returns true if there are no more rects to process |
| 26 | */ |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 27 | virtual bool isDone() const = 0; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 28 | |
| 29 | /** |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 30 | * Rewind the iterator to replay the set of clip elements again |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 31 | */ |
| 32 | virtual void rewind() = 0; |
| 33 | |
| 34 | /** |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 35 | * Get the type of the current clip element |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 36 | */ |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 37 | virtual GrClipType getType() const = 0; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 38 | |
| 39 | /** |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 40 | * Return the current path. It is an error to call this when isDone() is |
| 41 | * true or when getType() is kRect_Type. |
| 42 | */ |
reed@google.com | 07f3ee1 | 2011-05-16 17:21:57 +0000 | [diff] [blame] | 43 | virtual const GrPath* getPath() = 0; |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 44 | |
| 45 | /** |
| 46 | * Return the fill rule for the path. It is an error to call this when |
| 47 | * isDone() is true or when getType is kRect_Type. |
| 48 | */ |
| 49 | virtual GrPathFill getPathFill() const = 0; |
| 50 | |
| 51 | /** |
| 52 | * Return the current rect. It is an error to call this when isDone is true |
| 53 | * or when getType() is kPath_Type. |
| 54 | */ |
| 55 | virtual void getRect(GrRect* rect) const = 0; |
| 56 | |
| 57 | /** |
| 58 | * Gets the operation used to apply the current item to previously iterated |
| 59 | * items. Iterators should not produce a Replace op. |
| 60 | */ |
| 61 | virtual GrSetOp getOp() const = 0; |
| 62 | |
| 63 | /** |
bsalomon@google.com | 5aaa69e | 2011-03-04 20:29:08 +0000 | [diff] [blame] | 64 | * Call to move to the next element in the list, previous path iter can be |
| 65 | * made invalid. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 66 | */ |
| 67 | virtual void next() = 0; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | /** |
| 71 | * Call to rewind iter, first checking to see if iter is NULL |
| 72 | */ |
| 73 | static inline void GrSafeRewind(GrClipIterator* iter) { |
| 74 | if (iter) { |
| 75 | iter->rewind(); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | #endif |
| 80 | |