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 #ifndef GrClipMaskManager_DEFINED | 7 #ifndef GrClipMaskManager_DEFINED |
8 #define GrClipMaskManager_DEFINED | 8 #define GrClipMaskManager_DEFINED |
9 | 9 |
10 #include "GrClipMaskCache.h" | 10 #include "GrClipMaskCache.h" |
11 #include "GrPipelineBuilder.h" | 11 #include "GrPipelineBuilder.h" |
12 #include "GrReducedClip.h" | 12 #include "GrReducedClip.h" |
13 #include "GrStencil.h" | 13 #include "GrStencil.h" |
14 #include "GrTexture.h" | 14 #include "GrTexture.h" |
15 #include "SkClipStack.h" | 15 #include "SkClipStack.h" |
16 #include "SkDeque.h" | 16 #include "SkDeque.h" |
17 #include "SkPath.h" | 17 #include "SkPath.h" |
18 #include "SkRefCnt.h" | 18 #include "SkRefCnt.h" |
19 #include "SkTLList.h" | 19 #include "SkTLList.h" |
20 #include "SkTypes.h" | 20 #include "SkTypes.h" |
21 | 21 |
22 class GrClipTarget; | 22 class GrDrawTarget; |
23 class GrPathRenderer; | 23 class GrPathRenderer; |
24 class GrPathRendererChain; | 24 class GrPathRendererChain; |
25 class GrTexture; | 25 class GrTexture; |
26 class SkPath; | 26 class SkPath; |
27 /** | 27 /** |
28 * The clip mask creator handles the generation of the clip mask. If anti | 28 * The clip mask creator handles the generation of the clip mask. If anti |
29 * aliasing is requested it will (in the future) generate a single channel | 29 * aliasing is requested it will (in the future) generate a single channel |
30 * (8bit) mask. If no anti aliasing is requested it will generate a 1-bit | 30 * (8bit) mask. If no anti aliasing is requested it will generate a 1-bit |
31 * mask in the stencil buffer. In the non anti-aliasing case, if the clip | 31 * mask in the stencil buffer. In the non anti-aliasing case, if the clip |
32 * mask can be represented as a rectangle then scissoring is used. In all | 32 * mask can be represented as a rectangle then scissoring is used. In all |
33 * cases scissoring is used to bound the range of the clip mask. | 33 * cases scissoring is used to bound the range of the clip mask. |
34 */ | 34 */ |
35 class GrClipMaskManager : SkNoncopyable { | 35 class GrClipMaskManager : SkNoncopyable { |
36 public: | 36 public: |
37 GrClipMaskManager(GrClipTarget* owner); | 37 GrClipMaskManager(GrDrawTarget* owner); |
38 | 38 |
39 /** | 39 /** |
40 * Creates a clip mask if necessary as a stencil buffer or alpha texture | 40 * Creates a clip mask if necessary as a stencil buffer or alpha texture |
41 * and sets the GrGpu's scissor and stencil state. If the return is false | 41 * and sets the GrGpu's scissor and stencil state. If the return is false |
42 * then the draw can be skipped. The AutoRestoreEffects is initialized by | 42 * then the draw can be skipped. The AutoRestoreEffects is initialized by |
43 * the manager when it must install additional effects to implement the | 43 * the manager when it must install additional effects to implement the |
44 * clip. devBounds is optional but can help optimize clipping. | 44 * clip. devBounds is optional but can help optimize clipping. |
45 */ | 45 */ |
46 bool setupClipping(const GrPipelineBuilder&, | 46 bool setupClipping(const GrPipelineBuilder&, |
47 GrPipelineBuilder::AutoRestoreFragmentProcessorState*, | 47 GrPipelineBuilder::AutoRestoreFragmentProcessorState*, |
48 GrPipelineBuilder::AutoRestoreStencil*, | 48 GrPipelineBuilder::AutoRestoreStencil*, |
49 GrScissorState*, | 49 GrScissorState*, |
50 const SkRect* devBounds); | 50 const SkRect* devBounds); |
51 | 51 |
52 /** | 52 /** |
53 * Purge resources to free up memory. TODO: This class shouldn't hold any lo
ng lived refs | 53 * Purge resources to free up memory. TODO: This class shouldn't hold any lo
ng lived refs |
54 * which will allow Resourcecache to automatically purge anything this class
has created. | 54 * which will allow GrResourceCache to automatically purge anything this cla
ss has created. |
55 */ | 55 */ |
56 void purgeResources(); | 56 void purgeResources(); |
57 | 57 |
58 bool isClipInStencil() const { | 58 bool isClipInStencil() const { |
59 return kStencil_ClipMaskType == fCurrClipMaskType; | 59 return kStencil_ClipMaskType == fCurrClipMaskType; |
60 } | 60 } |
61 | 61 |
62 bool isClipInAlpha() const { | 62 bool isClipInAlpha() const { |
63 return kAlpha_ClipMaskType == fCurrClipMaskType; | 63 return kAlpha_ClipMaskType == fCurrClipMaskType; |
64 } | 64 } |
65 | 65 |
66 void setClipTarget(GrClipTarget*); | |
67 | |
68 void adjustPathStencilParams(const GrStencilAttachment*, GrStencilSettings*)
; | 66 void adjustPathStencilParams(const GrStencilAttachment*, GrStencilSettings*)
; |
69 | 67 |
70 private: | 68 private: |
71 inline GrContext* getContext(); | 69 inline GrContext* getContext(); |
72 | 70 |
73 /** | 71 /** |
74 * Informs the helper function adjustStencilParams() about how the stencil | 72 * Informs the helper function adjustStencilParams() about how the stencil |
75 * buffer clip is being used. | 73 * buffer clip is being used. |
76 */ | 74 */ |
77 enum StencilClipMode { | 75 enum StencilClipMode { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 * texture. It may be neither because the scissor rect suffices or we | 175 * texture. It may be neither because the scissor rect suffices or we |
178 * haven't yet examined the clip. | 176 * haven't yet examined the clip. |
179 */ | 177 */ |
180 enum ClipMaskType { | 178 enum ClipMaskType { |
181 kNone_ClipMaskType, | 179 kNone_ClipMaskType, |
182 kStencil_ClipMaskType, | 180 kStencil_ClipMaskType, |
183 kAlpha_ClipMaskType, | 181 kAlpha_ClipMaskType, |
184 } fCurrClipMaskType; | 182 } fCurrClipMaskType; |
185 | 183 |
186 GrClipMaskCache fAACache; // cache for the AA path | 184 GrClipMaskCache fAACache; // cache for the AA path |
187 GrClipTarget* fClipTarget; // This is our owning clip target. | 185 GrDrawTarget* fDrawTarget; // This is our owning draw target. |
188 StencilClipMode fClipMode; | 186 StencilClipMode fClipMode; |
189 | 187 |
190 typedef SkNoncopyable INHERITED; | 188 typedef SkNoncopyable INHERITED; |
191 }; | 189 }; |
192 #endif // GrClipMaskManager_DEFINED | 190 #endif // GrClipMaskManager_DEFINED |
OLD | NEW |