Chromium Code Reviews| 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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 const GrDrawTargetCaps& caps); | 372 const GrDrawTargetCaps& caps); |
| 373 | 373 |
| 374 /** | 374 /** |
| 375 * Loops through all the color stage effects to check if the stage will igno re color input or | 375 * Loops through all the color stage effects to check if the stage will igno re color input or |
| 376 * always output a constant color. In the ignore color input case we can ign ore all previous | 376 * always output a constant color. In the ignore color input case we can ign ore all previous |
| 377 * stages. In the constant color case, we can ignore all previous stages and | 377 * stages. In the constant color case, we can ignore all previous stages and |
| 378 * the current one and set the state color to the constant color. Once we de termine the so | 378 * the current one and set the state color to the constant color. Once we de termine the so |
| 379 * called first effective stage, we copy all the effective stages into our o ptimized | 379 * called first effective stage, we copy all the effective stages into our o ptimized |
| 380 * state. | 380 * state. |
| 381 */ | 381 */ |
| 382 void copyEffectiveColorStages(const GrDrawState& ds); | 382 void computeEffectiveColorStages(const GrDrawState& ds); |
| 383 | 383 |
| 384 /** | 384 /** |
| 385 * Loops through all the coverage stage effects to check if the stage will i gnore color input. | 385 * Loops through all the coverage stage effects to check if the stage will i gnore color input. |
| 386 * If a coverage stage will ignore input, then we can ignore all coverage st ages before it. We | 386 * If a coverage stage will ignore input, then we can ignore all coverage st ages before it. We |
| 387 * loop to determine the first effective coverage stage, and then copy all o f our effective | 387 * loop to determine the first effective coverage stage, and then copy all o f our effective |
| 388 * coverage stages into our optimized state. | 388 * coverage stages into our optimized state. |
| 389 */ | 389 */ |
| 390 void copyEffectiveCoverageStages(const GrDrawState& ds); | 390 void computeEffectiveCoverageStages(const GrDrawState& ds); |
| 391 | 391 |
| 392 /** | 392 /** |
| 393 * This function takes in a flag and removes the corresponding fixed functio n vertex attributes. | 393 * This function reads in the fFixedFunctionVAToRemove flag and removes the corresponding fixed |
| 394 * The flags are in the same order as GrVertexAttribBinding array. If bit i of removeVAFlags is | 394 * function vertex attributes. The flags are in the same order as GrVertexAt tribBinding array. |
| 395 * set, then vertex attributes with binding (GrVertexAttribute)i will be rem oved. | 395 * If bit i of fFixedFunctionVAToRemove is set, then vertex attributes with binding |
| 396 * (GrVertexAttribute)i will be removed. | |
| 396 */ | 397 */ |
| 397 void removeFixedFunctionVertexAttribs(uint8_t removeVAFlags); | 398 void removeFixedFunctionVertexAttribs(); |
| 398 | 399 |
| 399 /** | 400 /** |
| 400 * Alter the OptDrawState (adjusting stages, vertex attribs, flags, etc.) ba sed on the | 401 * Alter the OptDrawState (adjusting stages, vertex attribs, flags, etc.) ba sed on the |
| 401 * BlendOptFlags. | 402 * BlendOptFlags. |
| 402 */ | 403 */ |
| 403 void adjustFromBlendOpts(); | 404 void adjustFromBlendOpts(const GrDrawState& ds); |
| 404 | 405 |
| 405 /** | 406 /** |
| 406 * Loop over the effect stages to determine various info like what data they will read and what | 407 * Loop over the effect stages to determine various info like what data they will read and what |
| 407 * shaders they require. | 408 * shaders they require. |
| 408 */ | 409 */ |
| 409 void getStageStats(); | 410 void getStageStats(const GrDrawState& ds); |
| 410 | 411 |
| 411 /** | 412 /** |
| 412 * Calculates the primary and secondary output types of the shader. For cert ain output types | 413 * Calculates the primary and secondary output types of the shader. For cert ain output types |
| 413 * the function may adjust the blend coefficients. After this function is ca lled the src and dst | 414 * the function may adjust the blend coefficients. After this function is ca lled the src and dst |
| 414 * blend coeffs will represent those used by backend API. | 415 * blend coeffs will represent those used by backend API. |
| 415 */ | 416 */ |
| 416 void setOutputStateInfo(const GrDrawTargetCaps&); | 417 void setOutputStateInfo(const GrDrawState& ds, const GrDrawTargetCaps&); |
| 417 | 418 |
| 418 bool isEqual(const GrOptDrawState& that) const; | 419 bool isEqual(const GrOptDrawState& that) const; |
| 419 | 420 |
| 420 // These fields are roughly sorted by decreasing likelihood of being differe nt in op== | 421 // These fields are roughly sorted by decreasing likelihood of being differe nt in op== |
| 421 typedef GrTGpuResourceRef<GrRenderTarget> ProgramRenderTarget; | 422 typedef GrTGpuResourceRef<GrRenderTarget> ProgramRenderTarget; |
| 422 ProgramRenderTarget fRenderTarget; | 423 ProgramRenderTarget fRenderTarget; |
| 423 GrColor fColor; | 424 GrColor fColor; |
| 424 SkMatrix fViewMatrix; | 425 SkMatrix fViewMatrix; |
| 425 GrColor fBlendConstant; | 426 GrColor fBlendConstant; |
| 426 uint32_t fFlagBits; | 427 uint32_t fFlagBits; |
| 427 const GrVertexAttrib* fVAPtr; | 428 const GrVertexAttrib* fVAPtr; |
| 428 int fVACount; | 429 int fVACount; |
| 429 size_t fVAStride; | 430 size_t fVAStride; |
| 430 GrStencilSettings fStencilSettings; | 431 GrStencilSettings fStencilSettings; |
| 431 uint8_t fCoverage; | 432 uint8_t fCoverage; |
| 432 DrawFace fDrawFace; | 433 DrawFace fDrawFace; |
| 433 GrBlendCoeff fSrcBlend; | 434 GrBlendCoeff fSrcBlend; |
| 434 GrBlendCoeff fDstBlend; | 435 GrBlendCoeff fDstBlend; |
| 435 | 436 |
| 436 typedef SkSTArray<4, GrFragmentStage> FragmentStageArray; | 437 typedef SkSTArray<8, GrFragmentStage> FragmentStageArray; |
| 437 SkAutoTDelete<GrGeometryStage> fGeometryProcessor; | 438 SkAutoTDelete<GrGeometryStage> fGeometryProcessor; |
| 438 FragmentStageArray fColorStages; | 439 FragmentStageArray fColorStages; |
| 439 FragmentStageArray fCoverageStages; | 440 FragmentStageArray fCoverageStages; |
| 440 | 441 |
| 442 // Used when creating an OptDrawState from a DrawState to keep track of whic h stages to copy | |
|
bsalomon
2014/10/07 20:20:42
Do these really belong as members? Seems like they
egdaniel
2014/10/07 21:10:06
Done.
| |
| 443 // from the DS to the ODS. | |
| 444 int fFirstColorStageIdx; | |
| 445 int fFirstCoverageStageIdx; | |
| 446 bool fSeparateCoverageFromColor; | |
| 447 | |
| 448 uint8_t fFixedFunctionVAToRemove; | |
| 449 | |
| 441 // This is simply a different representation of info in fVertexAttribs and t hus does | 450 // This is simply a different representation of info in fVertexAttribs and t hus does |
| 442 // not need to be compared in op==. | 451 // not need to be compared in op==. |
| 443 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt ]; | 452 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt ]; |
| 444 | 453 |
| 445 // These flags are needed to protect the code from creating an unused unifor m color/coverage | 454 // These flags are needed to protect the code from creating an unused unifor m color/coverage |
| 446 // which will cause shader compiler errors. | 455 // which will cause shader compiler errors. |
| 447 bool fInputColorIsUsed; | 456 bool fInputColorIsUsed; |
| 448 bool fInputCoverageIsUsed; | 457 bool fInputCoverageIsUsed; |
| 449 | 458 |
| 450 // These flags give aggregated info on the effect stages that are used when building programs. | 459 // These flags give aggregated info on the effect stages that are used when building programs. |
| 451 bool fReadsDst; | 460 bool fReadsDst; |
| 452 bool fReadsFragPosition; | 461 bool fReadsFragPosition; |
| 453 bool fRequiresLocalCoordAttrib; | 462 bool fRequiresLocalCoordAttrib; |
| 454 | 463 |
| 455 SkAutoSTArray<4, GrVertexAttrib> fOptVA; | 464 SkAutoSTArray<4, GrVertexAttrib> fOptVA; |
| 456 | 465 |
| 457 BlendOptFlags fBlendOptFlags; | 466 BlendOptFlags fBlendOptFlags; |
| 458 | 467 |
| 459 // Fragment shader color outputs | 468 // Fragment shader color outputs |
| 460 PrimaryOutputType fPrimaryOutputType : 8; | 469 PrimaryOutputType fPrimaryOutputType : 8; |
| 461 SecondaryOutputType fSecondaryOutputType : 8; | 470 SecondaryOutputType fSecondaryOutputType : 8; |
| 462 | 471 |
| 463 typedef SkRefCnt INHERITED; | 472 typedef SkRefCnt INHERITED; |
| 464 }; | 473 }; |
| 465 | 474 |
| 466 GR_MAKE_BITFIELD_OPS(GrOptDrawState::BlendOptFlags); | 475 GR_MAKE_BITFIELD_OPS(GrOptDrawState::BlendOptFlags); |
| 467 | 476 |
| 468 #endif | 477 #endif |
| 469 | 478 |
| OLD | NEW |