Index: src/gpu/GrDrawState.cpp |
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp |
index b9d5cccff52b8020651eb7e5d056525d8c2f7ac6..a31d7b8d4b9585324a2ba7d43db235a5b1567e83 100644 |
--- a/src/gpu/GrDrawState.cpp |
+++ b/src/gpu/GrDrawState.cpp |
@@ -14,7 +14,7 @@ |
#include "GrXferProcessor.h" |
#include "effects/GrPorterDuffXferProcessor.h" |
-bool GrDrawState::isEqual(const GrDrawState& that) const { |
+bool GrDrawState::isEqual(const GrDrawState& that, bool explicitLocalCoords) const { |
if (this->getRenderTarget() != that.getRenderTarget() || |
this->fColorStages.count() != that.fColorStages.count() || |
this->fCoverageStages.count() != that.fCoverageStages.count() || |
@@ -25,17 +25,6 @@ bool GrDrawState::isEqual(const GrDrawState& that) const { |
return false; |
} |
- bool explicitLocalCoords = this->hasLocalCoordAttribute(); |
- if (this->hasGeometryProcessor()) { |
- if (!that.hasGeometryProcessor()) { |
- return false; |
- } else if (!this->getGeometryProcessor()->isEqual(*that.getGeometryProcessor())) { |
- return false; |
- } |
- } else if (that.hasGeometryProcessor()) { |
- return false; |
- } |
- |
if (!this->getXPFactory()->isEqual(*that.getXPFactory())) { |
return false; |
} |
@@ -77,7 +66,6 @@ GrDrawState& GrDrawState::operator=(const GrDrawState& that) { |
fFlagBits = that.fFlagBits; |
fStencilSettings = that.fStencilSettings; |
fDrawFace = that.fDrawFace; |
- fGeometryProcessor.reset(SkSafeRef(that.fGeometryProcessor.get())); |
fXPFactory.reset(SkRef(that.getXPFactory())); |
fColorStages = that.fColorStages; |
fCoverageStages = that.fCoverageStages; |
@@ -96,10 +84,9 @@ GrDrawState& GrDrawState::operator=(const GrDrawState& that) { |
} |
void GrDrawState::onReset(const SkMatrix* initialViewMatrix) { |
- SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages()); |
+ SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numFragmentStages()); |
fRenderTarget.reset(NULL); |
- fGeometryProcessor.reset(NULL); |
fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode)); |
fColorStages.reset(); |
fCoverageStages.reset(); |
@@ -138,9 +125,8 @@ bool GrDrawState::setIdentityViewMatrix() { |
} |
void GrDrawState::setFromPaint(const GrPaint& paint, const SkMatrix& vm, GrRenderTarget* rt) { |
- SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages()); |
+ SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numFragmentStages()); |
- fGeometryProcessor.reset(NULL); |
fColorStages.reset(); |
fCoverageStages.reset(); |
@@ -181,17 +167,17 @@ bool GrDrawState::canUseFracCoveragePrimProc(GrColor color, const GrDrawTargetCa |
return true; |
} |
- this->calcColorInvariantOutput(color); |
+ this->calcColorInvariantOutput(NULL, color); |
// The coverage isn't actually white, its unknown, but this will produce the same effect |
// TODO we want to cache the result of this call, but we can probably clean up the interface |
// so we don't have to pass in a seemingly known coverage |
- this->calcCoverageInvariantOutput(GrColor_WHITE); |
+ this->calcCoverageInvariantOutput(NULL, GrColor_WHITE); |
return fXPFactory->canApplyCoverage(fColorProcInfo, fCoverageProcInfo, |
this->isCoverageDrawing(), this->isColorWriteDisabled()); |
} |
-bool GrDrawState::hasSolidCoverage(GrColor coverage) const { |
+bool GrDrawState::hasSolidCoverage(const GrPrimitiveProcessor* pp, GrColor coverage) const { |
// If we're drawing coverage directly then coverage is effectively treated as color. |
if (this->isCoverageDrawing()) { |
return true; |
@@ -201,15 +187,17 @@ bool GrDrawState::hasSolidCoverage(GrColor coverage) const { |
return false; |
} |
- this->calcCoverageInvariantOutput(coverage); |
+ this->calcCoverageInvariantOutput(pp, coverage); |
return fCoverageProcInfo.isSolidWhite(); |
} |
//////////////////////////////////////////////////////////////////////////////s |
-bool GrDrawState::willEffectReadDstColor(GrColor color, GrColor coverage) const { |
- this->calcColorInvariantOutput(color); |
- this->calcCoverageInvariantOutput(coverage); |
+bool GrDrawState::willEffectReadDstColor(const GrPrimitiveProcessor* pp, |
+ GrColor color, |
+ GrColor coverage) const { |
+ this->calcColorInvariantOutput(pp, color); |
+ this->calcCoverageInvariantOutput(pp, coverage); |
// TODO: Remove need to create the XP here. |
// Also once all custom blends are turned into XPs we can remove the need |
// to check other stages since only xp's will be able to read dst |
@@ -229,15 +217,6 @@ bool GrDrawState::willEffectReadDstColor(GrColor color, GrColor coverage) const |
void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) { |
if (fDrawState) { |
- // See the big comment on the class definition about GPs. |
- if (SK_InvalidUniqueID == fOriginalGPID) { |
- fDrawState->fGeometryProcessor.reset(NULL); |
- } else { |
- SkASSERT(fDrawState->getGeometryProcessor()->getUniqueID() == |
- fOriginalGPID); |
- fOriginalGPID = SK_InvalidUniqueID; |
- } |
- |
int m = fDrawState->numColorStages() - fColorEffectCnt; |
SkASSERT(m >= 0); |
fDrawState->fColorStages.pop_back_n(m); |
@@ -253,10 +232,6 @@ void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) { |
} |
fDrawState = ds; |
if (NULL != ds) { |
- SkASSERT(SK_InvalidUniqueID == fOriginalGPID); |
- if (NULL != ds->getGeometryProcessor()) { |
- fOriginalGPID = ds->getGeometryProcessor()->getUniqueID(); |
- } |
fColorEffectCnt = ds->numColorStages(); |
fCoverageEffectCnt = ds->numCoverageStages(); |
SkDEBUGCODE(++ds->fBlockEffectRemovalCnt;) |
@@ -366,56 +341,44 @@ GrDrawState::~GrDrawState() { |
//////////////////////////////////////////////////////////////////////////////// |
-bool GrDrawState::srcAlphaWillBeOne(GrColor color, GrColor coverage) const { |
- this->calcColorInvariantOutput(color); |
- if (this->isCoverageDrawing()) { |
- this->calcCoverageInvariantOutput(coverage); |
- return (fColorProcInfo.isOpaque() && fCoverageProcInfo.isOpaque()); |
- } |
- return fColorProcInfo.isOpaque(); |
-} |
- |
-bool GrDrawState::willBlendWithDst(GrColor color, GrColor coverage) const { |
- this->calcColorInvariantOutput(color); |
- this->calcCoverageInvariantOutput(coverage); |
+bool GrDrawState::willBlendWithDst(const GrPrimitiveProcessor* pp, |
+ GrColor color, |
+ GrColor coverage) const { |
+ this->calcColorInvariantOutput(pp, color); |
+ this->calcCoverageInvariantOutput(pp, coverage); |
return fXPFactory->willBlendWithDst(fColorProcInfo, fCoverageProcInfo, |
this->isCoverageDrawing(), this->isColorWriteDisabled()); |
} |
-void GrDrawState::calcColorInvariantOutput(GrColor color) const { |
- if (!fColorProcInfoValid || color != fColorCache) { |
- GrColorComponentFlags flags; |
- if (this->hasColorVertexAttribute()) { |
- if (fHints & kVertexColorsAreOpaque_Hint) { |
- flags = kA_GrColorComponentFlag; |
- color = 0xFF << GrColor_SHIFT_A; |
- } else { |
- flags = static_cast<GrColorComponentFlags>(0); |
- color = 0; |
- } |
+void GrDrawState::calcColorInvariantOutput(const GrPrimitiveProcessor* pp, GrColor color) const { |
+ if (!fColorProcInfoValid || color != fColorCache || fColorPrimProc != pp) { |
+ if (pp) { |
+ fColorProcInfo.calcColorWithPrimProc(pp, fColorStages.begin(), this->numColorStages()); |
} else { |
- flags = kRGBA_GrColorComponentFlags; |
+ GrColorComponentFlags flags = kRGBA_GrColorComponentFlags; |
+ fColorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColorStages(), |
+ color, flags, false); |
} |
- fColorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColorStages(), |
- color, flags, false); |
fColorProcInfoValid = true; |
fColorCache = color; |
+ fColorPrimProc = pp; |
} |
} |
-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); |
- coverage = 0; |
+void GrDrawState::calcCoverageInvariantOutput(const GrPrimitiveProcessor* pp, |
+ GrColor coverage) const { |
+ if (!fCoverageProcInfoValid || coverage != fCoverageCache || fCoveragePrimProc != pp) { |
+ if (pp) { |
+ fCoverageProcInfo.calcCoverageWithPrimProc(pp, fCoverageStages.begin(), |
+ this->numCoverageStages()); |
} else { |
- flags = kRGBA_GrColorComponentFlags; |
+ GrColorComponentFlags flags = kRGBA_GrColorComponentFlags; |
+ fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), |
+ this->numCoverageStages(), coverage, flags, |
+ true); |
} |
- fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), this->numCoverageStages(), |
- coverage, flags, true, fGeometryProcessor.get()); |
fCoverageProcInfoValid = true; |
fCoverageCache = coverage; |
+ fCoveragePrimProc = pp; |
} |
} |