Add comments to clarify use of fInputColorIsOpaque

Bug: skia:7722
Change-Id: I9e2a70ac67947900897f6bb9237d6c3af1d03b7c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/413136
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2021-05-27 11:57:13 -04:00 committed by Skia Commit-Bot
parent 13adb4a398
commit 55cbc75930
2 changed files with 10 additions and 2 deletions

View File

@ -243,6 +243,11 @@ static std::unique_ptr<GrFragmentProcessor> make_gradient(const SkGradientShader
return nullptr; return nullptr;
} }
if (args.fInputColorIsOpaque) { if (args.fInputColorIsOpaque) {
// If the input alpha is known to be 1, we don't need to take the kSrcIn path. This is
// just an optimization. However, we can't just return 'gradient' here. We need to actually
// inhibit the coverage-as-alpha optimization, or we'll fail to incorporate AA correctly.
// The OverrideInput FP happens to do that, so wrap our fp in one of those. The gradient FP
// doesn't actually use the input color at all, so the overridden input is irrelevant.
return GrFragmentProcessor::OverrideInput(std::move(gradient), SK_PMColor4fWHITE, false); return GrFragmentProcessor::OverrideInput(std::move(gradient), SK_PMColor4fWHITE, false);
} }
return GrFragmentProcessor::MulChildByInputAlpha(std::move(gradient)); return GrFragmentProcessor::MulChildByInputAlpha(std::move(gradient));

View File

@ -342,8 +342,11 @@ std::unique_ptr<GrFragmentProcessor> SkImageShader::asFragmentProcessor(
if (fImage->isAlphaOnly()) { if (fImage->isAlphaOnly()) {
return GrBlendFragmentProcessor::Make(std::move(fp), nullptr, SkBlendMode::kDstIn); return GrBlendFragmentProcessor::Make(std::move(fp), nullptr, SkBlendMode::kDstIn);
} else if (args.fInputColorIsOpaque) { } else if (args.fInputColorIsOpaque) {
// This special case isn't needed for correctness. It just avoids a multiplication by // If the input alpha is known to be 1, we don't need to take the kSrcIn path. This is
// a vertex attribute alpha that is known to be 1 if we take the kSrcIn path. // just an optimization. However, we can't just return 'fp' here. We need to actually
// inhibit the coverage-as-alpha optimization, or we'll fail to incorporate AA correctly.
// The OverrideInput FP happens to do that, so wrap our fp in one of those. The texture FP
// doesn't actually use the input color at all, so the overridden input is irrelevant.
return GrFragmentProcessor::OverrideInput(std::move(fp), SK_PMColor4fWHITE, false); return GrFragmentProcessor::OverrideInput(std::move(fp), SK_PMColor4fWHITE, false);
} }
return GrBlendFragmentProcessor::Make(std::move(fp), nullptr, SkBlendMode::kSrcIn); return GrBlendFragmentProcessor::Make(std::move(fp), nullptr, SkBlendMode::kSrcIn);