| 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" |
| robertphillips@google.com | 0f191f3 | 2012-04-25 15:23:36 +0000 | [diff] [blame^] | 16 | #include "SkRegion.h" |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 17 | |
| bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 18 | /** |
| 19 | * A clip is a list of paths and/or rects with set operations to combine them. |
| 20 | */ |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 21 | class GrClipIterator { |
| 22 | public: |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 23 | virtual ~GrClipIterator() {} |
| 24 | |
| 25 | /** |
| 26 | * Returns true if there are no more rects to process |
| 27 | */ |
| bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 28 | virtual bool isDone() const = 0; |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 29 | |
| 30 | /** |
| bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 31 | * Rewind the iterator to replay the set of clip elements again |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 32 | */ |
| 33 | virtual void rewind() = 0; |
| 34 | |
| 35 | /** |
| bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 36 | * Get the type of the current clip element |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 37 | */ |
| bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 38 | virtual GrClipType getType() const = 0; |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 39 | |
| 40 | /** |
| bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 41 | * Return the current path. It is an error to call this when isDone() is |
| 42 | * true or when getType() is kRect_Type. |
| 43 | */ |
| reed@google.com | 07f3ee1 | 2011-05-16 17:21:57 +0000 | [diff] [blame] | 44 | virtual const GrPath* getPath() = 0; |
| bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * Return the fill rule for the path. It is an error to call this when |
| 48 | * isDone() is true or when getType is kRect_Type. |
| 49 | */ |
| 50 | virtual GrPathFill getPathFill() const = 0; |
| 51 | |
| 52 | /** |
| 53 | * Return the current rect. It is an error to call this when isDone is true |
| 54 | * or when getType() is kPath_Type. |
| 55 | */ |
| 56 | virtual void getRect(GrRect* rect) const = 0; |
| 57 | |
| 58 | /** |
| 59 | * Gets the operation used to apply the current item to previously iterated |
| 60 | * items. Iterators should not produce a Replace op. |
| 61 | */ |
| robertphillips@google.com | 0f191f3 | 2012-04-25 15:23:36 +0000 | [diff] [blame^] | 62 | virtual SkRegion::Op getOp() const = 0; |
| bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 63 | |
| 64 | /** |
| robertphillips@google.com | fa1d291 | 2012-04-16 14:49:14 +0000 | [diff] [blame] | 65 | * Gets anti-aliasing setting desired for the current clip |
| 66 | */ |
| 67 | virtual bool getDoAA() const = 0; |
| 68 | |
| 69 | /** |
| bsalomon@google.com | 5aaa69e | 2011-03-04 20:29:08 +0000 | [diff] [blame] | 70 | * Call to move to the next element in the list, previous path iter can be |
| 71 | * made invalid. |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 72 | */ |
| 73 | virtual void next() = 0; |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | /** |
| 77 | * Call to rewind iter, first checking to see if iter is NULL |
| 78 | */ |
| 79 | static inline void GrSafeRewind(GrClipIterator* iter) { |
| 80 | if (iter) { |
| 81 | iter->rewind(); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | #endif |
| 86 | |