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 GrPathIter_DEFINED |
| 19 | #define GrPathIter_DEFINED |
| 20 | |
| 21 | #include "GrTypes.h" |
| 22 | |
| 23 | struct GrPoint; |
bsalomon@google.com | 06e1795 | 2011-04-27 21:13:04 +0000 | [diff] [blame] | 24 | struct GrRect; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | 2D Path iterator. Porting layer creates a subclass of this. It allows Ganesh to |
| 28 | parse the top-level API's 2D paths. Supports lines, quadratics, and cubic |
| 29 | pieces and moves (multi-part paths). |
| 30 | */ |
| 31 | class GrPathIter { |
| 32 | public: |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 33 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 34 | virtual ~GrPathIter() {}; |
| 35 | |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 36 | /** |
bsalomon@google.com | 5aaa69e | 2011-03-04 20:29:08 +0000 | [diff] [blame] | 37 | * Iterates through the path. Should not be called after |
| 38 | * kEnd_Command has been returned once. This version retrieves the |
| 39 | * points for the command. |
| 40 | * @param points The points relevant to returned commend. See Command |
| 41 | * enum for number of points valid for each command. |
| 42 | * @return The next command of the path. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 43 | */ |
bsalomon@google.com | 5aaa69e | 2011-03-04 20:29:08 +0000 | [diff] [blame] | 44 | virtual GrPathCmd next(GrPoint points[4]) = 0; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * If the host API has knowledge of the convexity of the path |
bsalomon@google.com | 5aaa69e | 2011-03-04 20:29:08 +0000 | [diff] [blame] | 48 | * it can be communicated by this hint. Gr can analyze the path |
| 49 | * as it is iterated. So it is not necessary to do additional work to |
| 50 | * compute convexity status if it isn't already determined. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 51 | * |
| 52 | * @return a hint about the convexity of the path. |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 53 | */ |
bsalomon@google.com | bf4338c | 2011-03-04 22:48:25 +0000 | [diff] [blame] | 54 | virtual GrConvexHint convexHint() const = 0; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 55 | |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 56 | /** |
bsalomon@google.com | 5aaa69e | 2011-03-04 20:29:08 +0000 | [diff] [blame] | 57 | * Iterates through the path. Should not be called after |
| 58 | * kEnd_Command has been returned once. This version does not retrieve the |
| 59 | * points for the command. |
| 60 | * @return The next command of the path. |
| 61 | */ |
| 62 | virtual GrPathCmd next() = 0; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 63 | |
bsalomon@google.com | 06e1795 | 2011-04-27 21:13:04 +0000 | [diff] [blame] | 64 | /** |
| 65 | * Returns conservative bounds on the path points. If returns false then |
| 66 | * no bounds are available. |
| 67 | */ |
| 68 | virtual bool getConservativeBounds(GrRect* rect) const = 0; |
| 69 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 70 | /** |
| 71 | Restarts iteration from the beginning. |
| 72 | */ |
| 73 | virtual void rewind() = 0; |
| 74 | |
| 75 | }; |
| 76 | |
| 77 | #endif |