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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, int attr0 = -1,
int attr1 = -1) { |
175 SkASSERT(NULL != effect); | 175 SkASSERT(effect); |
176 SkASSERT(!this->hasGeometryProcessor()); | 176 SkASSERT(!this->hasGeometryProcessor()); |
177 fGeometryProcessor.reset(new GrEffectStage(effect, attr0, attr1)); | 177 fGeometryProcessor.reset(new GrEffectStage(effect, attr0, attr1)); |
178 this->invalidateBlendOptFlags(); | 178 this->invalidateBlendOptFlags(); |
179 return effect; | 179 return effect; |
180 } | 180 } |
181 | 181 |
182 /////////////////////////////////////////////////////////////////////////// | 182 /////////////////////////////////////////////////////////////////////////// |
183 /// @name Effect Stages | 183 /// @name Effect Stages |
184 /// Each stage hosts a GrEffect. The effect produces an output color or cove
rage in the fragment | 184 /// 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 | 185 /// 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, | 186 /// available to it in the fragment and vertex shader (e.g. the vertex posit
ion, the dst color, |
187 /// the fragment position, local coordinates). | 187 /// the fragment position, local coordinates). |
188 /// | 188 /// |
189 /// The stages are divided into two sets, color-computing and coverage-compu
ting. The final | 189 /// 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 | 190 /// 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 | 191 /// 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. | 192 /// pixel coverage rather than as input to the src/dst color blend step. |
193 /// | 193 /// |
194 /// The input color to the first color-stage is either the constant color or
interpolated | 194 /// 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 | 195 /// 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. | 196 /// (usually full-coverage) or interpolated per-vertex coverage. |
197 /// | 197 /// |
198 /// See the documentation of kCoverageDrawing_StateBit for information about
disabling the | 198 /// See the documentation of kCoverageDrawing_StateBit for information about
disabling the |
199 /// the color / coverage distinction. | 199 /// the color / coverage distinction. |
200 //// | 200 //// |
201 | 201 |
202 const GrEffect* addColorEffect(const GrEffect* effect, int attr0 = -1, int a
ttr1 = -1) { | 202 const GrEffect* addColorEffect(const GrEffect* effect, int attr0 = -1, int a
ttr1 = -1) { |
203 SkASSERT(NULL != effect); | 203 SkASSERT(effect); |
204 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrEffectStage, (effect, attr0, att
r1)); | 204 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrEffectStage, (effect, attr0, att
r1)); |
205 this->invalidateBlendOptFlags(); | 205 this->invalidateBlendOptFlags(); |
206 return effect; | 206 return effect; |
207 } | 207 } |
208 | 208 |
209 const GrEffect* addCoverageEffect(const GrEffect* effect, int attr0 = -1, in
t attr1 = -1) { | 209 const GrEffect* addCoverageEffect(const GrEffect* effect, int attr0 = -1, in
t attr1 = -1) { |
210 SkASSERT(NULL != effect); | 210 SkASSERT(effect); |
211 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrEffectStage, (effect, attr0,
attr1)); | 211 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrEffectStage, (effect, attr0,
attr1)); |
212 this->invalidateBlendOptFlags(); | 212 this->invalidateBlendOptFlags(); |
213 return effect; | 213 return effect; |
214 } | 214 } |
215 | 215 |
216 /** | 216 /** |
217 * Creates a GrSimpleTextureEffect that uses local coords as texture coordin
ates. | 217 * Creates a GrSimpleTextureEffect that uses local coords as texture coordin
ates. |
218 */ | 218 */ |
219 void addColorTextureEffect(GrTexture* texture, const SkMatrix& matrix) { | 219 void addColorTextureEffect(GrTexture* texture, const SkMatrix& matrix) { |
220 this->addColorEffect(GrSimpleTextureEffect::Create(texture, matrix))->un
ref(); | 220 this->addColorEffect(GrSimpleTextureEffect::Create(texture, matrix))->un
ref(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 , fOriginalGPID(SK_InvalidUniqueID) | 265 , fOriginalGPID(SK_InvalidUniqueID) |
266 , fColorEffectCnt(0) | 266 , fColorEffectCnt(0) |
267 , fCoverageEffectCnt(0) { | 267 , fCoverageEffectCnt(0) { |
268 this->set(ds); | 268 this->set(ds); |
269 } | 269 } |
270 | 270 |
271 ~AutoRestoreEffects() { this->set(NULL); } | 271 ~AutoRestoreEffects() { this->set(NULL); } |
272 | 272 |
273 void set(GrDrawState* ds); | 273 void set(GrDrawState* ds); |
274 | 274 |
275 bool isSet() const { return NULL != fDrawState; } | 275 bool isSet() const { return SkToBool(fDrawState); } |
276 | 276 |
277 private: | 277 private: |
278 GrDrawState* fDrawState; | 278 GrDrawState* fDrawState; |
279 uint32_t fOriginalGPID; | 279 uint32_t fOriginalGPID; |
280 int fColorEffectCnt; | 280 int fColorEffectCnt; |
281 int fCoverageEffectCnt; | 281 int fCoverageEffectCnt; |
282 }; | 282 }; |
283 | 283 |
284 /// @} | 284 /// @} |
285 | 285 |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 // Some of the auto restore objects assume that no effects are removed durin
g their lifetime. | 564 // Some of the auto restore objects assume that no effects are removed durin
g their lifetime. |
565 // This is used to assert that this condition holds. | 565 // This is used to assert that this condition holds. |
566 SkDEBUGCODE(int fBlockEffectRemovalCnt;) | 566 SkDEBUGCODE(int fBlockEffectRemovalCnt;) |
567 | 567 |
568 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz
e_t stride); | 568 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz
e_t stride); |
569 | 569 |
570 typedef GrRODrawState INHERITED; | 570 typedef GrRODrawState INHERITED; |
571 }; | 571 }; |
572 | 572 |
573 #endif | 573 #endif |
OLD | NEW |