Determine whether we can tweakAlphaForCoverage during Pipeline/XP creation.

BUG=skia:

Review URL: https://codereview.chromium.org/927623002
This commit is contained in:
egdaniel 2015-02-13 12:11:00 -08:00 committed by Commit bot
parent 0ff748ace6
commit f7c2d55872
6 changed files with 30 additions and 2 deletions

View File

@ -210,6 +210,7 @@ private:
bool willUseInputColor() const { return fWillUseInputColor; }
void resetWillUseInputColor() { fWillUseInputColor = true; }
bool allStagesMulInput() const { return !fNonMulStageFound; }
void resetNonMulStageFound() { fNonMulStageFound = false; }
bool isLCDCoverage() const { return fIsLCDCoverage; }

View File

@ -73,6 +73,10 @@ public:
* Set CoverageDrawing_StateBit
*/
kSetCoverageDrawing_OptFlag = 0x10,
/**
* Can tweak alpha for coverage. Currently this flag should only be used by a batch
*/
kCanTweakAlphaForCoverage_OptFlag = 0x20,
};
GR_DECL_BITFIELD_OPS_FRIENDS(OptFlags);

View File

@ -102,6 +102,8 @@ GrPipeline::GrPipeline(const GrPipelineBuilder& pipelineBuilder,
fInitBT.fOverrideColor = fInitBT.fColorIgnored ? GrColor_ILLEGAL : overrideColor;
fInitBT.fCoverageIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreCoverage_OptFlag);
fInitBT.fUsesLocalCoords = usesLocalCoords;
fInitBT.fCanTweakAlphaForCoverage =
SkToBool(optFlags & GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag);
}
void GrPipeline::adjustProgramFromOptimizations(const GrPipelineBuilder& pipelineBuilder,

View File

@ -83,6 +83,7 @@ struct GrPipelineInfo {
bool fCoverageIgnored;
GrColor fOverrideColor;
bool fUsesLocalCoords;
bool fCanTweakAlphaForCoverage;
};
/*

View File

@ -45,6 +45,7 @@ public:
bool isSolidWhite() const { return fInOut.isSolidWhite(); }
bool isOpaque() const { return fInOut.isOpaque(); }
bool isSingleComponent() const { return fInOut.isSingleComponent(); }
bool allStagesMultiplyInput() const { return fInOut.allStagesMulInput(); }
// TODO: Once texture pixel configs quaries are updated, we no longer need this function.
// For now this function will correctly tell us if we are using LCD text or not and should only

View File

@ -330,7 +330,13 @@ PorterDuffXferProcessor::internalGetOptimizations(const GrProcOptInfo& colorPOI,
// check whether coverage can be safely rolled into alpha
// of if we can skip color computation and just emit coverage
if (can_tweak_alpha_for_coverage(fDstBlend)) {
return GrXferProcessor::kSetCoverageDrawing_OptFlag;
if (colorPOI.allStagesMultiplyInput()) {
return GrXferProcessor::kSetCoverageDrawing_OptFlag |
GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag;
} else {
return GrXferProcessor::kSetCoverageDrawing_OptFlag;
}
}
if (dstCoeffIsZero) {
if (kZero_GrBlendCoeff == fSrcBlend) {
@ -346,12 +352,25 @@ PorterDuffXferProcessor::internalGetOptimizations(const GrProcOptInfo& colorPOI,
// If Sa is 1 then we can replace Sa with c
// and set dst coeff to 1-Sa.
fDstBlend = kISA_GrBlendCoeff;
return GrXferProcessor::kSetCoverageDrawing_OptFlag;
if (colorPOI.allStagesMultiplyInput()) {
return GrXferProcessor::kSetCoverageDrawing_OptFlag |
GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag;
} else {
return GrXferProcessor::kSetCoverageDrawing_OptFlag;
}
}
} else if (dstCoeffIsOne) {
// the dst coeff is effectively one so blend works out to:
// cS + (c)(1)D + (1-c)D = cS + D.
fDstBlend = kOne_GrBlendCoeff;
if (colorPOI.allStagesMultiplyInput()) {
return GrXferProcessor::kSetCoverageDrawing_OptFlag |
GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag;
} else {
return GrXferProcessor::kSetCoverageDrawing_OptFlag;
}
return GrXferProcessor::kSetCoverageDrawing_OptFlag;
}
}