| 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 |
| 11 #include "GrColor.h" | 11 #include "GrColor.h" |
| 12 #include "GrGpu.h" | 12 #include "GrGpu.h" |
| 13 #include "GrProcessorStage.h" | 13 #include "GrProcessorStage.h" |
| 14 #include "GrProgramDesc.h" |
| 14 #include "GrStencil.h" | 15 #include "GrStencil.h" |
| 15 #include "GrTypesPriv.h" | 16 #include "GrTypesPriv.h" |
| 16 #include "SkMatrix.h" | 17 #include "SkMatrix.h" |
| 17 #include "SkRefCnt.h" | 18 #include "SkRefCnt.h" |
| 18 | 19 |
| 20 class GrDeviceCoordTexture; |
| 19 class GrDrawState; | 21 class GrDrawState; |
| 20 | 22 |
| 21 /** | 23 /** |
| 22 * 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, |
| 23 * 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. |
| 24 */ | 26 */ |
| 25 class GrOptDrawState : public SkRefCnt { | 27 class GrOptDrawState : public SkRefCnt { |
| 26 public: | 28 public: |
| 27 /** | 29 /** |
| 28 * Returns a snapshot of the current optimized state. If the current drawSta
te has a valid | 30 * Returns a snapshot of the current optimized state. If the current drawSta
te has a valid |
| 29 * cached optimiezed state it will simply return a pointer to it otherwise i
t will create a new | 31 * cached optimiezed state it will simply return a pointer to it otherwise i
t will create a new |
| 30 * GrOptDrawState. In all cases the GrOptDrawState is reffed and ownership i
s given to the | 32 * GrOptDrawState. In all cases the GrOptDrawState is reffed and ownership i
s given to the |
| 31 * caller. | 33 * caller. |
| 32 */ | 34 */ |
| 33 static GrOptDrawState* Create(const GrDrawState& drawState, const GrDrawTarg
etCaps& caps, | 35 static GrOptDrawState* Create(const GrDrawState& drawState, GrGpu*, |
| 34 GrGpu::DrawType drawType); | 36 const GrDeviceCoordTexture* dstCopy, GrGpu::Dr
awType drawType); |
| 35 | 37 |
| 36 bool operator== (const GrOptDrawState& that) const; | 38 bool operator== (const GrOptDrawState& that) const; |
| 37 | 39 |
| 38 /////////////////////////////////////////////////////////////////////////// | 40 /////////////////////////////////////////////////////////////////////////// |
| 39 /// @name Vertex Attributes | 41 /// @name Vertex Attributes |
| 40 //// | 42 //// |
| 41 | 43 |
| 42 enum { | 44 enum { |
| 43 kMaxVertexAttribCnt = kLast_GrVertexAttribBinding + 4, | 45 kMaxVertexAttribCnt = kLast_GrVertexAttribBinding + 4, |
| 44 }; | 46 }; |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 kB_CombinedState, | 301 kB_CombinedState, |
| 300 }; | 302 }; |
| 301 | 303 |
| 302 bool inputColorIsUsed() const { return fInputColorIsUsed; } | 304 bool inputColorIsUsed() const { return fInputColorIsUsed; } |
| 303 bool inputCoverageIsUsed() const { return fInputCoverageIsUsed; } | 305 bool inputCoverageIsUsed() const { return fInputCoverageIsUsed; } |
| 304 | 306 |
| 305 bool readsDst() const { return fReadsDst; } | 307 bool readsDst() const { return fReadsDst; } |
| 306 bool readsFragPosition() const { return fReadsFragPosition; } | 308 bool readsFragPosition() const { return fReadsFragPosition; } |
| 307 bool requiresLocalCoordAttrib() const { return fRequiresLocalCoordAttrib; } | 309 bool requiresLocalCoordAttrib() const { return fRequiresLocalCoordAttrib; } |
| 308 | 310 |
| 309 /////////////////////////////////////////////////////////////////////////// | 311 GrProgramDesc::PrimaryOutputType getPrimaryOutputType() const { return fPrim
aryOutputType; } |
| 310 /// @name Stage Output Types | 312 GrProgramDesc::SecondaryOutputType getSecondaryOutputType() const { return f
SecondaryOutputType; } |
| 311 //// | |
| 312 | 313 |
| 313 enum PrimaryOutputType { | 314 const GrProgramDesc& desc() const { return fDesc; } |
| 314 // Modulate color and coverage, write result as the color output. | |
| 315 kModulate_PrimaryOutputType, | |
| 316 // Combines the coverage, dst, and color as coverage * color + (1 - cove
rage) * dst. This | |
| 317 // can only be set if fDstReadKey is non-zero. | |
| 318 kCombineWithDst_PrimaryOutputType, | |
| 319 | |
| 320 kPrimaryOutputTypeCnt, | |
| 321 }; | |
| 322 | |
| 323 enum SecondaryOutputType { | |
| 324 // There is no secondary output | |
| 325 kNone_SecondaryOutputType, | |
| 326 // Writes coverage as the secondary output. Only set if dual source blen
ding is supported | |
| 327 // and primary output is kModulate. | |
| 328 kCoverage_SecondaryOutputType, | |
| 329 // Writes coverage * (1 - colorA) as the secondary output. Only set if d
ual source blending | |
| 330 // is supported and primary output is kModulate. | |
| 331 kCoverageISA_SecondaryOutputType, | |
| 332 // Writes coverage * (1 - colorRGBA) as the secondary output. Only set i
f dual source | |
| 333 // blending is supported and primary output is kModulate. | |
| 334 kCoverageISC_SecondaryOutputType, | |
| 335 | |
| 336 kSecondaryOutputTypeCnt, | |
| 337 }; | |
| 338 | |
| 339 PrimaryOutputType getPrimaryOutputType() const { return fPrimaryOutputType;
} | |
| 340 SecondaryOutputType getSecondaryOutputType() const { return fSecondaryOutput
Type; } | |
| 341 | 315 |
| 342 /// @} | 316 /// @} |
| 343 | 317 |
| 344 private: | 318 private: |
| 345 /** | 319 /** |
| 346 * Optimizations for blending / coverage to that can be applied based on the
current state. | 320 * Optimizations for blending / coverage to that can be applied based on the
current state. |
| 347 */ | 321 */ |
| 348 enum BlendOptFlags { | 322 enum BlendOptFlags { |
| 349 /** | 323 /** |
| 350 * No optimization | 324 * No optimization |
| (...skipping 18 matching lines...) Expand all Loading... |
| 369 */ | 343 */ |
| 370 kEmitTransBlack_BlendOptFlag = 0x8, | 344 kEmitTransBlack_BlendOptFlag = 0x8, |
| 371 }; | 345 }; |
| 372 GR_DECL_BITFIELD_OPS_FRIENDS(BlendOptFlags); | 346 GR_DECL_BITFIELD_OPS_FRIENDS(BlendOptFlags); |
| 373 | 347 |
| 374 /** | 348 /** |
| 375 * Constructs and optimized drawState out of a GrRODrawState. | 349 * Constructs and optimized drawState out of a GrRODrawState. |
| 376 */ | 350 */ |
| 377 GrOptDrawState(const GrDrawState& drawState, BlendOptFlags blendOptFlags, | 351 GrOptDrawState(const GrDrawState& drawState, BlendOptFlags blendOptFlags, |
| 378 GrBlendCoeff optSrcCoeff, GrBlendCoeff optDstCoeff, | 352 GrBlendCoeff optSrcCoeff, GrBlendCoeff optDstCoeff, |
| 379 const GrDrawTargetCaps& caps); | 353 GrGpu*, const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType)
; |
| 380 | 354 |
| 381 /** | 355 /** |
| 382 * Loops through all the color stage effects to check if the stage will igno
re color input or | 356 * Loops through all the color stage effects to check if the stage will igno
re color input or |
| 383 * always output a constant color. In the ignore color input case we can ign
ore all previous | 357 * always output a constant color. In the ignore color input case we can ign
ore all previous |
| 384 * stages. In the constant color case, we can ignore all previous stages and | 358 * stages. In the constant color case, we can ignore all previous stages and |
| 385 * the current one and set the state color to the constant color. | 359 * the current one and set the state color to the constant color. |
| 386 */ | 360 */ |
| 387 void computeEffectiveColorStages(const GrDrawState& ds, int* firstColorStage
Idx, | 361 void computeEffectiveColorStages(const GrDrawState& ds, int* firstColorStage
Idx, |
| 388 uint8_t* fixFunctionVAToRemove); | 362 uint8_t* fixFunctionVAToRemove); |
| 389 | 363 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 // These flags give aggregated info on the effect stages that are used when
building programs. | 434 // These flags give aggregated info on the effect stages that are used when
building programs. |
| 461 bool fReadsDst; | 435 bool fReadsDst; |
| 462 bool fReadsFragPosition; | 436 bool fReadsFragPosition; |
| 463 bool fRequiresLocalCoordAttrib; | 437 bool fRequiresLocalCoordAttrib; |
| 464 | 438 |
| 465 SkAutoSTArray<4, GrVertexAttrib> fOptVA; | 439 SkAutoSTArray<4, GrVertexAttrib> fOptVA; |
| 466 | 440 |
| 467 BlendOptFlags fBlendOptFlags; | 441 BlendOptFlags fBlendOptFlags; |
| 468 | 442 |
| 469 // Fragment shader color outputs | 443 // Fragment shader color outputs |
| 470 PrimaryOutputType fPrimaryOutputType : 8; | 444 GrProgramDesc::PrimaryOutputType fPrimaryOutputType : 8; |
| 471 SecondaryOutputType fSecondaryOutputType : 8; | 445 GrProgramDesc::SecondaryOutputType fSecondaryOutputType : 8; |
| 446 |
| 447 GrProgramDesc fDesc; |
| 472 | 448 |
| 473 typedef SkRefCnt INHERITED; | 449 typedef SkRefCnt INHERITED; |
| 474 }; | 450 }; |
| 475 | 451 |
| 476 GR_MAKE_BITFIELD_OPS(GrOptDrawState::BlendOptFlags); | 452 GR_MAKE_BITFIELD_OPS(GrOptDrawState::BlendOptFlags); |
| 477 | 453 |
| 478 #endif | 454 #endif |
| 479 | 455 |
| OLD | NEW |