| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 164 } |
| 165 | 165 |
| 166 /// @} | 166 /// @} |
| 167 | 167 |
| 168 /** | 168 /** |
| 169 * The geometry processor is the sole element of the skia pipeline which can
use the vertex, | 169 * The geometry processor is the sole element of the skia pipeline which can
use the vertex, |
| 170 * geometry, and tesselation shaders. The GP may also compute a coverage in
its fragment shader | 170 * geometry, and tesselation shaders. The GP may also compute a coverage in
its fragment shader |
| 171 * but is never put in the color processing pipeline. | 171 * but is never put in the color processing pipeline. |
| 172 */ | 172 */ |
| 173 | 173 |
| 174 const GrEffect* setGeometryProcessor(const GrEffect* effect, int attr0 = -1,
int attr1 = -1) { | 174 const GrEffect* setGeometryProcessor(const GrEffect* effect) { |
| 175 SkASSERT(effect); | 175 SkASSERT(effect); |
| 176 SkASSERT(effect->requiresVertexShader()); |
| 176 SkASSERT(!this->hasGeometryProcessor()); | 177 SkASSERT(!this->hasGeometryProcessor()); |
| 177 fGeometryProcessor.reset(new GrEffectStage(effect, attr0, attr1)); | 178 fGeometryProcessor.reset(new GrEffectStage(effect)); |
| 178 this->invalidateBlendOptFlags(); | 179 this->invalidateBlendOptFlags(); |
| 179 return effect; | 180 return effect; |
| 180 } | 181 } |
| 181 | 182 |
| 182 /////////////////////////////////////////////////////////////////////////// | 183 /////////////////////////////////////////////////////////////////////////// |
| 183 /// @name Effect Stages | 184 /// @name Effect Stages |
| 184 /// Each stage hosts a GrEffect. The effect produces an output color or cove
rage in the fragment | 185 /// Each stage hosts a GrEffect. The effect produces an output color or cove
rage in the fragment |
| 185 /// shader. Its inputs are the output from the previous stage as well as som
e variables | 186 /// shader. Its inputs are the output from the previous stage as well as som
e variables |
| 186 /// available to it in the fragment and vertex shader (e.g. the vertex posit
ion, the dst color, | 187 /// available to it in the fragment and vertex shader (e.g. the vertex posit
ion, the dst color, |
| 187 /// the fragment position, local coordinates). | 188 /// the fragment position, local coordinates). |
| 188 /// | 189 /// |
| 189 /// The stages are divided into two sets, color-computing and coverage-compu
ting. The final | 190 /// The stages are divided into two sets, color-computing and coverage-compu
ting. The final |
| 190 /// color stage produces the final pixel color. The coverage-computing stage
s function exactly | 191 /// color stage produces the final pixel color. The coverage-computing stage
s function exactly |
| 191 /// as the color-computing but the output of the final coverage stage is tre
ated as a fractional | 192 /// as the color-computing but the output of the final coverage stage is tre
ated as a fractional |
| 192 /// pixel coverage rather than as input to the src/dst color blend step. | 193 /// pixel coverage rather than as input to the src/dst color blend step. |
| 193 /// | 194 /// |
| 194 /// The input color to the first color-stage is either the constant color or
interpolated | 195 /// The input color to the first color-stage is either the constant color or
interpolated |
| 195 /// per-vertex colors. The input to the first coverage stage is either a con
stant coverage | 196 /// per-vertex colors. The input to the first coverage stage is either a con
stant coverage |
| 196 /// (usually full-coverage) or interpolated per-vertex coverage. | 197 /// (usually full-coverage) or interpolated per-vertex coverage. |
| 197 /// | 198 /// |
| 198 /// See the documentation of kCoverageDrawing_StateBit for information about
disabling the | 199 /// See the documentation of kCoverageDrawing_StateBit for information about
disabling the |
| 199 /// the color / coverage distinction. | 200 /// the color / coverage distinction. |
| 200 //// | 201 //// |
| 201 | 202 |
| 202 const GrEffect* addColorEffect(const GrEffect* effect, int attr0 = -1, int a
ttr1 = -1) { | 203 const GrEffect* addColorEffect(const GrEffect* effect) { |
| 203 SkASSERT(effect); | 204 SkASSERT(effect); |
| 204 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrEffectStage, (effect, attr0, att
r1)); | 205 SkASSERT(!effect->requiresVertexShader()); |
| 206 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrEffectStage, (effect)); |
| 205 this->invalidateBlendOptFlags(); | 207 this->invalidateBlendOptFlags(); |
| 206 return effect; | 208 return effect; |
| 207 } | 209 } |
| 208 | 210 |
| 209 const GrEffect* addCoverageEffect(const GrEffect* effect, int attr0 = -1, in
t attr1 = -1) { | 211 const GrEffect* addCoverageEffect(const GrEffect* effect) { |
| 210 SkASSERT(effect); | 212 SkASSERT(effect); |
| 211 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrEffectStage, (effect, attr0,
attr1)); | 213 SkASSERT(!effect->requiresVertexShader()); |
| 214 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrEffectStage, (effect)); |
| 212 this->invalidateBlendOptFlags(); | 215 this->invalidateBlendOptFlags(); |
| 213 return effect; | 216 return effect; |
| 214 } | 217 } |
| 215 | 218 |
| 216 /** | 219 /** |
| 217 * Creates a GrSimpleTextureEffect that uses local coords as texture coordin
ates. | 220 * Creates a GrSimpleTextureEffect that uses local coords as texture coordin
ates. |
| 218 */ | 221 */ |
| 219 void addColorTextureEffect(GrTexture* texture, const SkMatrix& matrix) { | 222 void addColorTextureEffect(GrTexture* texture, const SkMatrix& matrix) { |
| 220 this->addColorEffect(GrSimpleTextureEffect::Create(texture, matrix))->un
ref(); | 223 this->addColorEffect(GrSimpleTextureEffect::Create(texture, matrix))->un
ref(); |
| 221 } | 224 } |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 // Some of the auto restore objects assume that no effects are removed durin
g their lifetime. | 569 // Some of the auto restore objects assume that no effects are removed durin
g their lifetime. |
| 567 // This is used to assert that this condition holds. | 570 // This is used to assert that this condition holds. |
| 568 SkDEBUGCODE(int fBlockEffectRemovalCnt;) | 571 SkDEBUGCODE(int fBlockEffectRemovalCnt;) |
| 569 | 572 |
| 570 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz
e_t stride); | 573 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz
e_t stride); |
| 571 | 574 |
| 572 typedef GrRODrawState INHERITED; | 575 typedef GrRODrawState INHERITED; |
| 573 }; | 576 }; |
| 574 | 577 |
| 575 #endif | 578 #endif |
| OLD | NEW |