diff options
author | egdaniel <egdaniel@google.com> | 2014-11-11 14:46:05 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-11 14:46:05 -0800 |
commit | cd8b6307fe636eeff822c0e48db2a0cb80a33830 (patch) | |
tree | cf12f74bad4d46bfd95df53f198d508eec3b2a17 | |
parent | 453cf40ac7702722695bb09ae2c6df44c19d008b (diff) |
Add isUnblended query to GrDrawState.
BUG=skia:
Review URL: https://codereview.chromium.org/715873002
-rw-r--r-- | src/gpu/GrDrawState.cpp | 20 | ||||
-rw-r--r-- | src/gpu/GrDrawState.h | 6 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp index dcf8d30717..296893c158 100644 --- a/src/gpu/GrDrawState.cpp +++ b/src/gpu/GrDrawState.cpp @@ -742,3 +742,23 @@ bool GrDrawState::srcAlphaWillBeOne() const { return inoutColor.isOpaque(); } +bool GrDrawState::willBlendWithDst() const { + if (!this->hasSolidCoverage()) { + return true; + } + + bool srcAIsOne = this->srcAlphaWillBeOne(); + GrBlendCoeff srcCoeff = this->getSrcBlendCoeff(); + GrBlendCoeff dstCoeff = this->getDstBlendCoeff(); + if (kISA_GrBlendCoeff == dstCoeff && srcAIsOne) { + dstCoeff = kZero_GrBlendCoeff; + } + if (kOne_GrBlendCoeff != srcCoeff || + kZero_GrBlendCoeff != dstCoeff || + this->willEffectReadDstColor()) { + return true; + } + + return false; +} + diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h index baa92afd59..5c76aed6a3 100644 --- a/src/gpu/GrDrawState.h +++ b/src/gpu/GrDrawState.h @@ -159,6 +159,12 @@ public: */ bool hasSolidCoverage() const; + /** + * This function returns true if the render target destination pixel values will be read for + * blending during draw. + */ + bool willBlendWithDst() const; + /// @} /////////////////////////////////////////////////////////////////////////// |