Check that coverage FPs are compatible with alpha as coverage
Change-Id: Ic3b6a02248d571e82f6729827c199d358fb75114
Reviewed-on: https://skia-review.googlesource.com/8508
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp
index 0248beb..838dff8 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -253,8 +253,12 @@
return GrConstColorProcessor::Make(GrColor4f::OpaqueWhite(),
GrConstColorProcessor::kModulateRGBA_InputMode);
}
+ // This could use kIgnore instead of kModulateRGBA but it would trigger a debug print
+ // about a coverage processor not being compatible with the alpha-as-coverage optimization.
+ // We don't really care about this unlikely case so we just use kModulateRGBA to suppress
+ // the print.
return GrConstColorProcessor::Make(GrColor4f::TransparentBlack(),
- GrConstColorProcessor::kIgnore_InputMode);
+ GrConstColorProcessor::kModulateRGBA_InputMode);
}
SkVector t;
diff --git a/src/gpu/effects/GrCustomXfermode.cpp b/src/gpu/effects/GrCustomXfermode.cpp
index d733069..36936f8 100644
--- a/src/gpu/effects/GrCustomXfermode.cpp
+++ b/src/gpu/effects/GrCustomXfermode.cpp
@@ -300,7 +300,8 @@
*/
OptFlags flags = kNone_OptFlags;
- if (analysis.fColorPOI.allProcessorsCompatibleWithCoverageAsAlpha()) {
+ if (analysis.fColorPOI.allProcessorsCompatibleWithCoverageAsAlpha() &&
+ analysis.fCoveragePOI.allProcessorsCompatibleWithCoverageAsAlpha()) {
flags |= kCanTweakAlphaForCoverage_OptFlag;
}
return flags;
diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
index ead4ed6..6b7d0ba 100644
--- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp
+++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
@@ -466,7 +466,8 @@
optFlags |= GrXferProcessor::kIgnoreColor_OptFlag;
}
if (analysis.fColorPOI.allProcessorsCompatibleWithCoverageAsAlpha() &&
- fBlendFormula.canTweakAlphaForCoverage() && !analysis.fCoveragePOI.isLCDCoverage()) {
+ analysis.fCoveragePOI.allProcessorsCompatibleWithCoverageAsAlpha() &&
+ fBlendFormula.canTweakAlphaForCoverage()) {
optFlags |= GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag;
}
}