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 12 matching lines...) Expand all Loading... |
23 /** | 23 /** |
24 * Class that holds an optimized version of a GrDrawState. It is meant to be an
immutable class, | 24 * Class that holds an optimized version of a GrDrawState. It is meant to be an
immutable class, |
25 * and contains all data needed to set the state for a gpu draw. | 25 * and contains all data needed to set the state for a gpu draw. |
26 */ | 26 */ |
27 class GrOptDrawState { | 27 class GrOptDrawState { |
28 public: | 28 public: |
29 SK_DECLARE_INST_COUNT(GrOptDrawState) | 29 SK_DECLARE_INST_COUNT(GrOptDrawState) |
30 | 30 |
31 typedef GrClipMaskManager::ScissorState ScissorState; | 31 typedef GrClipMaskManager::ScissorState ScissorState; |
32 | 32 |
33 GrOptDrawState(const GrDrawState& drawState, const GrDrawTargetCaps&, const
ScissorState&, | 33 GrOptDrawState(const GrDrawState& drawState, GrGpu*, const ScissorState&, |
34 const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType); | 34 const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType); |
35 | 35 |
36 bool operator== (const GrOptDrawState& that) const; | 36 bool operator== (const GrOptDrawState& that) const; |
37 bool operator!= (const GrOptDrawState& that) const { return !(*this == that)
; } | 37 bool operator!= (const GrOptDrawState& that) const { return !(*this == that)
; } |
38 | 38 |
39 /// @} | 39 /// @} |
40 | 40 |
41 /////////////////////////////////////////////////////////////////////////// | 41 /////////////////////////////////////////////////////////////////////////// |
42 /// @name Color | 42 /// @name Color |
43 //// | 43 //// |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 * Gets whether the target is drawing clockwise, counterclockwise, | 173 * Gets whether the target is drawing clockwise, counterclockwise, |
174 * or both faces. | 174 * or both faces. |
175 * @return the current draw face(s). | 175 * @return the current draw face(s). |
176 */ | 176 */ |
177 GrDrawState::DrawFace getDrawFace() const { return fDrawFace; } | 177 GrDrawState::DrawFace getDrawFace() const { return fDrawFace; } |
178 | 178 |
179 /// @} | 179 /// @} |
180 | 180 |
181 /////////////////////////////////////////////////////////////////////////// | 181 /////////////////////////////////////////////////////////////////////////// |
182 | 182 |
183 GrGpu::DrawType drawType() const { return fDrawType; } | |
184 | |
185 const GrDeviceCoordTexture* getDstCopy() const { return fDstCopy.texture() ?
&fDstCopy : NULL; } | 183 const GrDeviceCoordTexture* getDstCopy() const { return fDstCopy.texture() ?
&fDstCopy : NULL; } |
186 | 184 |
187 // Finalize *MUST* be called before programDesc() | 185 const GrProgramDesc& programDesc() const { return fDesc; } |
188 void finalize(GrGpu*); | |
189 | |
190 const GrProgramDesc& programDesc() const { SkASSERT(fFinalized); return fDes
c; } | |
191 | 186 |
192 private: | 187 private: |
193 /** | 188 /** |
| 189 * Loops through all the color stage effects to check if the stage will igno
re color input or |
| 190 * always output a constant color. In the ignore color input case we can ign
ore all previous |
| 191 * stages. In the constant color case, we can ignore all previous stages and |
| 192 * the current one and set the state color to the constant color. |
| 193 */ |
| 194 void computeEffectiveColorStages(const GrDrawState& ds, GrProgramDesc::DescI
nfo*, |
| 195 int* firstColorStageIdx, uint8_t* fixFuncti
onVAToRemove); |
| 196 |
| 197 /** |
| 198 * Loops through all the coverage stage effects to check if the stage will i
gnore color input. |
| 199 * If a coverage stage will ignore input, then we can ignore all coverage st
ages before it. We |
| 200 * loop to determine the first effective coverage stage. |
| 201 */ |
| 202 void computeEffectiveCoverageStages(const GrDrawState& ds, GrProgramDesc::De
scInfo* descInfo, |
| 203 int* firstCoverageStageIdx); |
| 204 |
| 205 /** |
194 * Alter the program desc and inputs (attribs and processors) based on the b
lend optimization. | 206 * Alter the program desc and inputs (attribs and processors) based on the b
lend optimization. |
195 */ | 207 */ |
196 void adjustProgramForBlendOpt(const GrDrawState& ds, GrDrawState::BlendOpt, | 208 void adjustProgramForBlendOpt(const GrDrawState& ds, GrDrawState::BlendOpt, |
| 209 GrProgramDesc::DescInfo*, |
197 int* firstColorStageIdx, int* firstCoverageSta
geIdx); | 210 int* firstColorStageIdx, int* firstCoverageSta
geIdx); |
198 | 211 |
199 /** | 212 /** |
200 * Loop over the effect stages to determine various info like what data they
will read and what | 213 * Loop over the effect stages to determine various info like what data they
will read and what |
201 * shaders they require. | 214 * shaders they require. |
202 */ | 215 */ |
203 void getStageStats(const GrDrawState& ds, int firstColorStageIdx, int firstC
overageStageIdx, | 216 void getStageStats(const GrDrawState& ds, int firstColorStageIdx, int firstC
overageStageIdx, |
204 bool hasLocalCoords); | 217 bool hasLocalCoords, GrProgramDesc::DescInfo*); |
205 | 218 |
206 /** | 219 /** |
207 * Calculates the primary and secondary output types of the shader. For cert
ain output types | 220 * Calculates the primary and secondary output types of the shader. For cert
ain output types |
208 * the function may adjust the blend coefficients. After this function is ca
lled the src and dst | 221 * the function may adjust the blend coefficients. After this function is ca
lled the src and dst |
209 * blend coeffs will represent those used by backend API. | 222 * blend coeffs will represent those used by backend API. |
210 */ | 223 */ |
211 void setOutputStateInfo(const GrDrawState& ds, GrDrawState::BlendOpt, const
GrDrawTargetCaps&); | 224 void setOutputStateInfo(const GrDrawState& ds, GrDrawState::BlendOpt, const
GrDrawTargetCaps&, |
| 225 GrProgramDesc::DescInfo*); |
212 | 226 |
213 enum Flags { | 227 enum Flags { |
214 kDither_Flag = 0x1, | 228 kDither_Flag = 0x1, |
215 kHWAA_Flag = 0x2, | 229 kHWAA_Flag = 0x2, |
216 kDisableColorWrite_Flag = 0x4, | 230 kDisableColorWrite_Flag = 0x4, |
217 }; | 231 }; |
218 | 232 |
219 typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; | 233 typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; |
220 typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray; | 234 typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray; |
221 typedef GrPendingProgramElement<const GrGeometryProcessor> ProgramGeometryPr
ocessor; | 235 typedef GrPendingProgramElement<const GrGeometryProcessor> ProgramGeometryPr
ocessor; |
222 typedef GrPendingProgramElement<const GrXferProcessor> ProgramXferProcessor; | 236 typedef GrPendingProgramElement<const GrXferProcessor> ProgramXferProcessor; |
223 RenderTarget fRenderTarget; | 237 RenderTarget fRenderTarget; |
224 ScissorState fScissorState; | 238 ScissorState fScissorState; |
225 GrColor fColor; | 239 GrColor fColor; |
226 SkMatrix fViewMatrix; | 240 SkMatrix fViewMatrix; |
227 GrColor fBlendConstant; | 241 GrColor fBlendConstant; |
228 GrStencilSettings fStencilSettings; | 242 GrStencilSettings fStencilSettings; |
229 uint8_t fCoverage; | 243 uint8_t fCoverage; |
230 GrDrawState::DrawFace fDrawFace; | 244 GrDrawState::DrawFace fDrawFace; |
231 GrDeviceCoordTexture fDstCopy; | 245 GrDeviceCoordTexture fDstCopy; |
232 GrBlendCoeff fSrcBlend; | 246 GrBlendCoeff fSrcBlend; |
233 GrBlendCoeff fDstBlend; | 247 GrBlendCoeff fDstBlend; |
234 uint32_t fFlags; | 248 uint32_t fFlags; |
235 ProgramGeometryProcessor fGeometryProcessor; | 249 ProgramGeometryProcessor fGeometryProcessor; |
236 ProgramXferProcessor fXferProcessor; | 250 ProgramXferProcessor fXferProcessor; |
237 FragmentStageArray fFragmentStages; | 251 FragmentStageArray fFragmentStages; |
238 GrGpu::DrawType fDrawType; | |
239 GrProgramDesc::DescInfo fDescInfo; | |
240 bool fFinalized; | |
241 | 252 |
242 // This function is equivalent to the offset into fFragmentStages where cove
rage stages begin. | 253 // This function is equivalent to the offset into fFragmentStages where cove
rage stages begin. |
243 int fNumColorStages; | 254 int fNumColorStages; |
244 | 255 |
245 GrProgramDesc fDesc; | 256 GrProgramDesc fDesc; |
246 | 257 |
247 typedef SkRefCnt INHERITED; | 258 typedef SkRefCnt INHERITED; |
248 }; | 259 }; |
249 | 260 |
250 #endif | 261 #endif |
OLD | NEW |