OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 GrDrawState_DEFINED | 8 #ifndef GrDrawState_DEFINED |
9 #define GrDrawState_DEFINED | 9 #define GrDrawState_DEFINED |
10 | 10 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 * coverage is ignored when per-vertex coverage is provided. | 159 * coverage is ignored when per-vertex coverage is provided. |
160 */ | 160 */ |
161 void setCoverage(uint8_t coverage) { | 161 void setCoverage(uint8_t coverage) { |
162 fCoverage = coverage; | 162 fCoverage = coverage; |
163 this->invalidateBlendOptFlags(); | 163 this->invalidateBlendOptFlags(); |
164 } | 164 } |
165 | 165 |
166 /// @} | 166 /// @} |
167 | 167 |
168 /////////////////////////////////////////////////////////////////////////// | 168 /////////////////////////////////////////////////////////////////////////// |
169 /// @name Effect Stages | 169 /// @name Effect Stages |
bsalomon
2014/09/03 21:07:00
Prolly should update this comment.
| |
170 /// Each stage hosts a GrEffect. The effect produces an output color or cove rage in the fragment | 170 /// Each stage hosts a GrEffect. The effect produces an output color or cove rage in the fragment |
171 /// shader. Its inputs are the output from the previous stage as well as som e variables | 171 /// shader. Its inputs are the output from the previous stage as well as som e variables |
172 /// available to it in the fragment and vertex shader (e.g. the vertex posit ion, the dst color, | 172 /// available to it in the fragment and vertex shader (e.g. the vertex posit ion, the dst color, |
173 /// the fragment position, local coordinates). | 173 /// the fragment position, local coordinates). |
174 /// | 174 /// |
175 /// The stages are divided into two sets, color-computing and coverage-compu ting. The final | 175 /// The stages are divided into two sets, color-computing and coverage-compu ting. The final |
176 /// color stage produces the final pixel color. The coverage-computing stage s function exactly | 176 /// color stage produces the final pixel color. The coverage-computing stage s function exactly |
177 /// as the color-computing but the output of the final coverage stage is tre ated as a fractional | 177 /// as the color-computing but the output of the final coverage stage is tre ated as a fractional |
178 /// pixel coverage rather than as input to the src/dst color blend step. | 178 /// pixel coverage rather than as input to the src/dst color blend step. |
179 /// | 179 /// |
180 /// The input color to the first color-stage is either the constant color or interpolated | 180 /// The input color to the first color-stage is either the constant color or interpolated |
181 /// per-vertex colors. The input to the first coverage stage is either a con stant coverage | 181 /// per-vertex colors. The input to the first coverage stage is either a con stant coverage |
182 /// (usually full-coverage) or interpolated per-vertex coverage. | 182 /// (usually full-coverage) or interpolated per-vertex coverage. |
183 /// | 183 /// |
184 /// See the documentation of kCoverageDrawing_StateBit for information about disabling the | 184 /// See the documentation of kCoverageDrawing_StateBit for information about disabling the |
185 /// the color / coverage distinction. | 185 /// the color / coverage distinction. |
186 //// | 186 //// |
187 | 187 |
188 const GrEffect* setGeometryProcessor(const GrEffect* effect, int attr0 = -1, int attr1 = -1) { | |
189 SkASSERT(NULL != effect); | |
190 SkASSERT(!this->hasGeometryProcessor()); | |
191 fGeometryProcessor.reset(new GrEffectStage(effect, attr0, attr1)); | |
192 this->invalidateBlendOptFlags(); | |
193 return effect; | |
194 } | |
195 | |
188 const GrEffect* addColorEffect(const GrEffect* effect, int attr0 = -1, int a ttr1 = -1) { | 196 const GrEffect* addColorEffect(const GrEffect* effect, int attr0 = -1, int a ttr1 = -1) { |
189 SkASSERT(NULL != effect); | 197 SkASSERT(NULL != effect); |
190 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrEffectStage, (effect, attr0, att r1)); | 198 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrEffectStage, (effect, attr0, att r1)); |
191 this->invalidateBlendOptFlags(); | 199 this->invalidateBlendOptFlags(); |
192 return effect; | 200 return effect; |
193 } | 201 } |
194 | 202 |
195 const GrEffect* addCoverageEffect(const GrEffect* effect, int attr0 = -1, in t attr1 = -1) { | 203 const GrEffect* addCoverageEffect(const GrEffect* effect, int attr0 = -1, in t attr1 = -1) { |
196 SkASSERT(NULL != effect); | 204 SkASSERT(NULL != effect); |
197 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrEffectStage, (effect, attr0, attr1)); | 205 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrEffectStage, (effect, attr0, attr1)); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 } | 243 } |
236 | 244 |
237 ~AutoRestoreEffects() { this->set(NULL); } | 245 ~AutoRestoreEffects() { this->set(NULL); } |
238 | 246 |
239 void set(GrDrawState* ds); | 247 void set(GrDrawState* ds); |
240 | 248 |
241 bool isSet() const { return NULL != fDrawState; } | 249 bool isSet() const { return NULL != fDrawState; } |
242 | 250 |
243 private: | 251 private: |
244 GrDrawState* fDrawState; | 252 GrDrawState* fDrawState; |
253 SkAutoTDelete<GrEffectStage> fGeometryProcessor; | |
245 int fColorEffectCnt; | 254 int fColorEffectCnt; |
246 int fCoverageEffectCnt; | 255 int fCoverageEffectCnt; |
247 }; | 256 }; |
248 | 257 |
249 /// @} | 258 /// @} |
250 | 259 |
251 /////////////////////////////////////////////////////////////////////////// | 260 /////////////////////////////////////////////////////////////////////////// |
252 /// @name Blending | 261 /// @name Blending |
253 //// | 262 //// |
254 | 263 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 /** Sets the draw state's matrix to identity. This can fail because the current view matrix | 366 /** Sets the draw state's matrix to identity. This can fail because the current view matrix |
358 is not invertible. */ | 367 is not invertible. */ |
359 bool setIdentity(GrDrawState* drawState); | 368 bool setIdentity(GrDrawState* drawState); |
360 | 369 |
361 private: | 370 private: |
362 void doEffectCoordChanges(const SkMatrix& coordChangeMatrix); | 371 void doEffectCoordChanges(const SkMatrix& coordChangeMatrix); |
363 | 372 |
364 GrDrawState* fDrawState; | 373 GrDrawState* fDrawState; |
365 SkMatrix fViewMatrix; | 374 SkMatrix fViewMatrix; |
366 int fNumColorStages; | 375 int fNumColorStages; |
376 bool fHasGeometryProcesso r; | |
367 SkAutoSTArray<8, GrEffectStage::SavedCoordChange> fSavedCoordChanges; | 377 SkAutoSTArray<8, GrEffectStage::SavedCoordChange> fSavedCoordChanges; |
368 }; | 378 }; |
369 | 379 |
370 /// @} | 380 /// @} |
371 | 381 |
372 /////////////////////////////////////////////////////////////////////////// | 382 /////////////////////////////////////////////////////////////////////////// |
373 /// @name Render Target | 383 /// @name Render Target |
374 //// | 384 //// |
375 | 385 |
376 /** | 386 /** |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
528 // Some of the auto restore objects assume that no effects are removed durin g their lifetime. | 538 // Some of the auto restore objects assume that no effects are removed durin g their lifetime. |
529 // This is used to assert that this condition holds. | 539 // This is used to assert that this condition holds. |
530 SkDEBUGCODE(int fBlockEffectRemovalCnt;) | 540 SkDEBUGCODE(int fBlockEffectRemovalCnt;) |
531 | 541 |
532 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz e_t stride); | 542 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz e_t stride); |
533 | 543 |
534 typedef GrRODrawState INHERITED; | 544 typedef GrRODrawState INHERITED; |
535 }; | 545 }; |
536 | 546 |
537 #endif | 547 #endif |
OLD | NEW |