aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-02-15 14:12:26 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-15 20:50:31 +0000
commiteb62829a83a0a4f4fdd1230a3c08140e38052602 (patch)
tree292dc0ca14c63b0e10b7ced33b204c69abc1ce31 /src
parent63c67461ed07b5fca35182ac62657b2cb16afbb4 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/effects/SkRRectsGaussianEdgeMaskFilter.cpp5
-rw-r--r--src/gpu/GrProcOptInfo.h2
-rw-r--r--src/gpu/GrRenderTargetOpList.cpp8
-rw-r--r--src/gpu/effects/GrConvexPolyEffect.cpp6
-rw-r--r--src/gpu/effects/GrCustomXfermode.cpp3
-rw-r--r--src/gpu/effects/GrPorterDuffXferProcessor.cpp3
6 files changed, 23 insertions, 4 deletions
diff --git a/src/effects/SkRRectsGaussianEdgeMaskFilter.cpp b/src/effects/SkRRectsGaussianEdgeMaskFilter.cpp
index 7635759ca2..b3967ecabb 100644
--- a/src/effects/SkRRectsGaussianEdgeMaskFilter.cpp
+++ b/src/effects/SkRRectsGaussianEdgeMaskFilter.cpp
@@ -206,7 +206,10 @@ public:
};
RRectsGaussianEdgeFP(const SkRRect& first, const SkRRect& second, SkScalar radius)
- : INHERITED(kNone_OptimizationFlags), fFirst(first), fSecond(second), fRadius(radius) {
+ : INHERITED(kCompatibleWithCoverageAsAlpha_OptimizationFlag)
+ , fFirst(first)
+ , fSecond(second)
+ , fRadius(radius) {
this->initClassID<RRectsGaussianEdgeFP>();
fFirstMode = ComputeMode(fFirst);
diff --git a/src/gpu/GrProcOptInfo.h b/src/gpu/GrProcOptInfo.h
index 1a8578980d..ac3cb36966 100644
--- a/src/gpu/GrProcOptInfo.h
+++ b/src/gpu/GrProcOptInfo.h
@@ -26,6 +26,7 @@ public:
GrProcOptInfo(const GrPipelineInput& input) : GrProcOptInfo() {
fIsLCDCoverage = input.isLCDCoverage();
+ fAllProcessorsCompatibleWithCoverageAsAlpha = !input.isLCDCoverage();
fIsOpaque = input.isOpaque();
GrColor color;
if (input.isConstant(&color)) {
@@ -37,6 +38,7 @@ public:
void resetToLCDCoverage() {
*this = GrProcOptInfo();
fIsLCDCoverage = true;
+ fAllProcessorsCompatibleWithCoverageAsAlpha = false;
}
void reset(const GrPipelineInput& input) { *this = GrProcOptInfo(input); }
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index 69ba279434..b7dd37a922 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -315,6 +315,14 @@ void GrRenderTargetOpList::addDrawOp(const GrPipelineBuilder& pipelineBuilder,
if (const GrFragmentProcessor* clipFP = appliedClip.clipCoverageFragmentProcessor()) {
args.fAnalysis.fCoveragePOI.analyzeProcessors(&clipFP, 1);
}
+#ifdef SK_DEBUG
+ // Other than tests that exercise atypical behavior we expect all coverage FPs to be compatible
+ // with the coverage-as-alpha optimization.
+ if (!args.fAnalysis.fCoveragePOI.allProcessorsCompatibleWithCoverageAsAlpha() &&
+ !args.fAnalysis.fCoveragePOI.isLCDCoverage()) {
+ GrCapsDebugf(this->caps(), "Coverage FP is not compatible with coverage as alpha.\n");
+ }
+#endif
if (!renderTargetContext->accessRenderTarget()) {
return;
diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp
index 0248beb9ce..838dff8e3a 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -253,8 +253,12 @@ sk_sp<GrFragmentProcessor> GrConvexPolyEffect::Make(GrPrimitiveEdgeType type, co
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 d7330691ae..36936f8db1 100644
--- a/src/gpu/effects/GrCustomXfermode.cpp
+++ b/src/gpu/effects/GrCustomXfermode.cpp
@@ -300,7 +300,8 @@ GrXferProcessor::OptFlags CustomXP::onGetOptimizations(const GrPipelineAnalysis&
*/
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 ead4ed6f3f..6b7d0ba025 100644
--- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp
+++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
@@ -466,7 +466,8 @@ GrXferProcessor::OptFlags PorterDuffXferProcessor::onGetOptimizations(
optFlags |= GrXferProcessor::kIgnoreColor_OptFlag;
}
if (analysis.fColorPOI.allProcessorsCompatibleWithCoverageAsAlpha() &&
- fBlendFormula.canTweakAlphaForCoverage() && !analysis.fCoveragePOI.isLCDCoverage()) {
+ analysis.fCoveragePOI.allProcessorsCompatibleWithCoverageAsAlpha() &&
+ fBlendFormula.canTweakAlphaForCoverage()) {
optFlags |= GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag;
}
}