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, GrGpu*, const ScissorState&, | 33 GrOptDrawState(const GrDrawState& drawState, const GrDrawTargetCaps&, 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 |
183 const GrDeviceCoordTexture* getDstCopy() const { return fDstCopy.texture() ?
&fDstCopy : NULL; } | 185 const GrDeviceCoordTexture* getDstCopy() const { return fDstCopy.texture() ?
&fDstCopy : NULL; } |
184 | 186 |
185 const GrProgramDesc& programDesc() const { return fDesc; } | 187 // Finalize *MUST* be called before programDesc() |
| 188 void finalize(GrGpu*); |
| 189 |
| 190 const GrProgramDesc& programDesc() const { SkASSERT(fFinalized); return fDes
c; } |
186 | 191 |
187 private: | 192 private: |
188 /** | 193 /** |
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 /** | |
206 * Alter the program desc and inputs (attribs and processors) based on the b
lend optimization. | 194 * Alter the program desc and inputs (attribs and processors) based on the b
lend optimization. |
207 */ | 195 */ |
208 void adjustProgramForBlendOpt(const GrDrawState& ds, GrDrawState::BlendOpt, | 196 void adjustProgramForBlendOpt(const GrDrawState& ds, GrDrawState::BlendOpt, |
209 GrProgramDesc::DescInfo*, | |
210 int* firstColorStageIdx, int* firstCoverageSta
geIdx); | 197 int* firstColorStageIdx, int* firstCoverageSta
geIdx); |
211 | 198 |
212 /** | 199 /** |
213 * Loop over the effect stages to determine various info like what data they
will read and what | 200 * Loop over the effect stages to determine various info like what data they
will read and what |
214 * shaders they require. | 201 * shaders they require. |
215 */ | 202 */ |
216 void getStageStats(const GrDrawState& ds, int firstColorStageIdx, int firstC
overageStageIdx, | 203 void getStageStats(const GrDrawState& ds, int firstColorStageIdx, int firstC
overageStageIdx, |
217 bool hasLocalCoords, GrProgramDesc::DescInfo*); | 204 bool hasLocalCoords); |
218 | 205 |
219 /** | 206 /** |
220 * Calculates the primary and secondary output types of the shader. For cert
ain output types | 207 * Calculates the primary and secondary output types of the shader. For cert
ain output types |
221 * the function may adjust the blend coefficients. After this function is ca
lled the src and dst | 208 * the function may adjust the blend coefficients. After this function is ca
lled the src and dst |
222 * blend coeffs will represent those used by backend API. | 209 * blend coeffs will represent those used by backend API. |
223 */ | 210 */ |
224 void setOutputStateInfo(const GrDrawState& ds, GrDrawState::BlendOpt, const
GrDrawTargetCaps&, | 211 void setOutputStateInfo(const GrDrawState& ds, GrDrawState::BlendOpt, const
GrDrawTargetCaps&); |
225 GrProgramDesc::DescInfo*); | |
226 | 212 |
227 enum Flags { | 213 enum Flags { |
228 kDither_Flag = 0x1, | 214 kDither_Flag = 0x1, |
229 kHWAA_Flag = 0x2, | 215 kHWAA_Flag = 0x2, |
230 kDisableColorWrite_Flag = 0x4, | 216 kDisableColorWrite_Flag = 0x4, |
231 }; | 217 }; |
232 | 218 |
233 typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; | 219 typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; |
234 typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray; | 220 typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray; |
235 typedef GrPendingProgramElement<const GrGeometryProcessor> ProgramGeometryPr
ocessor; | 221 typedef GrPendingProgramElement<const GrGeometryProcessor> ProgramGeometryPr
ocessor; |
236 typedef GrPendingProgramElement<const GrXferProcessor> ProgramXferProcessor; | 222 typedef GrPendingProgramElement<const GrXferProcessor> ProgramXferProcessor; |
237 RenderTarget fRenderTarget; | 223 RenderTarget fRenderTarget; |
238 ScissorState fScissorState; | 224 ScissorState fScissorState; |
239 GrColor fColor; | 225 GrColor fColor; |
240 SkMatrix fViewMatrix; | 226 SkMatrix fViewMatrix; |
241 GrColor fBlendConstant; | 227 GrColor fBlendConstant; |
242 GrStencilSettings fStencilSettings; | 228 GrStencilSettings fStencilSettings; |
243 uint8_t fCoverage; | 229 uint8_t fCoverage; |
244 GrDrawState::DrawFace fDrawFace; | 230 GrDrawState::DrawFace fDrawFace; |
245 GrDeviceCoordTexture fDstCopy; | 231 GrDeviceCoordTexture fDstCopy; |
246 GrBlendCoeff fSrcBlend; | 232 GrBlendCoeff fSrcBlend; |
247 GrBlendCoeff fDstBlend; | 233 GrBlendCoeff fDstBlend; |
248 uint32_t fFlags; | 234 uint32_t fFlags; |
249 ProgramGeometryProcessor fGeometryProcessor; | 235 ProgramGeometryProcessor fGeometryProcessor; |
250 ProgramXferProcessor fXferProcessor; | 236 ProgramXferProcessor fXferProcessor; |
251 FragmentStageArray fFragmentStages; | 237 FragmentStageArray fFragmentStages; |
| 238 GrGpu::DrawType fDrawType; |
| 239 GrProgramDesc::DescInfo fDescInfo; |
| 240 bool fFinalized; |
252 | 241 |
253 // This function is equivalent to the offset into fFragmentStages where cove
rage stages begin. | 242 // This function is equivalent to the offset into fFragmentStages where cove
rage stages begin. |
254 int fNumColorStages; | 243 int fNumColorStages; |
255 | 244 |
256 GrProgramDesc fDesc; | 245 GrProgramDesc fDesc; |
257 | 246 |
258 typedef SkRefCnt INHERITED; | 247 typedef SkRefCnt INHERITED; |
259 }; | 248 }; |
260 | 249 |
261 #endif | 250 #endif |
OLD | NEW |