aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2014-11-11 14:46:05 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-11 14:46:05 -0800
commitcd8b6307fe636eeff822c0e48db2a0cb80a33830 (patch)
treecf12f74bad4d46bfd95df53f198d508eec3b2a17
parent453cf40ac7702722695bb09ae2c6df44c19d008b (diff)
Add isUnblended query to GrDrawState.
-rw-r--r--src/gpu/GrDrawState.cpp20
-rw-r--r--src/gpu/GrDrawState.h6
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;
+
/// @}
///////////////////////////////////////////////////////////////////////////