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 GrRODrawState_DEFINED | 8 #ifndef GrRODrawState_DEFINED |
9 #define GrRODrawState_DEFINED | 9 #define GrRODrawState_DEFINED |
10 | 10 |
11 #include "GrEffectStage.h" | 11 #include "GrProcessorStage.h" |
12 #include "GrRenderTarget.h" | 12 #include "GrRenderTarget.h" |
13 #include "GrStencil.h" | 13 #include "GrStencil.h" |
14 #include "SkMatrix.h" | 14 #include "SkMatrix.h" |
15 | 15 |
16 class GrDrawState; | 16 class GrDrawState; |
17 class GrDrawTargetCaps; | 17 class GrDrawTargetCaps; |
18 class GrPaint; | 18 class GrPaint; |
19 class GrTexture; | 19 class GrTexture; |
20 | 20 |
21 /** | 21 /** |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 uint8_t getCoverage() const { return fCoverage; } | 103 uint8_t getCoverage() const { return fCoverage; } |
104 | 104 |
105 GrColor getCoverageColor() const { | 105 GrColor getCoverageColor() const { |
106 return GrColorPackRGBA(fCoverage, fCoverage, fCoverage, fCoverage); | 106 return GrColorPackRGBA(fCoverage, fCoverage, fCoverage, fCoverage); |
107 } | 107 } |
108 | 108 |
109 /// @} | 109 /// @} |
110 | 110 |
111 /////////////////////////////////////////////////////////////////////////// | 111 /////////////////////////////////////////////////////////////////////////// |
112 /// @name Effect Stages | 112 /// @name Effect Stages |
113 /// Each stage hosts a GrEffect. The effect produces an output color or cove
rage in the fragment | 113 /// Each stage hosts a GrProcessor. The effect produces an output color or c
overage in the |
114 /// shader. Its inputs are the output from the previous stage as well as som
e variables | 114 /// fragment shader. Its inputs are the output from the previous stage as we
ll as some variables |
115 /// available to it in the fragment and vertex shader (e.g. the vertex posit
ion, the dst color, | 115 /// available to it in the fragment and vertex shader (e.g. the vertex posit
ion, the dst color, |
116 /// the fragment position, local coordinates). | 116 /// the fragment position, local coordinates). |
117 /// | 117 /// |
118 /// The stages are divided into two sets, color-computing and coverage-compu
ting. The final | 118 /// The stages are divided into two sets, color-computing and coverage-compu
ting. The final |
119 /// color stage produces the final pixel color. The coverage-computing stage
s function exactly | 119 /// color stage produces the final pixel color. The coverage-computing stage
s function exactly |
120 /// as the color-computing but the output of the final coverage stage is tre
ated as a fractional | 120 /// as the color-computing but the output of the final coverage stage is tre
ated as a fractional |
121 /// pixel coverage rather than as input to the src/dst color blend step. | 121 /// pixel coverage rather than as input to the src/dst color blend step. |
122 /// | 122 /// |
123 /// The input color to the first color-stage is either the constant color or
interpolated | 123 /// The input color to the first color-stage is either the constant color or
interpolated |
124 /// per-vertex colors. The input to the first coverage stage is either a con
stant coverage | 124 /// per-vertex colors. The input to the first coverage stage is either a con
stant coverage |
125 /// (usually full-coverage) or interpolated per-vertex coverage. | 125 /// (usually full-coverage) or interpolated per-vertex coverage. |
126 /// | 126 /// |
127 /// See the documentation of kCoverageDrawing_StateBit for information about
disabling the | 127 /// See the documentation of kCoverageDrawing_StateBit for information about
disabling the |
128 /// the color / coverage distinction. | 128 /// the color / coverage distinction. |
129 //// | 129 //// |
130 | 130 |
131 int numColorStages() const { return fColorStages.count(); } | 131 int numColorStages() const { return fColorStages.count(); } |
132 int numCoverageStages() const { return fCoverageStages.count(); } | 132 int numCoverageStages() const { return fCoverageStages.count(); } |
133 int numTotalStages() const { | 133 int numTotalStages() const { |
134 return this->numColorStages() + this->numCoverageStages() + | 134 return this->numColorStages() + this->numCoverageStages() + |
135 (this->hasGeometryProcessor() ? 1 : 0); | 135 (this->hasGeometryProcessor() ? 1 : 0); |
136 } | 136 } |
137 | 137 |
138 bool hasGeometryProcessor() const { return SkToBool(fGeometryProcessor.get()
); } | 138 bool hasGeometryProcessor() const { return SkToBool(fGeometryProcessor.get()
); } |
139 const GrEffectStage* getGeometryProcessor() const { return fGeometryProcesso
r.get(); } | 139 const GrGeometryStage* getGeometryProcessor() const { return fGeometryProces
sor.get(); } |
140 const GrEffectStage& getColorStage(int stageIdx) const { return fColorStages
[stageIdx]; } | 140 const GrFragmentStage& getColorStage(int stageIdx) const { return fColorStag
es[stageIdx]; } |
141 const GrEffectStage& getCoverageStage(int stageIdx) const { return fCoverage
Stages[stageIdx]; } | 141 const GrFragmentStage& getCoverageStage(int stageIdx) const { return fCovera
geStages[stageIdx]; } |
142 | 142 |
143 /** | 143 /** |
144 * Checks whether any of the effects will read the dst pixel color. | 144 * Checks whether any of the effects will read the dst pixel color. |
145 */ | 145 */ |
146 bool willEffectReadDstColor() const; | 146 bool willEffectReadDstColor() const; |
147 | 147 |
148 /// @} | 148 /// @} |
149 | 149 |
150 /////////////////////////////////////////////////////////////////////////// | 150 /////////////////////////////////////////////////////////////////////////// |
151 /// @name Blending | 151 /// @name Blending |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 uint32_t fFlagBits; | 406 uint32_t fFlagBits; |
407 const GrVertexAttrib* fVAPtr; | 407 const GrVertexAttrib* fVAPtr; |
408 int fVACount; | 408 int fVACount; |
409 size_t fVAStride; | 409 size_t fVAStride; |
410 GrStencilSettings fStencilSettings; | 410 GrStencilSettings fStencilSettings; |
411 uint8_t fCoverage; | 411 uint8_t fCoverage; |
412 DrawFace fDrawFace; | 412 DrawFace fDrawFace; |
413 GrBlendCoeff fSrcBlend; | 413 GrBlendCoeff fSrcBlend; |
414 GrBlendCoeff fDstBlend; | 414 GrBlendCoeff fDstBlend; |
415 | 415 |
416 typedef SkSTArray<4, GrEffectStage> EffectStageArray; | 416 typedef SkSTArray<4, GrFragmentStage> FragmentStageArray; |
417 SkAutoTDelete<GrEffectStage> fGeometryProcessor; | 417 SkAutoTDelete<GrGeometryStage> fGeometryProcessor; |
418 EffectStageArray fColorStages; | 418 FragmentStageArray fColorStages; |
419 EffectStageArray fCoverageStages; | 419 FragmentStageArray fCoverageStages; |
420 | 420 |
421 uint32_t fHints; | 421 uint32_t fHints; |
422 | 422 |
423 // This is simply a different representation of info in fVertexAttribs and t
hus does | 423 // This is simply a different representation of info in fVertexAttribs and t
hus does |
424 // not need to be compared in op==. | 424 // not need to be compared in op==. |
425 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt
]; | 425 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt
]; |
426 | 426 |
427 private: | 427 private: |
428 /** | 428 /** |
429 * Determines whether src alpha is guaranteed to be one for all src pixels | 429 * Determines whether src alpha is guaranteed to be one for all src pixels |
430 */ | 430 */ |
431 bool srcAlphaWillBeOne() const; | 431 bool srcAlphaWillBeOne() const; |
432 | 432 |
433 typedef SkRefCnt INHERITED; | 433 typedef SkRefCnt INHERITED; |
434 }; | 434 }; |
435 | 435 |
436 GR_MAKE_BITFIELD_OPS(GrRODrawState::BlendOptFlags); | 436 GR_MAKE_BITFIELD_OPS(GrRODrawState::BlendOptFlags); |
437 | 437 |
438 #endif | 438 #endif |
OLD | NEW |