diff options
author | 2014-09-16 06:34:42 -0700 | |
---|---|---|
committer | 2014-09-16 06:34:42 -0700 | |
commit | ee6206572b42fec11f83ad0c1e6d435903640518 (patch) | |
tree | eb2c5cc2e59b708065484e18c01f459f6ef59ee9 /src/gpu/GrDrawState.cpp | |
parent | 8c8f71ac07f0611d2c3ec53551c7e0f6a1cc4789 (diff) |
Attach GrOptDrawState into shader building pipeline
The OptDrawState is now used for creating the actual gl shader. Current
optimizations dones in GrOptDrawState include:
All blend optimizations
Constant color/coverage stage optimizations
BUG=skia:
R=bsalomon@google.com, joshualitt@google.com
Author: egdaniel@google.com
Review URL: https://codereview.chromium.org/504203004
Diffstat (limited to 'src/gpu/GrDrawState.cpp')
-rw-r--r-- | src/gpu/GrDrawState.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp index 642ec2669f..f639744665 100644 --- a/src/gpu/GrDrawState.cpp +++ b/src/gpu/GrDrawState.cpp @@ -15,9 +15,17 @@ GrOptDrawState* GrDrawState::createOptState() const { if (NULL == fCachedOptState) { - fCachedOptState = SkNEW_ARGS(GrOptDrawState, (*this)); + GrBlendCoeff srcCoeff; + GrBlendCoeff dstCoeff; + BlendOptFlags blendFlags = this->getBlendOpts(false, &srcCoeff, &dstCoeff); + fCachedOptState = SkNEW_ARGS(GrOptDrawState, (*this, blendFlags, srcCoeff, dstCoeff)); } else { - SkASSERT(GrOptDrawState(*this) == *fCachedOptState); +#ifdef SK_DEBUG + GrBlendCoeff srcCoeff; + GrBlendCoeff dstCoeff; + BlendOptFlags blendFlags = this->getBlendOpts(false, &srcCoeff, &dstCoeff); + SkASSERT(GrOptDrawState(*this, blendFlags, srcCoeff, dstCoeff) == *fCachedOptState); +#endif } fCachedOptState->ref(); return fCachedOptState; @@ -106,9 +114,6 @@ GrDrawState& GrDrawState::operator=(const GrDrawState& that) { } fColorStages = that.fColorStages; fCoverageStages = that.fCoverageStages; - fOptSrcBlend = that.fOptSrcBlend; - fOptDstBlend = that.fOptDstBlend; - fBlendOptFlags = that.fBlendOptFlags; fHints = that.fHints; @@ -299,7 +304,7 @@ bool GrDrawState::couldApplyCoverage(const GrDrawTargetCaps& caps) const { // or c) the src, dst blend coeffs are 1,0 and we will read Dst Color GrBlendCoeff srcCoeff; GrBlendCoeff dstCoeff; - GrRODrawState::BlendOptFlags flag = this->getBlendOpts(true, &srcCoeff, &dstCoeff); + BlendOptFlags flag = this->getBlendOpts(true, &srcCoeff, &dstCoeff); return GrRODrawState::kNone_BlendOpt != flag || (this->willEffectReadDstColor() && kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCoeff); @@ -455,3 +460,16 @@ void GrDrawState::AutoViewMatrixRestore::doEffectCoordChanges(const SkMatrix& co } } +//////////////////////////////////////////////////////////////////////////////// + +void GrDrawState::invalidateOptState() const { + SkSafeSetNull(fCachedOptState); +} + +//////////////////////////////////////////////////////////////////////////////// + +GrDrawState::~GrDrawState() { + SkSafeUnref(fCachedOptState); + SkASSERT(0 == fBlockEffectRemovalCnt); +} + |