blob: e67ff698560ceaa7a25ca97e969cf3fe89f99e74 [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
reed@google.com20efde72011-05-09 17:00:02 +000021#include "GrRect.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000022
23/**
24 2D Path iterator. Porting layer creates a subclass of this. It allows Ganesh to
25 parse the top-level API's 2D paths. Supports lines, quadratics, and cubic
26 pieces and moves (multi-part paths).
27 */
28class GrPathIter {
29public:
bsalomon@google.comd302f142011-03-03 13:54:13 +000030
reed@google.comac10a2d2010-12-22 21:39:39 +000031 virtual ~GrPathIter() {};
32
bsalomon@google.comd302f142011-03-03 13:54:13 +000033 /**
bsalomon@google.com5aaa69e2011-03-04 20:29:08 +000034 * Iterates through the path. Should not be called after
35 * kEnd_Command has been returned once. This version retrieves the
36 * points for the command.
37 * @param points The points relevant to returned commend. See Command
38 * enum for number of points valid for each command.
39 * @return The next command of the path.
reed@google.comac10a2d2010-12-22 21:39:39 +000040 */
bsalomon@google.com5aaa69e2011-03-04 20:29:08 +000041 virtual GrPathCmd next(GrPoint points[4]) = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +000042
43 /**
44 * If the host API has knowledge of the convexity of the path
bsalomon@google.com5aaa69e2011-03-04 20:29:08 +000045 * it can be communicated by this hint. Gr can analyze the path
46 * as it is iterated. So it is not necessary to do additional work to
47 * compute convexity status if it isn't already determined.
reed@google.comac10a2d2010-12-22 21:39:39 +000048 *
49 * @return a hint about the convexity of the path.
bsalomon@google.comd302f142011-03-03 13:54:13 +000050 */
bsalomon@google.combf4338c2011-03-04 22:48:25 +000051 virtual GrConvexHint convexHint() const = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +000052
bsalomon@google.comd302f142011-03-03 13:54:13 +000053 /**
bsalomon@google.com5aaa69e2011-03-04 20:29:08 +000054 * Iterates through the path. Should not be called after
55 * kEnd_Command has been returned once. This version does not retrieve the
56 * points for the command.
57 * @return The next command of the path.
58 */
59 virtual GrPathCmd next() = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +000060
bsalomon@google.com06e17952011-04-27 21:13:04 +000061 /**
62 * Returns conservative bounds on the path points. If returns false then
63 * no bounds are available.
64 */
65 virtual bool getConservativeBounds(GrRect* rect) const = 0;
66
reed@google.comac10a2d2010-12-22 21:39:39 +000067 /**
68 Restarts iteration from the beginning.
69 */
70 virtual void rewind() = 0;
71
72};
73
74#endif