blob: f7f74a76b1dd7839636fd782ce6f661e6400fca6 [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 GrClipIterator_DEFINED
19#define GrClipIterator_DEFINED
20
bsalomon@google.comd302f142011-03-03 13:54:13 +000021#include "GrPath.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000022#include "GrRect.h"
23
bsalomon@google.comd302f142011-03-03 13:54:13 +000024/**
25 * A clip is a list of paths and/or rects with set operations to combine them.
26 */
reed@google.comac10a2d2010-12-22 21:39:39 +000027class GrClipIterator {
28public:
reed@google.comac10a2d2010-12-22 21:39:39 +000029 virtual ~GrClipIterator() {}
30
31 /**
32 * Returns true if there are no more rects to process
33 */
bsalomon@google.comd302f142011-03-03 13:54:13 +000034 virtual bool isDone() const = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +000035
36 /**
bsalomon@google.comd302f142011-03-03 13:54:13 +000037 * Rewind the iterator to replay the set of clip elements again
reed@google.comac10a2d2010-12-22 21:39:39 +000038 */
39 virtual void rewind() = 0;
40
41 /**
bsalomon@google.comd302f142011-03-03 13:54:13 +000042 * Get the type of the current clip element
reed@google.comac10a2d2010-12-22 21:39:39 +000043 */
bsalomon@google.comd302f142011-03-03 13:54:13 +000044 virtual GrClipType getType() const = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +000045
46 /**
bsalomon@google.comd302f142011-03-03 13:54:13 +000047 * 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.com07f3ee12011-05-16 17:21:57 +000050 virtual const GrPath* getPath() = 0;
bsalomon@google.comd302f142011-03-03 13:54:13 +000051
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.com5aaa69e2011-03-04 20:29:08 +000071 * Call to move to the next element in the list, previous path iter can be
72 * made invalid.
reed@google.comac10a2d2010-12-22 21:39:39 +000073 */
74 virtual void next() = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +000075};
76
77/**
78 * Call to rewind iter, first checking to see if iter is NULL
79 */
80static inline void GrSafeRewind(GrClipIterator* iter) {
81 if (iter) {
82 iter->rewind();
83 }
84}
85
86#endif
87