Remove GrBlendFragmentProcessor::Behavior::kSkBlendMode.
The only difference between this and kComposeOne is that it always
sets the src child's input color to opaque white. However, all call sites
pass a color FP that ignores its input. So in practice there is no
difference.
Bug: skia:10457
Change-Id: I816d421fcb7b48d81ba68f835571ef703aa8d73d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425460
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/core/SkModeColorFilter.cpp b/src/core/SkModeColorFilter.cpp
index f844e0a..c6849d4 100644
--- a/src/core/SkModeColorFilter.cpp
+++ b/src/core/SkModeColorFilter.cpp
@@ -101,8 +101,10 @@
auto colorFP = GrFragmentProcessor::MakeColor(SkColorToPMColor4f(fColor, dstColorInfo));
auto xferFP = GrBlendFragmentProcessor::Make(
- std::move(colorFP), std::move(inputFP), fMode,
- GrBlendFragmentProcessor::BlendBehavior::kSkModeBehavior);
+ std::move(colorFP),
+ std::move(inputFP),
+ fMode,
+ GrBlendFragmentProcessor::BlendBehavior::kComposeOneBehavior);
if (xferFP == nullptr) {
// This is only expected to happen if the blend mode is "dest" and the input FP is null.
diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp
index 5c0419b..0d2a4e8 100644
--- a/src/gpu/GrFragmentProcessor.cpp
+++ b/src/gpu/GrFragmentProcessor.cpp
@@ -248,16 +248,20 @@
std::unique_ptr<GrFragmentProcessor> inputFP, const SkPMColor4f& color) {
auto colorFP = MakeColor(color);
return GrBlendFragmentProcessor::Make(
- std::move(colorFP), std::move(inputFP), SkBlendMode::kSrcIn,
- GrBlendFragmentProcessor::BlendBehavior::kSkModeBehavior);
+ std::move(colorFP),
+ std::move(inputFP),
+ SkBlendMode::kSrcIn,
+ GrBlendFragmentProcessor::BlendBehavior::kComposeOneBehavior);
}
std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::ModulateRGBA(
std::unique_ptr<GrFragmentProcessor> inputFP, const SkPMColor4f& color) {
auto colorFP = MakeColor(color);
return GrBlendFragmentProcessor::Make(
- std::move(colorFP), std::move(inputFP), SkBlendMode::kModulate,
- GrBlendFragmentProcessor::BlendBehavior::kSkModeBehavior);
+ std::move(colorFP),
+ std::move(inputFP),
+ SkBlendMode::kModulate,
+ GrBlendFragmentProcessor::BlendBehavior::kComposeOneBehavior);
}
std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::ClampOutput(
diff --git a/src/gpu/GrFragmentProcessor.h b/src/gpu/GrFragmentProcessor.h
index 84743c4..9fc1d31 100644
--- a/src/gpu/GrFragmentProcessor.h
+++ b/src/gpu/GrFragmentProcessor.h
@@ -61,14 +61,16 @@
/**
* Returns a fragment processor that generates the passed-in color, modulated by the child's
- * alpha channel. (Pass a null FP to use the alpha from fInputColor instead of a child FP.)
+ * alpha channel. The child's input color will be the parent's fInputColor. (Pass a null FP to
+ * use the alpha from fInputColor instead of a child FP.)
*/
static std::unique_ptr<GrFragmentProcessor> ModulateAlpha(
std::unique_ptr<GrFragmentProcessor> child, const SkPMColor4f& color);
/**
* Returns a fragment processor that generates the passed-in color, modulated by the child's
- * RGBA color. (Pass a null FP to use the color from fInputColor instead of a child FP.)
+ * RGBA color. The child's input color will be the parent's fInputColor. (Pass a null FP to use
+ * the color from fInputColor instead of a child FP.)
*/
static std::unique_ptr<GrFragmentProcessor> ModulateRGBA(
std::unique_ptr<GrFragmentProcessor> child, const SkPMColor4f& color);
diff --git a/src/gpu/effects/GrBlendFragmentProcessor.cpp b/src/gpu/effects/GrBlendFragmentProcessor.cpp
index f754d42..e99ca9d 100644
--- a/src/gpu/effects/GrBlendFragmentProcessor.cpp
+++ b/src/gpu/effects/GrBlendFragmentProcessor.cpp
@@ -29,7 +29,6 @@
SkASSERT(unsigned(behavior) <= unsigned(BlendBehavior::kLastBlendBehavior));
static constexpr const char* gStrings[] = {
"Compose-One",
- "SkMode",
};
static_assert(SK_ARRAY_COUNT(gStrings) == size_t(BlendBehavior::kLastBlendBehavior) + 1);
return gStrings[int(behavior)];
@@ -177,14 +176,6 @@
return SkBlendMode_Apply(fMode, srcColor, dstColor);
}
- case BlendBehavior::kSkModeBehavior: {
- SkPMColor4f srcColor = src ? ConstantOutputForConstantInput(src, SK_PMColor4fWHITE)
- : input;
- SkPMColor4f dstColor = dst ? ConstantOutputForConstantInput(dst, input)
- : input;
- return SkBlendMode_Apply(fMode, srcColor, dstColor);
- }
-
default:
SK_ABORT("unrecognized blend behavior");
return input;
@@ -263,14 +254,6 @@
dstColor = this->invokeChild(1, args.fInputColor, args);
break;
- case BlendBehavior::kSkModeBehavior:
- // SkModeColorFilter operations act like ComposeOne, but pass the input color to dst.
- srcColor = cs.childProcessor(0) ? this->invokeChild(0, "half4(1)", args)
- : SkString(args.fInputColor);
- dstColor = cs.childProcessor(1) ? this->invokeChild(1, args.fInputColor, args)
- : SkString(args.fInputColor);
- break;
-
default:
SK_ABORT("unrecognized blend behavior");
break;
diff --git a/src/gpu/effects/GrBlendFragmentProcessor.h b/src/gpu/effects/GrBlendFragmentProcessor.h
index b322a4a..43d6d01 100644
--- a/src/gpu/effects/GrBlendFragmentProcessor.h
+++ b/src/gpu/effects/GrBlendFragmentProcessor.h
@@ -20,10 +20,7 @@
// fInputColor is passed as the input color to child FPs. No alpha channel trickery.
kComposeOneBehavior,
- // half(1) is passed to src; fInputColor is passed to dst. No alpha channel trickery.
- kSkModeBehavior,
-
- kLastBlendBehavior = kSkModeBehavior,
+ kLastBlendBehavior = kComposeOneBehavior,
};
/** Blends src and dst inputs according to the blend mode.