Avoid multiplication by alpha in fragment shader when known to be 1.
Implemented for image shaders, image draws, and gradient shaders.
Reimplement GrFragmentProcessor::OverrideInput as GrOverrideInputFragmentProcessor.fp.
It allows specification of whether the replacement input color should be
a literal in the shader code or a uniform. For above use case use with literal white.
Make key in variables in fp files work for 4f colors.
Fix issue in CPP code gen from .fp where when + key vars that pushed multiple values
into the shader key only skipped the first key value when the when condition is not
true.
Bug: skia:7722
Change-Id: Id7c865132d620e8cdea8b00f2a627103eef171ac
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201985
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
index e3064bf..b5730fb 100644
--- a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
+++ b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
@@ -326,17 +326,8 @@
case SkBlendMode::kSrcIn:
case SkBlendMode::kDstIn:
case SkBlendMode::kModulate:
- if (fp->compatibleWithCoverageAsAlpha()) {
- if (fp->preservesOpaqueInput()) {
- flags = kPreservesOpaqueInput_OptimizationFlag |
- kCompatibleWithCoverageAsAlpha_OptimizationFlag;
- } else {
- flags = kCompatibleWithCoverageAsAlpha_OptimizationFlag;
- }
- } else {
- flags = fp->preservesOpaqueInput() ? kPreservesOpaqueInput_OptimizationFlag
- : kNone_OptimizationFlags;
- }
+ flags = ProcessorOptimizationFlags(fp) &
+ ~kConstantOutputForConstantInput_OptimizationFlag;
break;
// Produces zero when both are opaque, indeterminate if one is opaque.