Remove coverage multiplies when it is known to be fully opaque.
BUG=skia: Review URL: https://codereview.chromium.org/1132883002
This commit is contained in:
parent
f36cca8a61
commit
7dfc27ca42
@ -49,18 +49,17 @@ public:
|
||||
|
||||
bool hasVertexCoverage = SkToBool(fInCoverage) && !init.fCoverageIgnored;
|
||||
bool covIsSolidWhite = !hasVertexCoverage && 0xff == this->coverage();
|
||||
if (covIsSolidWhite) {
|
||||
if (init.fCoverageIgnored) {
|
||||
local->fInputCoverageType = kIgnored_GrGPInput;
|
||||
} else if (covIsSolidWhite) {
|
||||
local->fInputCoverageType = kAllOnes_GrGPInput;
|
||||
} else if (!hasVertexCoverage) {
|
||||
local->fInputCoverageType = kUniform_GrGPInput;
|
||||
local->fCoverage = this->coverage();
|
||||
} else if (hasVertexCoverage) {
|
||||
SkASSERT(fInCoverage);
|
||||
local->fInputCoverageType = kAttribute_GrGPInput;
|
||||
} else {
|
||||
local->fInputCoverageType = kIgnored_GrGPInput;
|
||||
local->fInputCoverageType = kUniform_GrGPInput;
|
||||
local->fCoverage = this->coverage();
|
||||
}
|
||||
|
||||
local->fUsesLocalCoords = init.fUsesLocalCoords;
|
||||
}
|
||||
|
||||
|
@ -406,7 +406,8 @@ PorterDuffXferProcessor::internalGetOptimizations(const GrProcOptInfo& colorPOI,
|
||||
// if there is no coverage and coeffs are (1,0) then we
|
||||
// won't need to read the dst at all, it gets replaced by src
|
||||
fDstBlend = kZero_GrBlendCoeff;
|
||||
return GrXferProcessor::kNone_Opt;
|
||||
return GrXferProcessor::kNone_Opt |
|
||||
GrXferProcessor::kIgnoreCoverage_OptFlag;
|
||||
} else if (kZero_GrBlendCoeff == fSrcBlend) {
|
||||
// if the op is "clear" then we don't need to emit a color
|
||||
// or blend, just write transparent black into the dst.
|
||||
@ -416,54 +417,55 @@ PorterDuffXferProcessor::internalGetOptimizations(const GrProcOptInfo& colorPOI,
|
||||
GrXferProcessor::kIgnoreCoverage_OptFlag;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 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)) {
|
||||
if (colorPOI.allStagesMultiplyInput()) {
|
||||
return GrXferProcessor::kSetCoverageDrawing_OptFlag |
|
||||
GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag;
|
||||
} else {
|
||||
return GrXferProcessor::kSetCoverageDrawing_OptFlag;
|
||||
return GrXferProcessor::kIgnoreCoverage_OptFlag;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (dstCoeffIsZero) {
|
||||
if (kZero_GrBlendCoeff == fSrcBlend) {
|
||||
// the source color is not included in the blend
|
||||
// the dst coeff is effectively zero so blend works out to:
|
||||
// (c)(0)D + (1-c)D = (1-c)D.
|
||||
fDstBlend = kISA_GrBlendCoeff;
|
||||
return GrXferProcessor::kIgnoreColor_OptFlag |
|
||||
GrXferProcessor::kSetCoverageDrawing_OptFlag;
|
||||
} else if (srcAIsOne) {
|
||||
// the dst coeff is effectively zero so blend works out to:
|
||||
// cS + (c)(0)D + (1-c)D = cS + (1-c)D.
|
||||
// If Sa is 1 then we can replace Sa with c
|
||||
// and set dst coeff to 1-Sa.
|
||||
fDstBlend = kISA_GrBlendCoeff;
|
||||
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;
|
||||
|
||||
}
|
||||
// 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)) {
|
||||
if (colorPOI.allStagesMultiplyInput()) {
|
||||
return GrXferProcessor::kSetCoverageDrawing_OptFlag |
|
||||
GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag;
|
||||
} else {
|
||||
return GrXferProcessor::kSetCoverageDrawing_OptFlag;
|
||||
|
||||
}
|
||||
}
|
||||
if (dstCoeffIsZero) {
|
||||
if (kZero_GrBlendCoeff == fSrcBlend) {
|
||||
// the source color is not included in the blend
|
||||
// the dst coeff is effectively zero so blend works out to:
|
||||
// (c)(0)D + (1-c)D = (1-c)D.
|
||||
fDstBlend = kISA_GrBlendCoeff;
|
||||
return GrXferProcessor::kIgnoreColor_OptFlag |
|
||||
GrXferProcessor::kSetCoverageDrawing_OptFlag;
|
||||
} else if (srcAIsOne) {
|
||||
// the dst coeff is effectively zero so blend works out to:
|
||||
// cS + (c)(0)D + (1-c)D = cS + (1-c)D.
|
||||
// If Sa is 1 then we can replace Sa with c
|
||||
// and set dst coeff to 1-Sa.
|
||||
fDstBlend = kISA_GrBlendCoeff;
|
||||
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;
|
||||
}
|
||||
|
||||
return GrXferProcessor::kNone_Opt;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user