Index: src/gpu/GrDrawState.cpp |
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp |
index db70bfaaa2351c6ecb964c103f2f3291c261c1a0..c25467fb75346929a17e0037369a32cabfd63d71 100644 |
--- a/src/gpu/GrDrawState.cpp |
+++ b/src/gpu/GrDrawState.cpp |
@@ -17,11 +17,6 @@ |
/////////////////////////////////////////////////////////////////////////////// |
bool GrDrawState::isEqual(const GrDrawState& that) const { |
- bool usingVertexColors = this->hasColorVertexAttribute(); |
- if (!usingVertexColors && this->fColor != that.fColor) { |
- return false; |
- } |
- |
if (this->getRenderTarget() != that.getRenderTarget() || |
this->fColorStages.count() != that.fColorStages.count() || |
this->fCoverageStages.count() != that.fCoverageStages.count() || |
@@ -35,11 +30,6 @@ bool GrDrawState::isEqual(const GrDrawState& that) const { |
return false; |
} |
- bool usingVertexCoverage = this->hasCoverageVertexAttribute(); |
- if (!usingVertexCoverage && this->fCoverage != that.fCoverage) { |
- return false; |
- } |
- |
bool explicitLocalCoords = this->hasLocalCoordAttribute(); |
if (this->hasGeometryProcessor()) { |
if (!that.hasGeometryProcessor()) { |
@@ -84,14 +74,12 @@ GrDrawState::GrDrawState(const GrDrawState& state, const SkMatrix& preConcatMatr |
GrDrawState& GrDrawState::operator=(const GrDrawState& that) { |
fRenderTarget.reset(SkSafeRef(that.fRenderTarget.get())); |
- fColor = that.fColor; |
fViewMatrix = that.fViewMatrix; |
fSrcBlend = that.fSrcBlend; |
fDstBlend = that.fDstBlend; |
fBlendConstant = that.fBlendConstant; |
fFlagBits = that.fFlagBits; |
fStencilSettings = that.fStencilSettings; |
- fCoverage = that.fCoverage; |
fDrawFace = that.fDrawFace; |
fGeometryProcessor.reset(SkSafeRef(that.fGeometryProcessor.get())); |
fXPFactory.reset(SkRef(that.getXPFactory())); |
@@ -120,7 +108,6 @@ void GrDrawState::onReset(const SkMatrix* initialViewMatrix) { |
fColorStages.reset(); |
fCoverageStages.reset(); |
- fColor = 0xffffffff; |
if (NULL == initialViewMatrix) { |
fViewMatrix.reset(); |
} else { |
@@ -131,7 +118,6 @@ void GrDrawState::onReset(const SkMatrix* initialViewMatrix) { |
fBlendConstant = 0x0; |
fFlagBits = 0x0; |
fStencilSettings.setDisabled(); |
- fCoverage = 0xff; |
fDrawFace = kBoth_DrawFace; |
fHints = 0; |
@@ -190,18 +176,17 @@ void GrDrawState::setFromPaint(const GrPaint& paint, const SkMatrix& vm, GrRende |
// Enable the clip bit |
this->enableState(GrDrawState::kClip_StateBit); |
- this->setColor(paint.getColor()); |
this->setState(GrDrawState::kDither_StateBit, paint.isDither()); |
this->setState(GrDrawState::kHWAntialias_StateBit, paint.isAntiAlias()); |
- this->setCoverage(0xFF); |
fColorProcInfoValid = false; |
fCoverageProcInfoValid = false; |
} |
//////////////////////////////////////////////////////////////////////////////// |
-bool GrDrawState::couldApplyCoverage(const GrDrawTargetCaps& caps) const { |
+bool GrDrawState::couldApplyCoverage(GrColor color, GrColor coverage, |
+ const GrDrawTargetCaps& caps) const { |
if (caps.dualSourceBlendingSupport()) { |
return true; |
} |
@@ -210,13 +195,13 @@ 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; |
- BlendOpt opt = this->getBlendOpt(true, &srcCoeff, &dstCoeff); |
+ BlendOpt opt = this->getBlendOpt(color, coverage, true, &srcCoeff, &dstCoeff); |
return GrDrawState::kNone_BlendOpt != opt || |
- (this->willEffectReadDstColor() && |
+ (this->willEffectReadDstColor(color, coverage) && |
kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCoeff); |
} |
-bool GrDrawState::hasSolidCoverage() const { |
+bool GrDrawState::hasSolidCoverage(GrColor coverage) const { |
// If we're drawing coverage directly then coverage is effectively treated as color. |
if (this->isCoverageDrawing()) { |
return true; |
@@ -226,20 +211,20 @@ bool GrDrawState::hasSolidCoverage() const { |
return false; |
} |
- this->calcCoverageInvariantOutput(); |
+ this->calcCoverageInvariantOutput(coverage); |
return fCoverageProcInfo.isSolidWhite(); |
} |
//////////////////////////////////////////////////////////////////////////////s |
-bool GrDrawState::willEffectReadDstColor() const { |
+bool GrDrawState::willEffectReadDstColor(GrColor color, GrColor coverage) const { |
if (!this->isColorWriteDisabled()) { |
- this->calcColorInvariantOutput(); |
+ this->calcColorInvariantOutput(color); |
if (fColorProcInfo.readsDst()) { |
return true; |
} |
} |
- this->calcCoverageInvariantOutput(); |
+ this->calcCoverageInvariantOutput(coverage); |
return fCoverageProcInfo.readsDst(); |
} |
@@ -396,7 +381,9 @@ GrDrawState::~GrDrawState() { |
//////////////////////////////////////////////////////////////////////////////// |
-GrDrawState::BlendOpt GrDrawState::getBlendOpt(bool forceCoverage, |
+GrDrawState::BlendOpt GrDrawState::getBlendOpt(GrColor color, |
+ GrColor coverage, |
+ bool forceCoverage, |
GrBlendCoeff* srcCoeff, |
GrBlendCoeff* dstCoeff) const { |
GrBlendCoeff bogusSrcCoeff, bogusDstCoeff; |
@@ -415,7 +402,7 @@ GrDrawState::BlendOpt GrDrawState::getBlendOpt(bool forceCoverage, |
*dstCoeff = kOne_GrBlendCoeff; |
} |
- bool srcAIsOne = this->srcAlphaWillBeOne(); |
+ bool srcAIsOne = this->srcAlphaWillBeOne(color, coverage); |
bool dstCoeffIsOne = kOne_GrBlendCoeff == *dstCoeff || |
(kSA_GrBlendCoeff == *dstCoeff && srcAIsOne); |
bool dstCoeffIsZero = kZero_GrBlendCoeff == *dstCoeff || |
@@ -433,7 +420,7 @@ GrDrawState::BlendOpt GrDrawState::getBlendOpt(bool forceCoverage, |
} |
} |
- bool hasCoverage = forceCoverage || !this->hasSolidCoverage(); |
+ bool hasCoverage = forceCoverage || !this->hasSolidCoverage(coverage); |
// if we don't have coverage we can check whether the dst |
// has to read at all. If not, we'll disable blending. |
@@ -487,21 +474,21 @@ GrDrawState::BlendOpt GrDrawState::getBlendOpt(bool forceCoverage, |
return kNone_BlendOpt; |
} |
-bool GrDrawState::srcAlphaWillBeOne() const { |
- this->calcColorInvariantOutput(); |
+bool GrDrawState::srcAlphaWillBeOne(GrColor color, GrColor coverage) const { |
+ this->calcColorInvariantOutput(color); |
if (this->isCoverageDrawing()) { |
- this->calcCoverageInvariantOutput(); |
+ this->calcCoverageInvariantOutput(coverage); |
return (fColorProcInfo.isOpaque() && fCoverageProcInfo.isOpaque()); |
} |
return fColorProcInfo.isOpaque(); |
} |
-bool GrDrawState::willBlendWithDst() const { |
- if (!this->hasSolidCoverage()) { |
+bool GrDrawState::willBlendWithDst(GrColor color, GrColor coverage) const { |
+ if (!this->hasSolidCoverage(coverage)) { |
return true; |
} |
- if (this->willEffectReadDstColor()) { |
+ if (this->willEffectReadDstColor(color, coverage)) { |
return true; |
} |
@@ -511,16 +498,15 @@ bool GrDrawState::willBlendWithDst() const { |
GrBlendCoeff dstCoeff = this->getDstBlendCoeff(); |
if (!(kZero_GrBlendCoeff == dstCoeff || |
- (kISA_GrBlendCoeff == dstCoeff && this->srcAlphaWillBeOne()))) { |
+ (kISA_GrBlendCoeff == dstCoeff && this->srcAlphaWillBeOne(color, coverage)))) { |
return true; |
} |
return false; |
} |
-void GrDrawState::calcColorInvariantOutput() const { |
- if (!fColorProcInfoValid) { |
- GrColor color; |
+void GrDrawState::calcColorInvariantOutput(GrColor color) const { |
+ if (!fColorProcInfoValid || color != fColorCache) { |
GrColorComponentFlags flags; |
if (this->hasColorVertexAttribute()) { |
if (fHints & kVertexColorsAreOpaque_Hint) { |
@@ -532,29 +518,28 @@ void GrDrawState::calcColorInvariantOutput() const { |
} |
} else { |
flags = kRGBA_GrColorComponentFlags; |
- color = this->getColor(); |
} |
fColorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColorStages(), |
color, flags, false); |
fColorProcInfoValid = true; |
+ fColorCache = color; |
} |
} |
-void GrDrawState::calcCoverageInvariantOutput() const { |
- if (!fCoverageProcInfoValid) { |
- GrColor color; |
+void GrDrawState::calcCoverageInvariantOutput(GrColor coverage) const { |
+ if (!fCoverageProcInfoValid || coverage != fCoverageCache) { |
GrColorComponentFlags flags; |
// Check if per-vertex or constant color may have partial alpha |
if (this->hasCoverageVertexAttribute()) { |
flags = static_cast<GrColorComponentFlags>(0); |
- color = 0; |
+ coverage = 0; |
} else { |
flags = kRGBA_GrColorComponentFlags; |
- color = this->getCoverageColor(); |
} |
fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), this->numCoverageStages(), |
- color, flags, true, fGeometryProcessor.get()); |
+ coverage, flags, true, fGeometryProcessor.get()); |
fCoverageProcInfoValid = true; |
+ fCoverageCache = coverage; |
} |
} |