Fix clip shader coverage combining with geometry processor coverage
We were getting lucky with intersect in that the tested shaders always
ended up multiplying by the input alpha at the end. This adds a
dedicated GM that tests the difference op for clip shaders, across
a variety of shape types.
Bug: skia:10879
Change-Id: I45fdaad27f05ae7a74dbdc79eece2e9688806568
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330123
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/gpu/GrClipStack.cpp b/src/gpu/GrClipStack.cpp
index f572db2..abab6b7 100644
--- a/src/gpu/GrClipStack.cpp
+++ b/src/gpu/GrClipStack.cpp
@@ -1291,7 +1291,9 @@
GrFPArgs args(context, *fMatrixProvider, kNone_SkFilterQuality, &kCoverageColorInfo);
clipFP = as_SB(cs.shader())->asFragmentProcessor(args);
if (clipFP) {
- clipFP = GrFragmentProcessor::SwizzleOutput(std::move(clipFP), GrSwizzle::AAAA());
+ // The initial input is the coverage from the geometry processor, so this ensures it
+ // is multiplied properly with the alpha of the clip shader.
+ clipFP = GrFragmentProcessor::MulInputByChildAlpha(std::move(clipFP));
}
}