| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 * initial value (after construction or reset()) is 0xff. The constant | 158 * initial value (after construction or reset()) is 0xff. The constant |
| 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 /** |
| 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 |
| 171 * but is never put in the color processing pipeline. |
| 172 */ |
| 173 |
| 174 const GrEffect* setGeometryProcessor(const GrEffect* effect, int attr0 = -1,
int attr1 = -1) { |
| 175 SkASSERT(NULL != effect); |
| 176 SkASSERT(!this->hasGeometryProcessor()); |
| 177 fGeometryProcessor.reset(new GrEffectStage(effect, attr0, attr1)); |
| 178 this->invalidateBlendOptFlags(); |
| 179 return effect; |
| 180 } |
| 181 |
| 168 /////////////////////////////////////////////////////////////////////////// | 182 /////////////////////////////////////////////////////////////////////////// |
| 169 /// @name Effect Stages | 183 /// @name Effect Stages |
| 170 /// 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 |
| 171 /// 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 |
| 172 /// 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, |
| 173 /// the fragment position, local coordinates). | 187 /// the fragment position, local coordinates). |
| 174 /// | 188 /// |
| 175 /// 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 |
| 176 /// 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 |
| 177 /// 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 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 } | 249 } |
| 236 | 250 |
| 237 ~AutoRestoreEffects() { this->set(NULL); } | 251 ~AutoRestoreEffects() { this->set(NULL); } |
| 238 | 252 |
| 239 void set(GrDrawState* ds); | 253 void set(GrDrawState* ds); |
| 240 | 254 |
| 241 bool isSet() const { return NULL != fDrawState; } | 255 bool isSet() const { return NULL != fDrawState; } |
| 242 | 256 |
| 243 private: | 257 private: |
| 244 GrDrawState* fDrawState; | 258 GrDrawState* fDrawState; |
| 259 SkAutoTDelete<GrEffectStage> fGeometryProcessor; |
| 245 int fColorEffectCnt; | 260 int fColorEffectCnt; |
| 246 int fCoverageEffectCnt; | 261 int fCoverageEffectCnt; |
| 247 }; | 262 }; |
| 248 | 263 |
| 249 /// @} | 264 /// @} |
| 250 | 265 |
| 251 /////////////////////////////////////////////////////////////////////////// | 266 /////////////////////////////////////////////////////////////////////////// |
| 252 /// @name Blending | 267 /// @name Blending |
| 253 //// | 268 //// |
| 254 | 269 |
| (...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 | 372 /** Sets the draw state's matrix to identity. This can fail because the
current view matrix |
| 358 is not invertible. */ | 373 is not invertible. */ |
| 359 bool setIdentity(GrDrawState* drawState); | 374 bool setIdentity(GrDrawState* drawState); |
| 360 | 375 |
| 361 private: | 376 private: |
| 362 void doEffectCoordChanges(const SkMatrix& coordChangeMatrix); | 377 void doEffectCoordChanges(const SkMatrix& coordChangeMatrix); |
| 363 | 378 |
| 364 GrDrawState* fDrawState; | 379 GrDrawState* fDrawState; |
| 365 SkMatrix fViewMatrix; | 380 SkMatrix fViewMatrix; |
| 366 int fNumColorStages; | 381 int fNumColorStages; |
| 382 bool fHasGeometryProcesso
r; |
| 367 SkAutoSTArray<8, GrEffectStage::SavedCoordChange> fSavedCoordChanges; | 383 SkAutoSTArray<8, GrEffectStage::SavedCoordChange> fSavedCoordChanges; |
| 368 }; | 384 }; |
| 369 | 385 |
| 370 /// @} | 386 /// @} |
| 371 | 387 |
| 372 /////////////////////////////////////////////////////////////////////////// | 388 /////////////////////////////////////////////////////////////////////////// |
| 373 /// @name Render Target | 389 /// @name Render Target |
| 374 //// | 390 //// |
| 375 | 391 |
| 376 /** | 392 /** |
| (...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. | 544 // 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. | 545 // This is used to assert that this condition holds. |
| 530 SkDEBUGCODE(int fBlockEffectRemovalCnt;) | 546 SkDEBUGCODE(int fBlockEffectRemovalCnt;) |
| 531 | 547 |
| 532 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz
e_t stride); | 548 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz
e_t stride); |
| 533 | 549 |
| 534 typedef GrRODrawState INHERITED; | 550 typedef GrRODrawState INHERITED; |
| 535 }; | 551 }; |
| 536 | 552 |
| 537 #endif | 553 #endif |
| OLD | NEW |