OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 GrOptDrawState_DEFINED | 8 #ifndef GrOptDrawState_DEFINED |
9 #define GrOptDrawState_DEFINED | 9 #define GrOptDrawState_DEFINED |
10 | 10 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 /// pixel coverage rather than as input to the src/dst color blend step. | 112 /// pixel coverage rather than as input to the src/dst color blend step. |
113 /// | 113 /// |
114 /// The input color to the first color-stage is either the constant color or
interpolated | 114 /// The input color to the first color-stage is either the constant color or
interpolated |
115 /// per-vertex colors. The input to the first coverage stage is either a con
stant coverage | 115 /// per-vertex colors. The input to the first coverage stage is either a con
stant coverage |
116 /// (usually full-coverage) or interpolated per-vertex coverage. | 116 /// (usually full-coverage) or interpolated per-vertex coverage. |
117 /// | 117 /// |
118 /// See the documentation of kCoverageDrawing_StateBit for information about
disabling the | 118 /// See the documentation of kCoverageDrawing_StateBit for information about
disabling the |
119 /// the color / coverage distinction. | 119 /// the color / coverage distinction. |
120 //// | 120 //// |
121 | 121 |
122 int numColorStages() const { return fColorStages.count(); } | 122 int numColorStages() const { return fNumColorStages; } |
123 int numCoverageStages() const { return fCoverageStages.count(); } | 123 int numCoverageStages() const { return fFragmentStages.count() - fNumColorSt
ages; } |
| 124 int numFragmentStages() const { return fFragmentStages.count(); } |
124 int numTotalStages() const { | 125 int numTotalStages() const { |
125 return this->numColorStages() + this->numCoverageStages() + | 126 return this->numFragmentStages() + (this->hasGeometryProcessor() ? 1 :
0); |
126 (this->hasGeometryProcessor() ? 1 : 0); | |
127 } | 127 } |
128 | 128 |
129 bool hasGeometryProcessor() const { return SkToBool(fGeometryProcessor.get()
); } | 129 bool hasGeometryProcessor() const { return SkToBool(fGeometryProcessor.get()
); } |
130 const GrGeometryStage* getGeometryProcessor() const { return fGeometryProces
sor.get(); } | 130 const GrGeometryStage* getGeometryProcessor() const { return fGeometryProces
sor.get(); } |
131 const GrFragmentStage& getColorStage(int idx) const { return fColorStages[id
x]; } | 131 const GrFragmentStage& getColorStage(int idx) const { |
132 const GrFragmentStage& getCoverageStage(int idx) const { return fCoverageSta
ges[idx]; } | 132 SkASSERT(idx < this->numColorStages()); |
| 133 return fFragmentStages[idx]; |
| 134 } |
| 135 const GrFragmentStage& getCoverageStage(int idx) const { |
| 136 SkASSERT(idx < this->numCoverageStages()); |
| 137 return fFragmentStages[fNumColorStages + idx]; |
| 138 } |
| 139 const GrFragmentStage& getFragmentStage(int idx) const { return fFragmentSta
ges[idx]; } |
133 | 140 |
134 /// @} | 141 /// @} |
135 | 142 |
136 /////////////////////////////////////////////////////////////////////////// | 143 /////////////////////////////////////////////////////////////////////////// |
137 /// @name Blending | 144 /// @name Blending |
138 //// | 145 //// |
139 | 146 |
140 GrBlendCoeff getSrcBlendCoeff() const { return fSrcBlend; } | 147 GrBlendCoeff getSrcBlendCoeff() const { return fSrcBlend; } |
141 GrBlendCoeff getDstBlendCoeff() const { return fDstBlend; } | 148 GrBlendCoeff getDstBlendCoeff() const { return fDstBlend; } |
142 | 149 |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 int fVACount; | 435 int fVACount; |
429 size_t fVAStride; | 436 size_t fVAStride; |
430 GrStencilSettings fStencilSettings; | 437 GrStencilSettings fStencilSettings; |
431 uint8_t fCoverage; | 438 uint8_t fCoverage; |
432 DrawFace fDrawFace; | 439 DrawFace fDrawFace; |
433 GrBlendCoeff fSrcBlend; | 440 GrBlendCoeff fSrcBlend; |
434 GrBlendCoeff fDstBlend; | 441 GrBlendCoeff fDstBlend; |
435 | 442 |
436 typedef SkSTArray<8, GrFragmentStage> FragmentStageArray; | 443 typedef SkSTArray<8, GrFragmentStage> FragmentStageArray; |
437 SkAutoTDelete<GrGeometryStage> fGeometryProcessor; | 444 SkAutoTDelete<GrGeometryStage> fGeometryProcessor; |
438 FragmentStageArray fColorStages; | 445 FragmentStageArray fFragmentStages; |
439 FragmentStageArray fCoverageStages; | 446 |
| 447 // This function is equivalent to the offset into fFragmentStages where cove
rage stages begin. |
| 448 int fNumColorStages; |
440 | 449 |
441 // This is simply a different representation of info in fVertexAttribs and t
hus does | 450 // This is simply a different representation of info in fVertexAttribs and t
hus does |
442 // not need to be compared in op==. | 451 // not need to be compared in op==. |
443 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt
]; | 452 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt
]; |
444 | 453 |
445 // These flags are needed to protect the code from creating an unused unifor
m color/coverage | 454 // These flags are needed to protect the code from creating an unused unifor
m color/coverage |
446 // which will cause shader compiler errors. | 455 // which will cause shader compiler errors. |
447 bool fInputColorIsUsed; | 456 bool fInputColorIsUsed; |
448 bool fInputCoverageIsUsed; | 457 bool fInputCoverageIsUsed; |
449 | 458 |
(...skipping 10 matching lines...) Expand all Loading... |
460 PrimaryOutputType fPrimaryOutputType : 8; | 469 PrimaryOutputType fPrimaryOutputType : 8; |
461 SecondaryOutputType fSecondaryOutputType : 8; | 470 SecondaryOutputType fSecondaryOutputType : 8; |
462 | 471 |
463 typedef SkRefCnt INHERITED; | 472 typedef SkRefCnt INHERITED; |
464 }; | 473 }; |
465 | 474 |
466 GR_MAKE_BITFIELD_OPS(GrOptDrawState::BlendOptFlags); | 475 GR_MAKE_BITFIELD_OPS(GrOptDrawState::BlendOptFlags); |
467 | 476 |
468 #endif | 477 #endif |
469 | 478 |
OLD | NEW |