OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrClip_DEFINED | 8 #ifndef GrClip_DEFINED |
9 #define GrClip_DEFINED | 9 #define GrClip_DEFINED |
10 | 10 |
11 #include "SkClipStack.h" | 11 #include "SkClipStack.h" |
12 #include "GrSurface.h" | |
13 | 12 |
14 struct SkIRect; | 13 struct SkIRect; |
15 | 14 |
16 /** | 15 /** |
17 * GrClip encapsulates the information required to construct the clip | 16 * GrClip encapsulates the information required to construct the clip |
18 * masks. 'A GrClip is either wide open, just an IRect, just a Rect, or a full c
lipstack. | 17 * masks. 'A GrClip is either wide open, just an IRect, just a Rect, or a full c
lipstack. |
19 * If the clip is a clipstack than the origin is used to translate the stack wit
h | 18 * If the clip is a clipstack than the origin is used to translate the stack wit
h |
20 * respect to device coordinates. This allows us to use a clip stack that is | 19 * respect to device coordinates. This allows us to use a clip stack that is |
21 * specified for a root device with a layer device that is restricted to a subse
t | 20 * specified for a root device with a layer device that is restricted to a subse
t |
22 * of the original canvas. For other clip types the origin will always be (0,0). | 21 * of the original canvas. For other clip types the origin will always be (0,0). |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 return (kWideOpen_ClipType == fClipType) || | 149 return (kWideOpen_ClipType == fClipType) || |
151 (kClipStack_ClipType == fClipType && this->clipStack()->isWideOpe
n()); | 150 (kClipStack_ClipType == fClipType && this->clipStack()->isWideOpe
n()); |
152 } | 151 } |
153 | 152 |
154 bool quickContains(const SkRect& rect) const { | 153 bool quickContains(const SkRect& rect) const { |
155 return (kWideOpen_ClipType == fClipType) || | 154 return (kWideOpen_ClipType == fClipType) || |
156 (kClipStack_ClipType == fClipType && this->clipStack()->quickCont
ains(rect)) || | 155 (kClipStack_ClipType == fClipType && this->clipStack()->quickCont
ains(rect)) || |
157 (kIRect_ClipType == fClipType && this->irect().contains(rect)); | 156 (kIRect_ClipType == fClipType && this->irect().contains(rect)); |
158 } | 157 } |
159 | 158 |
160 void getConservativeBounds(const GrSurface* surface, | |
161 SkIRect* devResult, | |
162 bool* isIntersectionOfRects = NULL) const { | |
163 this->getConservativeBounds(surface->width(), surface->height(), | |
164 devResult, isIntersectionOfRects); | |
165 } | |
166 | |
167 void getConservativeBounds(int width, int height, | 159 void getConservativeBounds(int width, int height, |
168 SkIRect* devResult, | 160 SkIRect* devResult, |
169 bool* isIntersectionOfRects = NULL) const; | 161 bool* isIntersectionOfRects = NULL) const; |
170 | 162 |
171 static const GrClip& WideOpen(); | 163 static const GrClip& WideOpen(); |
172 | 164 |
173 enum ClipType { | 165 enum ClipType { |
174 kClipStack_ClipType, | 166 kClipStack_ClipType, |
175 kWideOpen_ClipType, | 167 kWideOpen_ClipType, |
176 kIRect_ClipType, | 168 kIRect_ClipType, |
177 }; | 169 }; |
178 | 170 |
179 ClipType clipType() const { return fClipType; } | 171 ClipType clipType() const { return fClipType; } |
180 | 172 |
181 private: | 173 private: |
182 union Clip { | 174 union Clip { |
183 const SkClipStack* fStack; | 175 const SkClipStack* fStack; |
184 SkIRect fIRect; | 176 SkIRect fIRect; |
185 } fClip; | 177 } fClip; |
186 | 178 |
187 SkIPoint fOrigin; | 179 SkIPoint fOrigin; |
188 ClipType fClipType; | 180 ClipType fClipType; |
189 }; | 181 }; |
190 | 182 |
191 #endif | 183 #endif |
OLD | NEW |