aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrDrawState.cpp
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2014-07-18 06:15:43 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-18 06:15:43 -0700
commit9514d24fa512c9cd73548715ac36ad02f34151e8 (patch)
tree5c51c54a69e253cf32596c4e1e8012c5e9071da8 /src/gpu/GrDrawState.cpp
parent83fab4732a59c78a557ef140c8f72fca7b65af46 (diff)
Cache the return values of getBlendOpts in GrDrawState
BUG=skia: R=bsalomon@google.com Author: egdaniel@google.com Review URL: https://codereview.chromium.org/404473007
Diffstat (limited to 'src/gpu/GrDrawState.cpp')
-rw-r--r--src/gpu/GrDrawState.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp
index 8285a324d5..14ba6fad5d 100644
--- a/src/gpu/GrDrawState.cpp
+++ b/src/gpu/GrDrawState.cpp
@@ -59,6 +59,7 @@ void GrDrawState::setFromPaint(const GrPaint& paint, const SkMatrix& vm, GrRende
this->setBlendFunc(paint.getSrcBlendCoeff(), paint.getDstBlendCoeff());
this->setCoverage(paint.getCoverage());
+ this->invalidateBlendOptFlags();
}
////////////////////////////////////////////////////////////////////////////////
@@ -119,6 +120,7 @@ void GrDrawState::setVertexAttribs(const GrVertexAttrib* attribs, int count) {
overlapCheck |= (mask << offsetShift);
#endif
}
+ this->invalidateBlendOptFlags();
// Positions must be specified.
SkASSERT(-1 != fFixedFunctionVertexAttribIndices[kPosition_GrVertexAttribBinding]);
}
@@ -137,6 +139,7 @@ void GrDrawState::setDefaultVertexAttribs() {
0xff,
sizeof(fFixedFunctionVertexAttribIndices));
fFixedFunctionVertexAttribIndices[kPosition_GrVertexAttribBinding] = 0;
+ this->invalidateBlendOptFlags();
}
////////////////////////////////////////////////////////////////////////////////
@@ -286,16 +289,35 @@ bool GrDrawState::canTweakAlphaForCoverage() const {
GrDrawState::BlendOptFlags GrDrawState::getBlendOpts(bool forceCoverage,
GrBlendCoeff* srcCoeff,
GrBlendCoeff* dstCoeff) const {
-
GrBlendCoeff bogusSrcCoeff, bogusDstCoeff;
if (NULL == srcCoeff) {
srcCoeff = &bogusSrcCoeff;
}
- *srcCoeff = this->getSrcBlendCoeff();
-
if (NULL == dstCoeff) {
dstCoeff = &bogusDstCoeff;
}
+
+ if (forceCoverage) {
+ return this->calcBlendOpts(true, srcCoeff, dstCoeff);
+ }
+
+ if (0 == (fBlendOptFlags & kInvalid_BlendOptFlag)) {
+ *srcCoeff = fOptSrcBlend;
+ *dstCoeff = fOptDstBlend;
+ return fBlendOptFlags;
+ }
+
+ fBlendOptFlags = this->calcBlendOpts(forceCoverage, srcCoeff, dstCoeff);
+ fOptSrcBlend = *srcCoeff;
+ fOptDstBlend = *dstCoeff;
+
+ return fBlendOptFlags;
+}
+
+GrDrawState::BlendOptFlags GrDrawState::calcBlendOpts(bool forceCoverage,
+ GrBlendCoeff* srcCoeff,
+ GrBlendCoeff* dstCoeff) const {
+ *srcCoeff = this->getSrcBlendCoeff();
*dstCoeff = this->getDstBlendCoeff();
if (this->isColorWriteDisabled()) {