From e026511f4c4b90bfe842f89966d088b663fc8c13 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Tue, 21 Feb 2017 14:19:07 -0500 Subject: 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 Commit-Queue: Brian Salomon --- src/gpu/effects/GrXfermodeFragmentProcessor.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp index 8488fec2ff..eb6f04b075 100644 --- a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp +++ b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp @@ -285,15 +285,21 @@ private: 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; -- cgit v1.2.3