OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 GrClipMaskManager_DEFINED | 8 #ifndef GrClipMaskManager_DEFINED |
9 #define GrClipMaskManager_DEFINED | 9 #define GrClipMaskManager_DEFINED |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 * aliasing is requested it will (in the future) generate a single channel | 33 * aliasing is requested it will (in the future) generate a single channel |
34 * (8bit) mask. If no anti aliasing is requested it will generate a 1-bit | 34 * (8bit) mask. If no anti aliasing is requested it will generate a 1-bit |
35 * mask in the stencil buffer. In the non anti-aliasing case, if the clip | 35 * mask in the stencil buffer. In the non anti-aliasing case, if the clip |
36 * mask can be represented as a rectangle then scissoring is used. In all | 36 * mask can be represented as a rectangle then scissoring is used. In all |
37 * cases scissoring is used to bound the range of the clip mask. | 37 * cases scissoring is used to bound the range of the clip mask. |
38 */ | 38 */ |
39 class GrClipMaskManager : SkNoncopyable { | 39 class GrClipMaskManager : SkNoncopyable { |
40 public: | 40 public: |
41 GrClipMaskManager() | 41 GrClipMaskManager() |
42 : fCurrClipMaskType(kNone_ClipMaskType) | 42 : fCurrClipMaskType(kNone_ClipMaskType) |
43 , fClipTarget(NULL) { | 43 , fClipTarget(NULL) |
| 44 , fClipMode(kIgnoreClip_StencilClipMode) { |
44 } | 45 } |
45 | 46 |
46 // The state of the scissor is controlled by the clip manager, no one else s
hould set | 47 // The state of the scissor is controlled by the clip manager, no one else s
hould set |
47 // Scissor state. This should really be on Gpu itself. We should revist th
is when GPU | 48 // Scissor state. This should really be on Gpu itself. We should revist th
is when GPU |
48 // and drawtarget are separate | 49 // and drawtarget are separate |
49 struct ScissorState { | 50 struct ScissorState { |
50 ScissorState() : fEnabled(false) {} | 51 ScissorState() : fEnabled(false) {} |
51 void set(const SkIRect& rect) { fRect = rect; fEnabled = true; } | 52 void set(const SkIRect& rect) { fRect = rect; fEnabled = true; } |
52 bool fEnabled; | 53 bool fEnabled; |
53 SkIRect fRect; | 54 SkIRect fRect; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 88 |
88 GrContext* getContext() { | 89 GrContext* getContext() { |
89 return fAACache.getContext(); | 90 return fAACache.getContext(); |
90 } | 91 } |
91 | 92 |
92 void setClipTarget(GrClipTarget*); | 93 void setClipTarget(GrClipTarget*); |
93 | 94 |
94 void adjustPathStencilParams(GrStencilSettings*); | 95 void adjustPathStencilParams(GrStencilSettings*); |
95 | 96 |
96 private: | 97 private: |
97 enum PrivateDrawStateStateBits { | |
98 kFirstBit = (GrDrawState::kLastPublicStateBit << 1), | |
99 | |
100 kModifyStencilClip_StateBit = kFirstBit, // allows draws to modify | |
101 // stencil bits used for | |
102 // clipping. | |
103 }; | |
104 | |
105 /** | 98 /** |
106 * Informs the helper function adjustStencilParams() about how the stencil | 99 * Informs the helper function adjustStencilParams() about how the stencil |
107 * buffer clip is being used. | 100 * buffer clip is being used. |
108 */ | 101 */ |
109 enum StencilClipMode { | 102 enum StencilClipMode { |
110 // Draw to the clip bit of the stencil buffer | 103 // Draw to the clip bit of the stencil buffer |
111 kModifyClip_StencilClipMode, | 104 kModifyClip_StencilClipMode, |
112 // Clip against the existing representation of the clip in the high bit | 105 // Clip against the existing representation of the clip in the high bit |
113 // of the stencil buffer. | 106 // of the stencil buffer. |
114 kRespectClip_StencilClipMode, | 107 kRespectClip_StencilClipMode, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 * texture. It may be neither because the scissor rect suffices or we | 188 * texture. It may be neither because the scissor rect suffices or we |
196 * haven't yet examined the clip. | 189 * haven't yet examined the clip. |
197 */ | 190 */ |
198 enum ClipMaskType { | 191 enum ClipMaskType { |
199 kNone_ClipMaskType, | 192 kNone_ClipMaskType, |
200 kStencil_ClipMaskType, | 193 kStencil_ClipMaskType, |
201 kAlpha_ClipMaskType, | 194 kAlpha_ClipMaskType, |
202 } fCurrClipMaskType; | 195 } fCurrClipMaskType; |
203 | 196 |
204 GrClipMaskCache fAACache; // cache for the AA path | 197 GrClipMaskCache fAACache; // cache for the AA path |
205 GrClipTarget* fClipTarget; | 198 GrClipTarget* fClipTarget; |
| 199 StencilClipMode fClipMode; |
206 | 200 |
207 typedef SkNoncopyable INHERITED; | 201 typedef SkNoncopyable INHERITED; |
208 }; | 202 }; |
209 | 203 |
210 #endif // GrClipMaskManager_DEFINED | 204 #endif // GrClipMaskManager_DEFINED |
OLD | NEW |