| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 const GrDeviceCoordTexture* getDstCopy() const { return fDstCopy.texture() ?
&fDstCopy : NULL; } | 180 const GrDeviceCoordTexture* getDstCopy() const { return fDstCopy.texture() ?
&fDstCopy : NULL; } |
| 181 | 181 |
| 182 const GrProgramDesc& programDesc() const { return fDesc; } | 182 const GrProgramDesc::DescInfo& descInfo() const { return fDescInfo; } |
| 183 | 183 |
| 184 private: | 184 private: |
| 185 /** | 185 /** |
| 186 * Loops through all the color stage effects to check if the stage will igno
re color input or | 186 * 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 | 187 * 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 | 188 * 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. | 189 * the current one and set the state color to the constant color. |
| 190 */ | 190 */ |
| 191 void computeEffectiveColorStages(const GrDrawState& ds, GrProgramDesc::DescI
nfo*, | 191 void computeEffectiveColorStages(const GrDrawState& ds, int* firstColorStage
Idx, |
| 192 int* firstColorStageIdx, uint8_t* fixFuncti
onVAToRemove); | 192 uint8_t* fixFunctionVAToRemove); |
| 193 | 193 |
| 194 /** | 194 /** |
| 195 * Loops through all the coverage stage effects to check if the stage will i
gnore color input. | 195 * 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 | 196 * 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. | 197 * loop to determine the first effective coverage stage. |
| 198 */ | 198 */ |
| 199 void computeEffectiveCoverageStages(const GrDrawState& ds, GrProgramDesc::De
scInfo* descInfo, | 199 void computeEffectiveCoverageStages(const GrDrawState& ds, int* firstCoverag
eStageIdx); |
| 200 int* firstCoverageStageIdx); | |
| 201 | 200 |
| 202 /** | 201 /** |
| 203 * Alter the program desc and inputs (attribs and processors) based on the b
lend optimization. | 202 * Alter the program desc and inputs (attribs and processors) based on the b
lend optimization. |
| 204 */ | 203 */ |
| 205 void adjustProgramForBlendOpt(const GrDrawState& ds, GrDrawState::BlendOpt, | 204 void adjustProgramForBlendOpt(const GrDrawState& ds, GrDrawState::BlendOpt, |
| 206 GrProgramDesc::DescInfo*, | |
| 207 int* firstColorStageIdx, int* firstCoverageSta
geIdx); | 205 int* firstColorStageIdx, int* firstCoverageSta
geIdx); |
| 208 | 206 |
| 209 /** | 207 /** |
| 210 * Loop over the effect stages to determine various info like what data they
will read and what | 208 * Loop over the effect stages to determine various info like what data they
will read and what |
| 211 * shaders they require. | 209 * shaders they require. |
| 212 */ | 210 */ |
| 213 void getStageStats(const GrDrawState& ds, int firstColorStageIdx, int firstC
overageStageIdx, | 211 void getStageStats(const GrDrawState& ds, int firstColorStageIdx, int firstC
overageStageIdx, |
| 214 bool hasLocalCoords, GrProgramDesc::DescInfo*); | 212 bool hasLocalCoords); |
| 215 | 213 |
| 216 /** | 214 /** |
| 217 * Calculates the primary and secondary output types of the shader. For cert
ain output types | 215 * 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 | 216 * 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. | 217 * blend coeffs will represent those used by backend API. |
| 220 */ | 218 */ |
| 221 void setOutputStateInfo(const GrDrawState& ds, GrDrawState::BlendOpt, const
GrDrawTargetCaps&, | 219 void setOutputStateInfo(const GrDrawState& ds, GrDrawState::BlendOpt, const
GrDrawTargetCaps&); |
| 222 GrProgramDesc::DescInfo*); | |
| 223 | 220 |
| 224 enum Flags { | 221 enum Flags { |
| 225 kDither_Flag = 0x1, | 222 kDither_Flag = 0x1, |
| 226 kHWAA_Flag = 0x2, | 223 kHWAA_Flag = 0x2, |
| 227 kDisableColorWrite_Flag = 0x4, | 224 kDisableColorWrite_Flag = 0x4, |
| 228 }; | 225 }; |
| 229 | 226 |
| 230 typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; | 227 typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; |
| 231 typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray; | 228 typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray; |
| 232 typedef GrPendingProgramElement<const GrGeometryProcessor> ProgramGeometryPr
ocessor; | 229 typedef GrPendingProgramElement<const GrGeometryProcessor> ProgramGeometryPr
ocessor; |
| 233 RenderTarget fRenderTarget; | 230 RenderTarget fRenderTarget; |
| 234 ScissorState fScissorState; | 231 ScissorState fScissorState; |
| 235 GrColor fColor; | 232 GrColor fColor; |
| 236 SkMatrix fViewMatrix; | 233 SkMatrix fViewMatrix; |
| 237 GrColor fBlendConstant; | 234 GrColor fBlendConstant; |
| 238 GrStencilSettings fStencilSettings; | 235 GrStencilSettings fStencilSettings; |
| 239 uint8_t fCoverage; | 236 uint8_t fCoverage; |
| 240 GrDrawState::DrawFace fDrawFace; | 237 GrDrawState::DrawFace fDrawFace; |
| 241 GrDeviceCoordTexture fDstCopy; | 238 GrDeviceCoordTexture fDstCopy; |
| 242 GrBlendCoeff fSrcBlend; | 239 GrBlendCoeff fSrcBlend; |
| 243 GrBlendCoeff fDstBlend; | 240 GrBlendCoeff fDstBlend; |
| 244 uint32_t fFlags; | 241 uint32_t fFlags; |
| 245 ProgramGeometryProcessor fGeometryProcessor; | 242 ProgramGeometryProcessor fGeometryProcessor; |
| 246 FragmentStageArray fFragmentStages; | 243 FragmentStageArray fFragmentStages; |
| 244 GrProgramDesc::DescInfo fDescInfo; |
| 247 | 245 |
| 248 // This function is equivalent to the offset into fFragmentStages where cove
rage stages begin. | 246 // This function is equivalent to the offset into fFragmentStages where cove
rage stages begin. |
| 249 int fNumColorStages; | 247 int fNumColorStages; |
| 250 | 248 |
| 251 GrProgramDesc fDesc; | |
| 252 | |
| 253 typedef SkRefCnt INHERITED; | 249 typedef SkRefCnt INHERITED; |
| 254 }; | 250 }; |
| 255 | 251 |
| 256 #endif | 252 #endif |
| OLD | NEW |