blob: 55427c0b228d7a7d96c7a093a506353108ae40da [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
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
23struct GrPoint;
24
25/**
26 2D Path iterator. Porting layer creates a subclass of this. It allows Ganesh to
27 parse the top-level API's 2D paths. Supports lines, quadratics, and cubic
28 pieces and moves (multi-part paths).
29 */
30class GrPathIter {
31public:
bsalomon@google.comd302f142011-03-03 13:54:13 +000032
reed@google.comac10a2d2010-12-22 21:39:39 +000033 virtual ~GrPathIter() {};
34
bsalomon@google.comd302f142011-03-03 13:54:13 +000035 /**
bsalomon@google.com5aaa69e2011-03-04 20:29:08 +000036 * Iterates through the path. Should not be called after
37 * kEnd_Command has been returned once. This version retrieves the
38 * points for the command.
39 * @param points The points relevant to returned commend. See Command
40 * enum for number of points valid for each command.
41 * @return The next command of the path.
reed@google.comac10a2d2010-12-22 21:39:39 +000042 */
bsalomon@google.com5aaa69e2011-03-04 20:29:08 +000043 virtual GrPathCmd next(GrPoint points[4]) = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +000044
45 /**
46 * If the host API has knowledge of the convexity of the path
bsalomon@google.com5aaa69e2011-03-04 20:29:08 +000047 * it can be communicated by this hint. Gr can analyze the path
48 * as it is iterated. So it is not necessary to do additional work to
49 * compute convexity status if it isn't already determined.
reed@google.comac10a2d2010-12-22 21:39:39 +000050 *
51 * @return a hint about the convexity of the path.
bsalomon@google.comd302f142011-03-03 13:54:13 +000052 */
bsalomon@google.combf4338c2011-03-04 22:48:25 +000053 virtual GrConvexHint convexHint() const = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +000054
bsalomon@google.comd302f142011-03-03 13:54:13 +000055 /**
bsalomon@google.com5aaa69e2011-03-04 20:29:08 +000056 * Iterates through the path. Should not be called after
57 * kEnd_Command has been returned once. This version does not retrieve the
58 * points for the command.
59 * @return The next command of the path.
60 */
61 virtual GrPathCmd next() = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +000062
63 /**
64 Restarts iteration from the beginning.
65 */
66 virtual void rewind() = 0;
67
68};
69
70#endif