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" |
(...skipping 25 matching lines...) Expand all Loading... |
36 public: | 36 public: |
37 GrClipMaskManager(GrClipTarget* owner); | 37 GrClipMaskManager(GrClipTarget* 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(GrPipelineBuilder*, | 46 bool setupClipping(const GrPipelineBuilder&, |
47 GrPipelineBuilder::AutoRestoreFragmentProcessors*, | 47 GrPipelineBuilder::AutoRestoreFragmentProcessors*, |
48 GrPipelineBuilder::AutoRestoreStencil*, | 48 GrPipelineBuilder::AutoRestoreStencil*, |
| 49 GrPipelineBuilder::AutoRestoreProcessorDataManager*, |
49 GrScissorState*, | 50 GrScissorState*, |
50 const SkRect* devBounds); | 51 const SkRect* devBounds); |
51 | 52 |
52 /** | 53 /** |
53 * Purge resources to free up memory. TODO: This class shouldn't hold any lo
ng lived refs | 54 * 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. | 55 * which will allow Resourcecache to automatically purge anything this class
has created. |
55 */ | 56 */ |
56 void purgeResources(); | 57 void purgeResources(); |
57 | 58 |
58 bool isClipInStencil() const { | 59 bool isClipInStencil() const { |
(...skipping 20 matching lines...) Expand all Loading... |
79 kModifyClip_StencilClipMode, | 80 kModifyClip_StencilClipMode, |
80 // Clip against the existing representation of the clip in the high bit | 81 // Clip against the existing representation of the clip in the high bit |
81 // of the stencil buffer. | 82 // of the stencil buffer. |
82 kRespectClip_StencilClipMode, | 83 kRespectClip_StencilClipMode, |
83 // Neither writing to nor clipping against the clip bit. | 84 // Neither writing to nor clipping against the clip bit. |
84 kIgnoreClip_StencilClipMode, | 85 kIgnoreClip_StencilClipMode, |
85 }; | 86 }; |
86 | 87 |
87 // Attempts to install a series of coverage effects to implement the clip. R
eturn indicates | 88 // Attempts to install a series of coverage effects to implement the clip. R
eturn indicates |
88 // whether the element list was successfully converted to effects. | 89 // whether the element list was successfully converted to effects. |
89 bool installClipEffects(GrPipelineBuilder*, | 90 bool installClipEffects(const GrPipelineBuilder&, |
90 GrPipelineBuilder::AutoRestoreFragmentProcessors*, | 91 GrPipelineBuilder::AutoRestoreFragmentProcessors*, |
91 const GrReducedClip::ElementList&, | 92 const GrReducedClip::ElementList&, |
92 const SkVector& clipOffset, | 93 const SkVector& clipOffset, |
93 const SkRect* devBounds); | 94 const SkRect* devBounds); |
94 | 95 |
95 // Draws the clip into the stencil buffer | 96 // Draws the clip into the stencil buffer |
96 bool createStencilClipMask(GrRenderTarget*, | 97 bool createStencilClipMask(GrRenderTarget*, |
97 int32_t elementsGenID, | 98 int32_t elementsGenID, |
98 GrReducedClip::InitialState initialState, | 99 GrReducedClip::InitialState initialState, |
99 const GrReducedClip::ElementList& elements, | 100 const GrReducedClip::ElementList& elements, |
(...skipping 18 matching lines...) Expand all Loading... |
118 // Returns the cached mask texture if it matches the elementsGenID and the c
lipSpaceIBounds. | 119 // Returns the cached mask texture if it matches the elementsGenID and the c
lipSpaceIBounds. |
119 // Returns NULL if not found. | 120 // Returns NULL if not found. |
120 GrTexture* getCachedMaskTexture(int32_t elementsGenID, const SkIRect& clipSp
aceIBounds); | 121 GrTexture* getCachedMaskTexture(int32_t elementsGenID, const SkIRect& clipSp
aceIBounds); |
121 | 122 |
122 // Handles allocation (if needed) of a clip alpha-mask texture for both the
sw-upload | 123 // Handles allocation (if needed) of a clip alpha-mask texture for both the
sw-upload |
123 // or gpu-rendered cases. | 124 // or gpu-rendered cases. |
124 GrTexture* allocMaskTexture(int32_t elementsGenID, | 125 GrTexture* allocMaskTexture(int32_t elementsGenID, |
125 const SkIRect& clipSpaceIBounds, | 126 const SkIRect& clipSpaceIBounds, |
126 bool willUpload); | 127 bool willUpload); |
127 | 128 |
128 bool useSWOnlyPath(const GrPipelineBuilder*, | 129 bool useSWOnlyPath(const GrPipelineBuilder&, |
129 const SkVector& clipToMaskOffset, | 130 const SkVector& clipToMaskOffset, |
130 const GrReducedClip::ElementList& elements); | 131 const GrReducedClip::ElementList& elements); |
131 | 132 |
132 // Draws a clip element into the target alpha mask. The caller should have a
lready setup the | 133 // Draws a clip element into the target alpha mask. The caller should have a
lready setup the |
133 // desired blend operation. Optionally if the caller already selected a path
renderer it can | 134 // desired blend operation. Optionally if the caller already selected a path
renderer it can |
134 // be passed. Otherwise the function will select one if the element is a pat
h. | 135 // be passed. Otherwise the function will select one if the element is a pat
h. |
135 bool drawElement(GrPipelineBuilder*, | 136 bool drawElement(GrPipelineBuilder*, |
136 const SkMatrix& viewMatrix, | 137 const SkMatrix& viewMatrix, |
137 GrTexture* target, | 138 GrTexture* target, |
138 const SkClipStack::Element*, | 139 const SkClipStack::Element*, |
(...skipping 15 matching lines...) Expand all Loading... |
154 const SkIRect& srcBound); | 155 const SkIRect& srcBound); |
155 | 156 |
156 GrTexture* createTempMask(int width, int height); | 157 GrTexture* createTempMask(int width, int height); |
157 | 158 |
158 void setupCache(const SkClipStack& clip, | 159 void setupCache(const SkClipStack& clip, |
159 const SkIRect& bounds); | 160 const SkIRect& bounds); |
160 /** | 161 /** |
161 * Called prior to return control back the GrGpu in setupClipping. It update
s the | 162 * Called prior to return control back the GrGpu in setupClipping. It update
s the |
162 * GrPipelineBuilder with stencil settings that account for stencil-based cl
ipping. | 163 * GrPipelineBuilder with stencil settings that account for stencil-based cl
ipping. |
163 */ | 164 */ |
164 void setPipelineBuilderStencil(GrPipelineBuilder*, GrPipelineBuilder::AutoRe
storeStencil*); | 165 void setPipelineBuilderStencil(const GrPipelineBuilder&, |
| 166 GrPipelineBuilder::AutoRestoreStencil*); |
165 | 167 |
166 /** | 168 /** |
167 * Adjusts the stencil settings to account for interaction with stencil | 169 * Adjusts the stencil settings to account for interaction with stencil |
168 * clipping. | 170 * clipping. |
169 */ | 171 */ |
170 void adjustStencilParams(GrStencilSettings* settings, | 172 void adjustStencilParams(GrStencilSettings* settings, |
171 StencilClipMode mode, | 173 StencilClipMode mode, |
172 int stencilBitCnt); | 174 int stencilBitCnt); |
173 | 175 |
174 /** | 176 /** |
175 * We may represent the clip as a mask in the stencil buffer or as an alpha | 177 * We may represent the clip as a mask in the stencil buffer or as an alpha |
176 * texture. It may be neither because the scissor rect suffices or we | 178 * texture. It may be neither because the scissor rect suffices or we |
177 * haven't yet examined the clip. | 179 * haven't yet examined the clip. |
178 */ | 180 */ |
179 enum ClipMaskType { | 181 enum ClipMaskType { |
180 kNone_ClipMaskType, | 182 kNone_ClipMaskType, |
181 kStencil_ClipMaskType, | 183 kStencil_ClipMaskType, |
182 kAlpha_ClipMaskType, | 184 kAlpha_ClipMaskType, |
183 } fCurrClipMaskType; | 185 } fCurrClipMaskType; |
184 | 186 |
185 GrClipMaskCache fAACache; // cache for the AA path | 187 GrClipMaskCache fAACache; // cache for the AA path |
186 GrClipTarget* fClipTarget; // This is our owning clip target. | 188 GrClipTarget* fClipTarget; // This is our owning clip target. |
187 StencilClipMode fClipMode; | 189 StencilClipMode fClipMode; |
188 | 190 |
189 typedef SkNoncopyable INHERITED; | 191 typedef SkNoncopyable INHERITED; |
190 }; | 192 }; |
191 #endif // GrClipMaskManager_DEFINED | 193 #endif // GrClipMaskManager_DEFINED |
OLD | NEW |