Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1415)

Unified Diff: src/gpu/effects/GrPorterDuffXferProcessor.cpp

Issue 1132883002: Remove coverage multiplies when it is known to be fully opaque. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrDefaultGeoProcFactory.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrPorterDuffXferProcessor.cpp
diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
index 506383a29ea9ce969ab103dd0d5333d4f78e8037..73d58245c00766ee117c04dd3c97d13cfaa078ab 100644
--- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp
+++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
@@ -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,53 +417,54 @@ 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;
+ }
+
+ // 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 (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;
+ 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;
« no previous file with comments | « src/gpu/GrDefaultGeoProcFactory.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698