| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2010 Google Inc. |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | |
| 18 | #ifndef GrClipIterator_DEFINED |
| 19 | #define GrClipIterator_DEFINED |
| 20 | |
| bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 21 | #include "GrPath.h" |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 22 | #include "GrRect.h" |
| 23 | |
| bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 24 | /** |
| 25 | * A clip is a list of paths and/or rects with set operations to combine them. |
| 26 | */ |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 27 | class GrClipIterator { |
| 28 | public: |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 29 | virtual ~GrClipIterator() {} |
| 30 | |
| 31 | /** |
| 32 | * Returns true if there are no more rects to process |
| 33 | */ |
| bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 34 | virtual bool isDone() const = 0; |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 35 | |
| 36 | /** |
| bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 37 | * Rewind the iterator to replay the set of clip elements again |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 38 | */ |
| 39 | virtual void rewind() = 0; |
| 40 | |
| 41 | /** |
| bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 42 | * Get the type of the current clip element |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 43 | */ |
| bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 44 | virtual GrClipType getType() const = 0; |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 45 | |
| 46 | /** |
| bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 47 | * Return the current path. It is an error to call this when isDone() is |
| 48 | * true or when getType() is kRect_Type. |
| 49 | */ |
| reed@google.com | 07f3ee1 | 2011-05-16 17:21:57 +0000 | [diff] [blame^] | 50 | virtual const GrPath* getPath() = 0; |
| bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 51 | |
| 52 | /** |
| 53 | * Return the fill rule for the path. It is an error to call this when |
| 54 | * isDone() is true or when getType is kRect_Type. |
| 55 | */ |
| 56 | virtual GrPathFill getPathFill() const = 0; |
| 57 | |
| 58 | /** |
| 59 | * Return the current rect. It is an error to call this when isDone is true |
| 60 | * or when getType() is kPath_Type. |
| 61 | */ |
| 62 | virtual void getRect(GrRect* rect) const = 0; |
| 63 | |
| 64 | /** |
| 65 | * Gets the operation used to apply the current item to previously iterated |
| 66 | * items. Iterators should not produce a Replace op. |
| 67 | */ |
| 68 | virtual GrSetOp getOp() const = 0; |
| 69 | |
| 70 | /** |
| bsalomon@google.com | 5aaa69e | 2011-03-04 20:29:08 +0000 | [diff] [blame] | 71 | * Call to move to the next element in the list, previous path iter can be |
| 72 | * made invalid. |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 73 | */ |
| 74 | virtual void next() = 0; |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | /** |
| 78 | * Call to rewind iter, first checking to see if iter is NULL |
| 79 | */ |
| 80 | static inline void GrSafeRewind(GrClipIterator* iter) { |
| 81 | if (iter) { |
| 82 | iter->rewind(); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | #endif |
| 87 | |