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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 * Gets whether the target is drawing clockwise, counterclockwise, | 170 * Gets whether the target is drawing clockwise, counterclockwise, |
171 * or both faces. | 171 * or both faces. |
172 * @return the current draw face(s). | 172 * @return the current draw face(s). |
173 */ | 173 */ |
174 GrDrawState::DrawFace getDrawFace() const { return fDrawFace; } | 174 GrDrawState::DrawFace getDrawFace() const { return fDrawFace; } |
175 | 175 |
176 /// @} | 176 /// @} |
177 | 177 |
178 /////////////////////////////////////////////////////////////////////////// | 178 /////////////////////////////////////////////////////////////////////////// |
179 | 179 |
180 GrGpu::DrawType drawType() const { return fDrawType; } | |
181 | |
180 const GrDeviceCoordTexture* getDstCopy() const { return fDstCopy.texture() ? &fDstCopy : NULL; } | 182 const GrDeviceCoordTexture* getDstCopy() const { return fDstCopy.texture() ? &fDstCopy : NULL; } |
181 | 183 |
182 const GrProgramDesc& programDesc() const { return fDesc; } | 184 // Finalize *MUST* be called before programDesc() |
185 void finalize(GrGpu*); | |
186 | |
187 const GrProgramDesc& programDesc() const { SkASSERT(fFinalized); return fDes c; } | |
183 | 188 |
184 private: | 189 private: |
185 /** | 190 /** |
186 * Loops through all the color stage effects to check if the stage will igno re color input or | 191 * Loops through all the color stage effects to check if the stage will igno re color input or |
187 * always output a constant color. In the ignore color input case we can ign ore all previous | 192 * always output a constant color. In the ignore color input case we can ign ore all previous |
188 * stages. In the constant color case, we can ignore all previous stages and | 193 * stages. In the constant color case, we can ignore all previous stages and |
189 * the current one and set the state color to the constant color. | 194 * the current one and set the state color to the constant color. |
190 */ | 195 */ |
191 void computeEffectiveColorStages(const GrDrawState& ds, GrProgramDesc::DescI nfo*, | 196 void computeEffectiveColorStages(const GrDrawState& ds, int* firstColorStage Idx, |
egdaniel
2014/12/03 19:42:59
This function and the one for coverage are never u
| |
192 int* firstColorStageIdx, uint8_t* fixFuncti onVAToRemove); | 197 uint8_t* fixFunctionVAToRemove); |
193 | 198 |
194 /** | 199 /** |
195 * Loops through all the coverage stage effects to check if the stage will i gnore color input. | 200 * Loops through all the coverage stage effects to check if the stage will i gnore color input. |
196 * If a coverage stage will ignore input, then we can ignore all coverage st ages before it. We | 201 * If a coverage stage will ignore input, then we can ignore all coverage st ages before it. We |
197 * loop to determine the first effective coverage stage. | 202 * loop to determine the first effective coverage stage. |
198 */ | 203 */ |
199 void computeEffectiveCoverageStages(const GrDrawState& ds, GrProgramDesc::De scInfo* descInfo, | 204 void computeEffectiveCoverageStages(const GrDrawState& ds, int* firstCoverag eStageIdx); |
200 int* firstCoverageStageIdx); | |
201 | 205 |
202 /** | 206 /** |
203 * Alter the program desc and inputs (attribs and processors) based on the b lend optimization. | 207 * Alter the program desc and inputs (attribs and processors) based on the b lend optimization. |
204 */ | 208 */ |
205 void adjustProgramForBlendOpt(const GrDrawState& ds, GrDrawState::BlendOpt, | 209 void adjustProgramForBlendOpt(const GrDrawState& ds, GrDrawState::BlendOpt, |
206 GrProgramDesc::DescInfo*, | |
207 int* firstColorStageIdx, int* firstCoverageSta geIdx); | 210 int* firstColorStageIdx, int* firstCoverageSta geIdx); |
208 | 211 |
209 /** | 212 /** |
210 * 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 |
211 * shaders they require. | 214 * shaders they require. |
212 */ | 215 */ |
213 void getStageStats(const GrDrawState& ds, int firstColorStageIdx, int firstC overageStageIdx, | 216 void getStageStats(const GrDrawState& ds, int firstColorStageIdx, int firstC overageStageIdx, |
214 bool hasLocalCoords, GrProgramDesc::DescInfo*); | 217 bool hasLocalCoords); |
215 | 218 |
216 /** | 219 /** |
217 * 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 |
218 * 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 |
219 * blend coeffs will represent those used by backend API. | 222 * blend coeffs will represent those used by backend API. |
220 */ | 223 */ |
221 void setOutputStateInfo(const GrDrawState& ds, GrDrawState::BlendOpt, const GrDrawTargetCaps&, | 224 void setOutputStateInfo(const GrDrawState& ds, GrDrawState::BlendOpt, const GrDrawTargetCaps&); |
222 GrProgramDesc::DescInfo*); | |
223 | 225 |
224 enum Flags { | 226 enum Flags { |
225 kDither_Flag = 0x1, | 227 kDither_Flag = 0x1, |
226 kHWAA_Flag = 0x2, | 228 kHWAA_Flag = 0x2, |
227 kDisableColorWrite_Flag = 0x4, | 229 kDisableColorWrite_Flag = 0x4, |
228 }; | 230 }; |
229 | 231 |
230 typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; | 232 typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; |
231 typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray; | 233 typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray; |
232 typedef GrPendingProgramElement<const GrGeometryProcessor> ProgramGeometryPr ocessor; | 234 typedef GrPendingProgramElement<const GrGeometryProcessor> ProgramGeometryPr ocessor; |
233 RenderTarget fRenderTarget; | 235 RenderTarget fRenderTarget; |
234 ScissorState fScissorState; | 236 ScissorState fScissorState; |
235 GrColor fColor; | 237 GrColor fColor; |
236 SkMatrix fViewMatrix; | 238 SkMatrix fViewMatrix; |
237 GrColor fBlendConstant; | 239 GrColor fBlendConstant; |
238 GrStencilSettings fStencilSettings; | 240 GrStencilSettings fStencilSettings; |
239 uint8_t fCoverage; | 241 uint8_t fCoverage; |
240 GrDrawState::DrawFace fDrawFace; | 242 GrDrawState::DrawFace fDrawFace; |
241 GrDeviceCoordTexture fDstCopy; | 243 GrDeviceCoordTexture fDstCopy; |
242 GrBlendCoeff fSrcBlend; | 244 GrBlendCoeff fSrcBlend; |
243 GrBlendCoeff fDstBlend; | 245 GrBlendCoeff fDstBlend; |
244 uint32_t fFlags; | 246 uint32_t fFlags; |
245 ProgramGeometryProcessor fGeometryProcessor; | 247 ProgramGeometryProcessor fGeometryProcessor; |
246 FragmentStageArray fFragmentStages; | 248 FragmentStageArray fFragmentStages; |
249 GrGpu::DrawType fDrawType; | |
250 GrProgramDesc::DescInfo fDescInfo; | |
251 bool fFinalized; | |
247 | 252 |
248 // 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. |
249 int fNumColorStages; | 254 int fNumColorStages; |
250 | 255 |
251 GrProgramDesc fDesc; | 256 GrProgramDesc fDesc; |
252 | 257 |
253 typedef SkRefCnt INHERITED; | 258 typedef SkRefCnt INHERITED; |
254 }; | 259 }; |
255 | 260 |
256 #endif | 261 #endif |
OLD | NEW |