blob: 5261f0fd70895c6699be42d6036352871cf099b5 [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;
bsalomon@google.com06e17952011-04-27 21:13:04 +000024struct GrRect;
reed@google.comac10a2d2010-12-22 21:39:39 +000025
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 */
31class GrPathIter {
32public:
bsalomon@google.comd302f142011-03-03 13:54:13 +000033
reed@google.comac10a2d2010-12-22 21:39:39 +000034 virtual ~GrPathIter() {};
35
bsalomon@google.comd302f142011-03-03 13:54:13 +000036 /**
bsalomon@google.com5aaa69e2011-03-04 20:29:08 +000037 * 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.comac10a2d2010-12-22 21:39:39 +000043 */
bsalomon@google.com5aaa69e2011-03-04 20:29:08 +000044 virtual GrPathCmd next(GrPoint points[4]) = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +000045
46 /**
47 * If the host API has knowledge of the convexity of the path
bsalomon@google.com5aaa69e2011-03-04 20:29:08 +000048 * 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.comac10a2d2010-12-22 21:39:39 +000051 *
52 * @return a hint about the convexity of the path.
bsalomon@google.comd302f142011-03-03 13:54:13 +000053 */
bsalomon@google.combf4338c2011-03-04 22:48:25 +000054 virtual GrConvexHint convexHint() const = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +000055
bsalomon@google.comd302f142011-03-03 13:54:13 +000056 /**
bsalomon@google.com5aaa69e2011-03-04 20:29:08 +000057 * 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.comac10a2d2010-12-22 21:39:39 +000063
bsalomon@google.com06e17952011-04-27 21:13:04 +000064 /**
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.comac10a2d2010-12-22 21:39:39 +000070 /**
71 Restarts iteration from the beginning.
72 */
73 virtual void rewind() = 0;
74
75};
76
77#endif