aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2015-01-20 06:34:51 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-01-20 06:34:51 -0800
commit71e236c03e65ff6b48a3d0eb091f814dd3e3a928 (patch)
tree3b3ca3eb421a45b6aaf151c2e227cc1de4655a38 /src/gpu
parentb2b416d3847c138a0a13876fdc1cdeae607b7e31 (diff)
Remove willReadDst from GrFragmentProcessor.
Since only XP's can read dst now, there is no reason to have this query on GrFP. This also triggered a chain reaction of cleaning up/removing unnecessary code elsewhere. BUG=skia: Review URL: https://codereview.chromium.org/851143003
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrDrawState.cpp7
-rw-r--r--src/gpu/GrDrawState.h6
-rw-r--r--src/gpu/GrDrawTarget.cpp13
-rw-r--r--src/gpu/GrDrawTarget.h1
-rw-r--r--src/gpu/GrOptDrawState.cpp11
-rw-r--r--src/gpu/GrProcOptInfo.cpp6
-rw-r--r--src/gpu/GrProcOptInfo.h7
-rw-r--r--src/gpu/effects/GrCoverageSetOpXP.cpp11
-rw-r--r--src/gpu/effects/GrCoverageSetOpXP.h3
-rw-r--r--src/gpu/effects/GrCustomXfermodePriv.h5
-rw-r--r--src/gpu/effects/GrDisableColorXP.h5
-rw-r--r--src/gpu/effects/GrPorterDuffXferProcessor.cpp33
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.cpp5
13 files changed, 20 insertions, 93 deletions
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp
index 36042e19ab..4ec39e7005 100644
--- a/src/gpu/GrDrawState.cpp
+++ b/src/gpu/GrDrawState.cpp
@@ -147,11 +147,8 @@ bool GrDrawState::canUseFracCoveragePrimProc(GrColor color, const GrDrawTargetCa
//////////////////////////////////////////////////////////////////////////////s
-bool GrDrawState::willEffectReadDstColor(const GrPrimitiveProcessor* pp) const {
- this->calcColorInvariantOutput(pp);
- this->calcCoverageInvariantOutput(pp);
-
- return fXPFactory->willReadDst(fColorProcInfo, fCoverageProcInfo);
+bool GrDrawState::willEffectReadDstColor() const {
+ return fXPFactory->willReadDst();
}
void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) {
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index ce29e6ca68..c02429f965 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -108,10 +108,10 @@ public:
const GrFragmentStage& getCoverageStage(int idx) const { return fCoverageStages[idx]; }
/**
- * Checks whether any of the effects will read the dst pixel color.
- * TODO remove when we have an XP
+ * Checks whether the xp will read the dst pixel color.
+ * TODO: remove when we have dstCpy contained inside of GrXP
*/
- bool willEffectReadDstColor(const GrPrimitiveProcessor*) const;
+ bool willEffectReadDstColor() const;
/**
* The xfer processor factory.
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 5faf00f843..f14515462a 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -383,10 +383,9 @@ bool GrDrawTarget::checkDraw(const GrDrawState& drawState,
}
bool GrDrawTarget::setupDstReadIfNecessary(GrDrawState* ds,
- const GrPrimitiveProcessor* primProc,
GrDeviceCoordTexture* dstCopy,
const SkRect* drawBounds) {
- if (this->caps()->dstReadInShaderSupport() || !ds->willEffectReadDstColor(primProc)) {
+ if (this->caps()->dstReadInShaderSupport() || !ds->willEffectReadDstColor()) {
return true;
}
SkIRect copyRect;
@@ -470,7 +469,7 @@ void GrDrawTarget::drawIndexed(GrDrawState* ds,
// TODO: We should continue with incorrect blending.
GrDeviceCoordTexture dstCopy;
- if (!this->setupDstReadIfNecessary(ds, gp, &dstCopy, devBounds)) {
+ if (!this->setupDstReadIfNecessary(ds, &dstCopy, devBounds)) {
return;
}
this->setDrawBuffers(&info, gp->getVertexStride());
@@ -513,7 +512,7 @@ void GrDrawTarget::drawNonIndexed(GrDrawState* ds,
// TODO: We should continue with incorrect blending.
GrDeviceCoordTexture dstCopy;
- if (!this->setupDstReadIfNecessary(ds, gp, &dstCopy, devBounds)) {
+ if (!this->setupDstReadIfNecessary(ds, &dstCopy, devBounds)) {
return;
}
@@ -611,7 +610,7 @@ void GrDrawTarget::drawPath(GrDrawState* ds,
&stencilSettings);
GrDeviceCoordTexture dstCopy;
- if (!this->setupDstReadIfNecessary(ds, pathProc, &dstCopy, &devBounds)) {
+ if (!this->setupDstReadIfNecessary(ds, &dstCopy, &devBounds)) {
return;
}
@@ -655,7 +654,7 @@ void GrDrawTarget::drawPaths(GrDrawState* ds,
// point, because any context that supports NV_path_rendering will also
// support NV_blend_equation_advanced.
GrDeviceCoordTexture dstCopy;
- if (!this->setupDstReadIfNecessary(ds, pathProc, &dstCopy, NULL)) {
+ if (!this->setupDstReadIfNecessary(ds, &dstCopy, NULL)) {
return;
}
@@ -768,7 +767,7 @@ void GrDrawTarget::drawIndexedInstances(GrDrawState* ds,
// TODO: We should continue with incorrect blending.
GrDeviceCoordTexture dstCopy;
- if (!this->setupDstReadIfNecessary(ds, gp, &dstCopy, devBounds)) {
+ if (!this->setupDstReadIfNecessary(ds, &dstCopy, devBounds)) {
return;
}
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index 0e211ba85d..6628e37228 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -661,7 +661,6 @@ protected:
// but couldn't be made. Otherwise, returns true. This method needs to be protected because it
// needs to be accessed by GLPrograms to setup a correct drawstate
bool setupDstReadIfNecessary(GrDrawState*,
- const GrPrimitiveProcessor*,
GrDeviceCoordTexture* dstCopy,
const SkRect* drawBounds);
diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp
index 742ffade12..bc1ce7dc93 100644
--- a/src/gpu/GrOptDrawState.cpp
+++ b/src/gpu/GrOptDrawState.cpp
@@ -89,6 +89,8 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
this->adjustProgramFromOptimizations(drawState, optFlags, colorPOI, coveragePOI,
&firstColorStageIdx, &firstCoverageStageIdx);
+ fDescInfo.fReadsDst = fXferProcessor->willReadDstColor();
+
bool usesLocalCoords = false;
// Copy Stages from DS to ODS
@@ -124,31 +126,22 @@ void GrOptDrawState::adjustProgramFromOptimizations(const GrDrawState& ds,
const GrProcOptInfo& coveragePOI,
int* firstColorStageIdx,
int* firstCoverageStageIdx) {
- fDescInfo.fReadsDst = false;
fDescInfo.fReadsFragPosition = false;
if ((flags & GrXferProcessor::kIgnoreColor_OptFlag) ||
(flags & GrXferProcessor::kOverrideColor_OptFlag)) {
*firstColorStageIdx = ds.numColorStages();
} else {
- fDescInfo.fReadsDst = colorPOI.readsDst();
fDescInfo.fReadsFragPosition = colorPOI.readsFragPosition();
}
if (flags & GrXferProcessor::kIgnoreCoverage_OptFlag) {
*firstCoverageStageIdx = ds.numCoverageStages();
} else {
- if (coveragePOI.readsDst()) {
- fDescInfo.fReadsDst = true;
- }
if (coveragePOI.readsFragPosition()) {
fDescInfo.fReadsFragPosition = true;
}
}
-
- if (fXferProcessor->willReadDstColor()) {
- fDescInfo.fReadsDst = true;
- }
}
void GrOptDrawState::finalize(GrGpu* gpu) {
diff --git a/src/gpu/GrProcOptInfo.cpp b/src/gpu/GrProcOptInfo.cpp
index 274c5305de..a350ef783d 100644
--- a/src/gpu/GrProcOptInfo.cpp
+++ b/src/gpu/GrProcOptInfo.cpp
@@ -48,7 +48,6 @@ void GrProcOptInfo::internalCalc(const GrFragmentStage* stages,
fFirstEffectStageIndex = 0;
fInputColorIsUsed = true;
fInputColor = fInOut.color();
- fReadsDst = false;
fReadsFragPosition = initWillReadFragmentPosition;
for (int i = 0; i < stageCount; ++i) {
@@ -60,12 +59,8 @@ void GrProcOptInfo::internalCalc(const GrFragmentStage* stages,
fFirstEffectStageIndex = i;
fInputColorIsUsed = false;
// Reset these since we don't care if previous stages read these values
- fReadsDst = false;
fReadsFragPosition = initWillReadFragmentPosition;
}
- if (processor->willReadDstColor()) {
- fReadsDst = true;
- }
if (processor->willReadFragmentPosition()) {
fReadsFragPosition = true;
}
@@ -77,7 +72,6 @@ void GrProcOptInfo::internalCalc(const GrFragmentStage* stages,
// zero stages that don't multiply the inputColor.
fInOut.resetNonMulStageFound();
// Reset these since we don't care if previous stages read these values
- fReadsDst = false;
fReadsFragPosition = initWillReadFragmentPosition;
}
}
diff --git a/src/gpu/GrProcOptInfo.h b/src/gpu/GrProcOptInfo.h
index 43d6c558f1..75d88c64e2 100644
--- a/src/gpu/GrProcOptInfo.h
+++ b/src/gpu/GrProcOptInfo.h
@@ -28,7 +28,6 @@ public:
, fFirstEffectStageIndex(0)
, fInputColorIsUsed(true)
, fInputColor(0)
- , fReadsDst(false)
, fReadsFragPosition(false) {}
void calcWithInitialValues(const GrFragmentStage*, int stageCount, GrColor startColor,
@@ -75,11 +74,6 @@ public:
GrColor inputColorToEffectiveStage() const { return fInputColor; }
/**
- * Returns true if any of the stages preserved by GrProcOptInfo read the dst color.
- */
- bool readsDst() const { return fReadsDst; }
-
- /**
* Returns true if any of the stages preserved by GrProcOptInfo read the frag position.
*/
bool readsFragPosition() const { return fReadsFragPosition; }
@@ -91,7 +85,6 @@ private:
int fFirstEffectStageIndex;
bool fInputColorIsUsed;
GrColor fInputColor;
- bool fReadsDst;
bool fReadsFragPosition;
};
diff --git a/src/gpu/effects/GrCoverageSetOpXP.cpp b/src/gpu/effects/GrCoverageSetOpXP.cpp
index bb87616e74..fe286f6bf5 100644
--- a/src/gpu/effects/GrCoverageSetOpXP.cpp
+++ b/src/gpu/effects/GrCoverageSetOpXP.cpp
@@ -195,22 +195,13 @@ void GrCoverageSetOpXPFactory::getInvariantOutput(const GrProcOptInfo& colorPOI,
output->fBlendedColorFlags = 0;
}
- if (coveragePOI.readsDst()) {
- output->fWillBlendWithDst = true;
- } else {
- output->fWillBlendWithDst = false;
- }
+ output->fWillBlendWithDst = false;
} else {
output->fBlendedColorFlags = 0;
output->fWillBlendWithDst = true;
}
}
-bool GrCoverageSetOpXPFactory::willReadDst(const GrProcOptInfo& colorPOI,
- const GrProcOptInfo& coveragePOI) const {
- return coveragePOI.readsDst();
-}
-
GR_DEFINE_XP_FACTORY_TEST(GrCoverageSetOpXPFactory);
GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(SkRandom* random,
diff --git a/src/gpu/effects/GrCoverageSetOpXP.h b/src/gpu/effects/GrCoverageSetOpXP.h
index 289b5cf307..a144f975b7 100644
--- a/src/gpu/effects/GrCoverageSetOpXP.h
+++ b/src/gpu/effects/GrCoverageSetOpXP.h
@@ -83,8 +83,7 @@ public:
void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo& coveragePOI,
GrXPFactory::InvariantOutput*) const SK_OVERRIDE;
- bool willReadDst(const GrProcOptInfo& colorPOI,
- const GrProcOptInfo& coveragePOI) const SK_OVERRIDE;
+ bool willReadDst() const SK_OVERRIDE { return false; }
private:
GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage);
diff --git a/src/gpu/effects/GrCustomXfermodePriv.h b/src/gpu/effects/GrCustomXfermodePriv.h
index 48ad7842f5..45a9d3005d 100644
--- a/src/gpu/effects/GrCustomXfermodePriv.h
+++ b/src/gpu/effects/GrCustomXfermodePriv.h
@@ -126,10 +126,7 @@ public:
void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo& coveragePOI,
GrXPFactory::InvariantOutput*) const SK_OVERRIDE;
- bool willReadDst(const GrProcOptInfo& colorPOI,
- const GrProcOptInfo& coveragePOI) const SK_OVERRIDE {
- return true;
- }
+ bool willReadDst() const SK_OVERRIDE { return true; }
private:
bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE {
diff --git a/src/gpu/effects/GrDisableColorXP.h b/src/gpu/effects/GrDisableColorXP.h
index b0de66bf43..d62c3201dd 100644
--- a/src/gpu/effects/GrDisableColorXP.h
+++ b/src/gpu/effects/GrDisableColorXP.h
@@ -81,10 +81,7 @@ public:
output->fWillBlendWithDst = 0;
}
- bool willReadDst(const GrProcOptInfo& colorPOI,
- const GrProcOptInfo& coveragePOI) const SK_OVERRIDE {
- return false;
- }
+ bool willReadDst() const SK_OVERRIDE { return false; }
private:
GrDisableColorXPFactory();
diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
index aecf685e62..5038aa333f 100644
--- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp
+++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
@@ -72,14 +72,8 @@ public:
fsBuilder->codeAppendf("%s = %s;", args.fOutputPrimary, args.fInputCoverage);
break;
case GrPorterDuffXferProcessor::kModulate_PrimaryOutputType:
- case GrPorterDuffXferProcessor::kCombineWithDst_PrimaryOutputType:
fsBuilder->codeAppendf("%s = %s * %s;", args.fOutputPrimary, args.fInputColor,
args.fInputCoverage);
- if (GrPorterDuffXferProcessor::kCombineWithDst_PrimaryOutputType ==
- xp.primaryOutputType()){
- fsBuilder->codeAppendf("%s += (vec4(1.0) - %s) * %s;", args.fOutputPrimary,
- args.fInputCoverage, fsBuilder->dstColor());
- }
break;
default:
SkFAIL("Unexpected Primary Output");
@@ -144,14 +138,13 @@ GrPorterDuffXferProcessor::getOptimizations(const GrProcOptInfo& colorPOI,
coveragePOI,
doesStencilWrite);
}
- this->calcOutputTypes(optFlags, caps, coveragePOI.isSolidWhite(),
- colorPOI.readsDst() || coveragePOI.readsDst());
+ this->calcOutputTypes(optFlags, caps, coveragePOI.isSolidWhite());
return optFlags;
}
void GrPorterDuffXferProcessor::calcOutputTypes(GrXferProcessor::OptFlags optFlags,
const GrDrawTargetCaps& caps,
- bool hasSolidCoverage, bool readsDst) {
+ bool hasSolidCoverage) {
if (optFlags & kIgnoreColor_OptFlag) {
if (optFlags & kIgnoreCoverage_OptFlag) {
fPrimaryOutputType = kNone_PrimaryOutputType;
@@ -184,10 +177,6 @@ void GrPorterDuffXferProcessor::calcOutputTypes(GrXferProcessor::OptFlags optFla
fSecondaryOutputType = kCoverageISC_SecondaryOutputType;
fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff;
}
- } else if (readsDst &&
- kOne_GrBlendCoeff == fSrcBlend &&
- kZero_GrBlendCoeff == fDstBlend) {
- fPrimaryOutputType = kCombineWithDst_PrimaryOutputType;
}
}
}
@@ -419,13 +408,6 @@ bool GrPorterDuffXPFactory::canApplyCoverage(const GrProcOptInfo& colorPOI,
return true;
}
- // TODO: once all SkXferEffects are XP's then we will never reads dst here since only XP's
- // will readDst and PD XP's don't read dst.
- if ((colorPOI.readsDst() || coveragePOI.readsDst()) &&
- kOne_GrBlendCoeff == fSrcCoeff && kZero_GrBlendCoeff == fDstCoeff) {
- return true;
- }
-
return false;
}
@@ -499,20 +481,9 @@ void GrPorterDuffXPFactory::getInvariantOutput(const GrProcOptInfo& colorPOI,
break;
}
- // TODO: once all SkXferEffects are XP's then we will never reads dst here since only XP's
- // will readDst and PD XP's don't read dst.
- if (colorPOI.readsDst() || coveragePOI.readsDst()) {
- output->fWillBlendWithDst = true;
- return;
- }
output->fWillBlendWithDst = false;
}
-bool GrPorterDuffXPFactory::willReadDst(const GrProcOptInfo& colorPOI,
- const GrProcOptInfo& coveragePOI) const {
- return colorPOI.readsDst() || coveragePOI.readsDst();
-}
-
GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory);
GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random,
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 8ec0d2ddbe..c88efac9f0 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -359,14 +359,11 @@ void GrGLProgramBuilder::verify(const GrPrimitiveProcessor& gp) {
}
void GrGLProgramBuilder::verify(const GrXferProcessor& xp) {
- // TODO: Once will readDst is only xp enable this assert and remove it from the
- // FragmentProcessor verify()
- //SkASSERT(fFS.hasReadDstColor() == xp.willReadDstColor());
+ SkASSERT(fFS.hasReadDstColor() == xp.willReadDstColor());
}
void GrGLProgramBuilder::verify(const GrFragmentProcessor& fp) {
SkASSERT(fFS.hasReadFragmentPosition() == fp.willReadFragmentPosition());
- SkASSERT(fFS.hasReadDstColor() == fp.willReadDstColor());
}
template <class Proc>