blob: 4f98c5c7707b6f77e1aeecf676ef850f4415bf0f [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"
robertphillips@google.com0f191f32012-04-25 15:23:36 +000016#include "SkRegion.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000017
bsalomon@google.comd302f142011-03-03 13:54:13 +000018/**
19 * A clip is a list of paths and/or rects with set operations to combine them.
20 */
reed@google.comac10a2d2010-12-22 21:39:39 +000021class GrClipIterator {
22public:
reed@google.comac10a2d2010-12-22 21:39:39 +000023 virtual ~GrClipIterator() {}
24
25 /**
26 * Returns true if there are no more rects to process
27 */
bsalomon@google.comd302f142011-03-03 13:54:13 +000028 virtual bool isDone() const = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +000029
30 /**
bsalomon@google.comd302f142011-03-03 13:54:13 +000031 * Rewind the iterator to replay the set of clip elements again
reed@google.comac10a2d2010-12-22 21:39:39 +000032 */
33 virtual void rewind() = 0;
34
35 /**
bsalomon@google.comd302f142011-03-03 13:54:13 +000036 * Get the type of the current clip element
reed@google.comac10a2d2010-12-22 21:39:39 +000037 */
bsalomon@google.comd302f142011-03-03 13:54:13 +000038 virtual GrClipType getType() const = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +000039
40 /**
bsalomon@google.comd302f142011-03-03 13:54:13 +000041 * Return the current path. It is an error to call this when isDone() is
42 * true or when getType() is kRect_Type.
43 */
reed@google.com07f3ee12011-05-16 17:21:57 +000044 virtual const GrPath* getPath() = 0;
bsalomon@google.comd302f142011-03-03 13:54:13 +000045
46 /**
47 * Return the fill rule for the path. It is an error to call this when
48 * isDone() is true or when getType is kRect_Type.
49 */
50 virtual GrPathFill getPathFill() const = 0;
51
52 /**
53 * Return the current rect. It is an error to call this when isDone is true
54 * or when getType() is kPath_Type.
55 */
56 virtual void getRect(GrRect* rect) const = 0;
57
58 /**
59 * Gets the operation used to apply the current item to previously iterated
60 * items. Iterators should not produce a Replace op.
61 */
robertphillips@google.com0f191f32012-04-25 15:23:36 +000062 virtual SkRegion::Op getOp() const = 0;
bsalomon@google.comd302f142011-03-03 13:54:13 +000063
64 /**
robertphillips@google.comfa1d2912012-04-16 14:49:14 +000065 * Gets anti-aliasing setting desired for the current clip
66 */
67 virtual bool getDoAA() const = 0;
68
69 /**
bsalomon@google.com5aaa69e2011-03-04 20:29:08 +000070 * Call to move to the next element in the list, previous path iter can be
71 * made invalid.
reed@google.comac10a2d2010-12-22 21:39:39 +000072 */
73 virtual void next() = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +000074};
75
76/**
77 * Call to rewind iter, first checking to see if iter is NULL
78 */
79static inline void GrSafeRewind(GrClipIterator* iter) {
80 if (iter) {
81 iter->rewind();
82 }
83}
84
85#endif
86