blob: 4a5cc7135f0135fa36a6c40d8ee7542c22b1e061 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@google.comac10a2d2010-12-22 21:39:39 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2010 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@google.comac10a2d2010-12-22 21:39:39 +00007 */
8
9
epoger@google.comec3ed6a2011-07-28 14:26:00 +000010
reed@google.comac10a2d2010-12-22 21:39:39 +000011#ifndef GrClipIterator_DEFINED
12#define GrClipIterator_DEFINED
13
bsalomon@google.comd302f142011-03-03 13:54:13 +000014#include "GrPath.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000015#include "GrRect.h"
16
bsalomon@google.comd302f142011-03-03 13:54:13 +000017/**
18 * A clip is a list of paths and/or rects with set operations to combine them.
19 */
reed@google.comac10a2d2010-12-22 21:39:39 +000020class GrClipIterator {
21public:
reed@google.comac10a2d2010-12-22 21:39:39 +000022 virtual ~GrClipIterator() {}
23
24 /**
25 * Returns true if there are no more rects to process
26 */
bsalomon@google.comd302f142011-03-03 13:54:13 +000027 virtual bool isDone() const = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +000028
29 /**
bsalomon@google.comd302f142011-03-03 13:54:13 +000030 * Rewind the iterator to replay the set of clip elements again
reed@google.comac10a2d2010-12-22 21:39:39 +000031 */
32 virtual void rewind() = 0;
33
34 /**
bsalomon@google.comd302f142011-03-03 13:54:13 +000035 * Get the type of the current clip element
reed@google.comac10a2d2010-12-22 21:39:39 +000036 */
bsalomon@google.comd302f142011-03-03 13:54:13 +000037 virtual GrClipType getType() const = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +000038
39 /**
bsalomon@google.comd302f142011-03-03 13:54:13 +000040 * Return the current path. It is an error to call this when isDone() is
41 * true or when getType() is kRect_Type.
42 */
reed@google.com07f3ee12011-05-16 17:21:57 +000043 virtual const GrPath* getPath() = 0;
bsalomon@google.comd302f142011-03-03 13:54:13 +000044
45 /**
46 * Return the fill rule for the path. It is an error to call this when
47 * isDone() is true or when getType is kRect_Type.
48 */
49 virtual GrPathFill getPathFill() const = 0;
50
51 /**
52 * Return the current rect. It is an error to call this when isDone is true
53 * or when getType() is kPath_Type.
54 */
55 virtual void getRect(GrRect* rect) const = 0;
56
57 /**
58 * Gets the operation used to apply the current item to previously iterated
59 * items. Iterators should not produce a Replace op.
60 */
61 virtual GrSetOp getOp() const = 0;
62
63 /**
bsalomon@google.com5aaa69e2011-03-04 20:29:08 +000064 * Call to move to the next element in the list, previous path iter can be
65 * made invalid.
reed@google.comac10a2d2010-12-22 21:39:39 +000066 */
67 virtual void next() = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +000068};
69
70/**
71 * Call to rewind iter, first checking to see if iter is NULL
72 */
73static inline void GrSafeRewind(GrClipIterator* iter) {
74 if (iter) {
75 iter->rewind();
76 }
77}
78
79#endif
80