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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 /// | 72 /// |
73 /// The input color to the first color-stage is either the constant color or
interpolated | 73 /// The input color to the first color-stage is either the constant color or
interpolated |
74 /// per-vertex colors. The input to the first coverage stage is either a con
stant coverage | 74 /// per-vertex colors. The input to the first coverage stage is either a con
stant coverage |
75 /// (usually full-coverage) or interpolated per-vertex coverage. | 75 /// (usually full-coverage) or interpolated per-vertex coverage. |
76 //// | 76 //// |
77 | 77 |
78 int numColorStages() const { return fNumColorStages; } | 78 int numColorStages() const { return fNumColorStages; } |
79 int numCoverageStages() const { return fFragmentStages.count() - fNumColorSt
ages; } | 79 int numCoverageStages() const { return fFragmentStages.count() - fNumColorSt
ages; } |
80 int numFragmentStages() const { return fFragmentStages.count(); } | 80 int numFragmentStages() const { return fFragmentStages.count(); } |
81 int numTotalStages() const { | 81 int numTotalStages() const { |
82 return this->numFragmentStages() + (this->hasGeometryProcessor() ? 1 :
0); | 82 // the + 1 at the end is for the xferProcessor which will always be pres
ent |
| 83 return this->numFragmentStages() + (this->hasGeometryProcessor() ? 1 : 0
) + 1; |
83 } | 84 } |
84 | 85 |
85 bool hasGeometryProcessor() const { return SkToBool(fGeometryProcessor.get()
); } | 86 bool hasGeometryProcessor() const { return SkToBool(fGeometryProcessor.get()
); } |
86 const GrGeometryProcessor* getGeometryProcessor() const { return fGeometryPr
ocessor.get(); } | 87 const GrGeometryProcessor* getGeometryProcessor() const { return fGeometryPr
ocessor.get(); } |
87 const GrBatchTracker& getBatchTracker() const { return fBatchTracker; } | 88 const GrBatchTracker& getBatchTracker() const { return fBatchTracker; } |
88 | 89 |
89 const GrXferProcessor* getXferProcessor() const { return fXferProcessor.get(
); } | 90 const GrXferProcessor* getXferProcessor() const { return fXferProcessor.get(
); } |
90 | 91 |
91 const GrPendingFragmentStage& getColorStage(int idx) const { | 92 const GrPendingFragmentStage& getColorStage(int idx) const { |
92 SkASSERT(idx < this->numColorStages()); | 93 SkASSERT(idx < this->numColorStages()); |
93 return fFragmentStages[idx]; | 94 return fFragmentStages[idx]; |
94 } | 95 } |
95 const GrPendingFragmentStage& getCoverageStage(int idx) const { | 96 const GrPendingFragmentStage& getCoverageStage(int idx) const { |
96 SkASSERT(idx < this->numCoverageStages()); | 97 SkASSERT(idx < this->numCoverageStages()); |
97 return fFragmentStages[fNumColorStages + idx]; | 98 return fFragmentStages[fNumColorStages + idx]; |
98 } | 99 } |
99 const GrPendingFragmentStage& getFragmentStage(int idx) const { | 100 const GrPendingFragmentStage& getFragmentStage(int idx) const { |
100 return fFragmentStages[idx]; | 101 return fFragmentStages[idx]; |
101 } | 102 } |
102 | 103 |
103 /// @} | 104 /// @} |
104 | 105 |
105 /////////////////////////////////////////////////////////////////////////// | 106 /////////////////////////////////////////////////////////////////////////// |
106 /// @name Blending | |
107 //// | |
108 | |
109 GrBlendCoeff getSrcBlendCoeff() const { return fSrcBlend; } | |
110 GrBlendCoeff getDstBlendCoeff() const { return fDstBlend; } | |
111 | |
112 /** | |
113 * Retrieves the last value set by setBlendConstant() | |
114 * @return the blending constant value | |
115 */ | |
116 GrColor getBlendConstant() const { return fBlendConstant; } | |
117 | |
118 /// @} | |
119 | |
120 /////////////////////////////////////////////////////////////////////////// | |
121 /// @name View Matrix | 107 /// @name View Matrix |
122 //// | 108 //// |
123 | 109 |
124 /** | 110 /** |
125 * Retrieves the current view matrix | 111 * Retrieves the current view matrix |
126 * @return the current view matrix. | 112 * @return the current view matrix. |
127 */ | 113 */ |
128 const SkMatrix& getViewMatrix() const { return fViewMatrix; } | 114 const SkMatrix& getViewMatrix() const { return fViewMatrix; } |
129 | 115 |
130 /// @} | 116 /// @} |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 }; | 202 }; |
217 | 203 |
218 typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; | 204 typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; |
219 typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray; | 205 typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray; |
220 typedef GrPendingProgramElement<const GrGeometryProcessor> ProgramGeometryPr
ocessor; | 206 typedef GrPendingProgramElement<const GrGeometryProcessor> ProgramGeometryPr
ocessor; |
221 typedef GrPendingProgramElement<const GrXferProcessor> ProgramXferProcessor; | 207 typedef GrPendingProgramElement<const GrXferProcessor> ProgramXferProcessor; |
222 RenderTarget fRenderTarget; | 208 RenderTarget fRenderTarget; |
223 ScissorState fScissorState; | 209 ScissorState fScissorState; |
224 GrColor fColor; | 210 GrColor fColor; |
225 SkMatrix fViewMatrix; | 211 SkMatrix fViewMatrix; |
226 GrColor fBlendConstant; | |
227 GrStencilSettings fStencilSettings; | 212 GrStencilSettings fStencilSettings; |
228 uint8_t fCoverage; | 213 uint8_t fCoverage; |
229 GrDrawState::DrawFace fDrawFace; | 214 GrDrawState::DrawFace fDrawFace; |
230 GrDeviceCoordTexture fDstCopy; | 215 GrDeviceCoordTexture fDstCopy; |
231 GrBlendCoeff fSrcBlend; | |
232 GrBlendCoeff fDstBlend; | |
233 uint32_t fFlags; | 216 uint32_t fFlags; |
234 ProgramGeometryProcessor fGeometryProcessor; | 217 ProgramGeometryProcessor fGeometryProcessor; |
235 GrBatchTracker fBatchTracker; | 218 GrBatchTracker fBatchTracker; |
236 ProgramXferProcessor fXferProcessor; | 219 ProgramXferProcessor fXferProcessor; |
237 FragmentStageArray fFragmentStages; | 220 FragmentStageArray fFragmentStages; |
238 GrGpu::DrawType fDrawType; | 221 GrGpu::DrawType fDrawType; |
239 GrProgramDesc::DescInfo fDescInfo; | 222 GrProgramDesc::DescInfo fDescInfo; |
240 bool fFinalized; | 223 bool fFinalized; |
241 | 224 |
242 // This function is equivalent to the offset into fFragmentStages where cove
rage stages begin. | 225 // This function is equivalent to the offset into fFragmentStages where cove
rage stages begin. |
243 int fNumColorStages; | 226 int fNumColorStages; |
244 | 227 |
245 GrProgramDesc fDesc; | 228 GrProgramDesc fDesc; |
246 | 229 |
247 typedef SkRefCnt INHERITED; | 230 typedef SkRefCnt INHERITED; |
248 }; | 231 }; |
249 | 232 |
250 #endif | 233 #endif |
OLD | NEW |