Fix ComposeOneFragmentProcessor coverage as alpha optimization.
It should only be advertised if the child also advertises it.
Change-Id: I698213c9562d710dff45f0622d50eacc41e29af5
Reviewed-on: https://skia-review.googlesource.com/8811
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
index 8488fec..eb6f04b 100644
--- a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
+++ b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
@@ -285,15 +285,21 @@
break;
// Produces opaque if both src and dst are opaque. These also will modulate the child's
- // output by either the input color or alpha.
+ // output by either the input color or alpha. However, if the child is not compatible
+ // with the coverage as alpha then it may produce a color that is not valid premul.
case SkBlendMode::kSrcIn:
case SkBlendMode::kDstIn:
case SkBlendMode::kModulate:
- if (fp->preservesOpaqueInput()) {
- flags = kPreservesOpaqueInput_OptimizationFlag |
- kCompatibleWithCoverageAsAlpha_OptimizationFlag;
+ if (fp->compatibleWithCoverageAsAlpha()) {
+ if (fp->preservesOpaqueInput()) {
+ flags = kPreservesOpaqueInput_OptimizationFlag |
+ kCompatibleWithCoverageAsAlpha_OptimizationFlag;
+ } else {
+ flags = kCompatibleWithCoverageAsAlpha_OptimizationFlag;
+ }
} else {
- flags = kCompatibleWithCoverageAsAlpha_OptimizationFlag;
+ flags = fp->preservesOpaqueInput() ? kPreservesOpaqueInput_OptimizationFlag
+ : kNone_OptimizationFlags;
}
break;