Remove GrBlendFragmentProcessor::BlendBehavior::kDefault
Always explicitly pass one of the other behaviors. Bug: skia:10457 Change-Id: I573161b3de0476a398d71fcaab71e2d68fa13d02 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425457 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
ae7f7edd49
commit
a2d6890c5b
@ -281,14 +281,19 @@ static void run(GrRecordingContext* rContext, GrSurfaceDrawContext* sdc, bool su
|
||||
sampler,
|
||||
caps);
|
||||
// Compose against white (default paint color)
|
||||
fp = GrBlendFragmentProcessor::Make(std::move(fp),
|
||||
/*dst=*/nullptr,
|
||||
SkBlendMode::kSrcOver);
|
||||
fp = GrBlendFragmentProcessor::Make(
|
||||
std::move(fp),
|
||||
/*dst=*/nullptr,
|
||||
SkBlendMode::kSrcOver,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kComposeOneBehavior);
|
||||
GrPaint paint;
|
||||
// Compose against white (default paint color) and then replace the dst
|
||||
// (SkBlendMode::kSrc).
|
||||
fp = GrBlendFragmentProcessor::Make(std::move(fp), /*dst=*/nullptr,
|
||||
SkBlendMode::kSrcOver);
|
||||
fp = GrBlendFragmentProcessor::Make(
|
||||
std::move(fp),
|
||||
/*dst=*/nullptr,
|
||||
SkBlendMode::kSrcOver,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kComposeOneBehavior);
|
||||
paint.setColorFragmentProcessor(std::move(fp));
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
sdc->fillRectToRect(nullptr,
|
||||
@ -385,9 +390,11 @@ static void do_very_large_blur_gm(GrSurfaceDrawContext* sdc,
|
||||
if (result) {
|
||||
std::unique_ptr<GrFragmentProcessor> fp =
|
||||
GrTextureEffect::Make(std::move(result), kPremul_SkAlphaType);
|
||||
fp = GrBlendFragmentProcessor::Make(std::move(fp),
|
||||
/*dst=*/nullptr,
|
||||
SkBlendMode::kSrcOver);
|
||||
fp = GrBlendFragmentProcessor::Make(
|
||||
std::move(fp),
|
||||
/*dst=*/nullptr,
|
||||
SkBlendMode::kSrcOver,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kComposeOneBehavior);
|
||||
sdc->fillRectToRectWithFP(SkIRect::MakeSize(dstB.size()),
|
||||
dstRect,
|
||||
std::move(fp));
|
||||
|
@ -280,7 +280,11 @@ sk_sp<SkSpecialImage> SkBlendImageFilter::filterImageGPU(const Context& ctx,
|
||||
fgFP = GrColorSpaceXformEffect::Make(std::move(fgFP), foreground->getColorSpace(),
|
||||
foreground->alphaType(), ctx.colorSpace(),
|
||||
kPremul_SkAlphaType);
|
||||
fp = GrBlendFragmentProcessor::Make(std::move(fgFP), std::move(fp), fMode);
|
||||
fp = GrBlendFragmentProcessor::Make(
|
||||
std::move(fgFP),
|
||||
std::move(fp),
|
||||
fMode,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kComposeTwoBehavior);
|
||||
}
|
||||
|
||||
GrImageInfo info(ctx.grColorType(), kPremul_SkAlphaType, ctx.refColorSpace(), bounds.size());
|
||||
|
@ -1606,6 +1606,10 @@ GrFPResult GrClipStack::GetSWMaskFP(GrRecordingContext* context, Mask::Stack* ma
|
||||
fp = GrFragmentProcessor::DeviceSpace(std::move(fp));
|
||||
|
||||
// Must combine the coverage sampled from the texture effect with the previous coverage
|
||||
fp = GrBlendFragmentProcessor::Make(std::move(fp), std::move(clipFP), SkBlendMode::kDstIn);
|
||||
fp = GrBlendFragmentProcessor::Make(
|
||||
std::move(fp),
|
||||
std::move(clipFP),
|
||||
SkBlendMode::kDstIn,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kComposeTwoBehavior);
|
||||
return GrFPSuccess(std::move(fp));
|
||||
}
|
||||
|
@ -82,7 +82,11 @@ static std::unique_ptr<GrFragmentProcessor> create_fp_for_mask(GrSurfaceProxyVie
|
||||
auto domain = subset.makeInset(0.5, 0.5);
|
||||
auto fp = GrTextureEffect::MakeSubset(std::move(mask), kPremul_SkAlphaType, m, samplerState,
|
||||
subset, domain, caps);
|
||||
fp = GrBlendFragmentProcessor::Make(std::move(fp), nullptr, SkBlendMode::kDstIn);
|
||||
fp = GrBlendFragmentProcessor::Make(
|
||||
std::move(fp),
|
||||
nullptr,
|
||||
SkBlendMode::kDstIn,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kComposeOneBehavior);
|
||||
return GrFragmentProcessor::DeviceSpace(std::move(fp));
|
||||
}
|
||||
|
||||
|
@ -225,7 +225,11 @@ std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::MulChildByInputAlpha(
|
||||
if (!fp) {
|
||||
return nullptr;
|
||||
}
|
||||
return GrBlendFragmentProcessor::Make(/*src=*/nullptr, std::move(fp), SkBlendMode::kDstIn);
|
||||
return GrBlendFragmentProcessor::Make(
|
||||
/*src=*/nullptr,
|
||||
std::move(fp),
|
||||
SkBlendMode::kDstIn,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kComposeOneBehavior);
|
||||
}
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::MulInputByChildAlpha(
|
||||
@ -233,7 +237,11 @@ std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::MulInputByChildAlpha(
|
||||
if (!fp) {
|
||||
return nullptr;
|
||||
}
|
||||
return GrBlendFragmentProcessor::Make(/*src=*/nullptr, std::move(fp), SkBlendMode::kSrcIn);
|
||||
return GrBlendFragmentProcessor::Make(
|
||||
/*src=*/nullptr,
|
||||
std::move(fp),
|
||||
SkBlendMode::kSrcIn,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kComposeOneBehavior);
|
||||
}
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::ModulateAlpha(
|
||||
|
@ -643,7 +643,11 @@ void GrSurfaceDrawContext::drawTexture(const GrClip* clip,
|
||||
if (colorSpaceXform) {
|
||||
fp = GrColorSpaceXformEffect::Make(std::move(fp), std::move(colorSpaceXform));
|
||||
}
|
||||
fp = GrBlendFragmentProcessor::Make(std::move(fp), nullptr, SkBlendMode::kModulate);
|
||||
fp = GrBlendFragmentProcessor::Make(
|
||||
std::move(fp),
|
||||
nullptr,
|
||||
SkBlendMode::kModulate,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kComposeOneBehavior);
|
||||
paint.setColorFragmentProcessor(std::move(fp));
|
||||
if (blendMode != SkBlendMode::kSrcOver) {
|
||||
paint.setXPFactory(SkBlendMode_AsXPFactory(blendMode));
|
||||
|
@ -430,8 +430,11 @@ static inline bool skpaint_to_grpaint_impl(GrRecordingContext* context,
|
||||
|
||||
SkPMColor4f shaderInput = origColor.makeOpaque().premul();
|
||||
paintFP = GrFragmentProcessor::OverrideInput(std::move(paintFP), shaderInput);
|
||||
paintFP = GrBlendFragmentProcessor::Make(std::move(paintFP), /*dst=*/nullptr,
|
||||
*primColorMode);
|
||||
paintFP = GrBlendFragmentProcessor::Make(
|
||||
std::move(paintFP),
|
||||
/*dst=*/nullptr,
|
||||
*primColorMode,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kComposeOneBehavior);
|
||||
|
||||
// We can ignore origColor here - alpha is unchanged by gamma
|
||||
float paintAlpha = skPaint.getColor4f().fA;
|
||||
@ -450,8 +453,11 @@ static inline bool skpaint_to_grpaint_impl(GrRecordingContext* context,
|
||||
// the opaque paint color. The paint's alpha is applied to the post-blended color.
|
||||
SkPMColor4f opaqueColor = origColor.makeOpaque().premul();
|
||||
paintFP = GrFragmentProcessor::MakeColor(opaqueColor);
|
||||
paintFP = GrBlendFragmentProcessor::Make(std::move(paintFP), /*dst=*/nullptr,
|
||||
*primColorMode);
|
||||
paintFP = GrBlendFragmentProcessor::Make(
|
||||
std::move(paintFP),
|
||||
/*dst=*/nullptr,
|
||||
*primColorMode,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kComposeOneBehavior);
|
||||
grPaint->setColor4f(opaqueColor);
|
||||
|
||||
// We can ignore origColor here - alpha is unchanged by gamma
|
||||
|
@ -28,7 +28,6 @@ static inline bool does_cpu_blend_impl_match_gpu(SkBlendMode mode) {
|
||||
static const char* BlendBehavior_Name(BlendBehavior behavior) {
|
||||
SkASSERT(unsigned(behavior) <= unsigned(BlendBehavior::kLastBlendBehavior));
|
||||
static constexpr const char* gStrings[] = {
|
||||
"Default",
|
||||
"Compose-One",
|
||||
"Compose-Two",
|
||||
"SkMode",
|
||||
@ -62,10 +61,6 @@ private:
|
||||
: INHERITED(kBlendFragmentProcessor_ClassID, OptFlags(src.get(), dst.get(), mode))
|
||||
, fMode(mode)
|
||||
, fBlendBehavior(behavior) {
|
||||
if (fBlendBehavior == BlendBehavior::kDefault) {
|
||||
fBlendBehavior = (src && dst) ? BlendBehavior::kComposeTwoBehavior
|
||||
: BlendBehavior::kComposeOneBehavior;
|
||||
}
|
||||
this->registerChild(std::move(src));
|
||||
this->registerChild(std::move(dst));
|
||||
}
|
||||
|
@ -17,9 +17,6 @@ namespace GrBlendFragmentProcessor {
|
||||
|
||||
// TODO(skbug.com/10457): Standardize on a single blend behavior
|
||||
enum class BlendBehavior {
|
||||
// Picks "ComposeOne" or "ComposeTwo" automatically depending on presence of src/dst FPs.
|
||||
kDefault = 0,
|
||||
|
||||
// half(1) is passed as the input color to child FPs. No alpha channel trickery.
|
||||
kComposeOneBehavior,
|
||||
|
||||
@ -38,7 +35,7 @@ enum class BlendBehavior {
|
||||
std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> src,
|
||||
std::unique_ptr<GrFragmentProcessor> dst,
|
||||
SkBlendMode mode,
|
||||
BlendBehavior behavior = BlendBehavior::kDefault);
|
||||
BlendBehavior behavior);
|
||||
|
||||
} // namespace GrBlendFragmentProcessor
|
||||
|
||||
|
@ -1167,7 +1167,11 @@ GrOp::Owner GrTextureOp::Make(GrRecordingContext* context,
|
||||
caps);
|
||||
}
|
||||
fp = GrColorSpaceXformEffect::Make(std::move(fp), std::move(textureXform));
|
||||
fp = GrBlendFragmentProcessor::Make(std::move(fp), nullptr, SkBlendMode::kModulate);
|
||||
fp = GrBlendFragmentProcessor::Make(
|
||||
std::move(fp),
|
||||
nullptr,
|
||||
SkBlendMode::kModulate,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kComposeOneBehavior);
|
||||
if (saturate == GrTextureOp::Saturate::kYes) {
|
||||
fp = GrFragmentProcessor::ClampOutput(std::move(fp));
|
||||
}
|
||||
|
@ -510,9 +510,17 @@ void draw_image(GrRecordingContext* context,
|
||||
image.imageInfo().colorInfo(),
|
||||
rtc->colorInfo());
|
||||
if (image.isAlphaOnly()) {
|
||||
fp = GrBlendFragmentProcessor::Make(std::move(fp), nullptr, SkBlendMode::kDstIn);
|
||||
fp = GrBlendFragmentProcessor::Make(
|
||||
std::move(fp),
|
||||
nullptr,
|
||||
SkBlendMode::kDstIn,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kComposeOneBehavior);
|
||||
} else {
|
||||
fp = GrBlendFragmentProcessor::Make(std::move(fp), nullptr, SkBlendMode::kSrcIn);
|
||||
fp = GrBlendFragmentProcessor::Make(
|
||||
std::move(fp),
|
||||
nullptr,
|
||||
SkBlendMode::kSrcIn,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kComposeOneBehavior);
|
||||
}
|
||||
|
||||
GrPaint grPaint;
|
||||
|
@ -136,6 +136,10 @@ std::unique_ptr<GrFragmentProcessor> SkShader_Blend::asFragmentProcessor(
|
||||
// This is unexpected. Both src and dst shaders should be valid. Just fail.
|
||||
return nullptr;
|
||||
}
|
||||
return GrBlendFragmentProcessor::Make(std::move(fpB), std::move(fpA), fMode);
|
||||
return GrBlendFragmentProcessor::Make(
|
||||
std::move(fpB),
|
||||
std::move(fpA),
|
||||
fMode,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kComposeTwoBehavior);
|
||||
}
|
||||
#endif
|
||||
|
@ -340,7 +340,11 @@ std::unique_ptr<GrFragmentProcessor> SkImageShader::asFragmentProcessor(
|
||||
args.fDstColorInfo->colorSpace(),
|
||||
kPremul_SkAlphaType);
|
||||
if (fImage->isAlphaOnly()) {
|
||||
return GrBlendFragmentProcessor::Make(std::move(fp), nullptr, SkBlendMode::kDstIn);
|
||||
return GrBlendFragmentProcessor::Make(
|
||||
std::move(fp),
|
||||
nullptr,
|
||||
SkBlendMode::kDstIn,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kComposeOneBehavior);
|
||||
} else 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 'fp' here. We need to actually
|
||||
@ -349,7 +353,11 @@ std::unique_ptr<GrFragmentProcessor> SkImageShader::asFragmentProcessor(
|
||||
// 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 GrBlendFragmentProcessor::Make(std::move(fp), nullptr, SkBlendMode::kSrcIn);
|
||||
return GrBlendFragmentProcessor::Make(
|
||||
std::move(fp),
|
||||
nullptr,
|
||||
SkBlendMode::kSrcIn,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kComposeOneBehavior);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -204,10 +204,18 @@ static std::unique_ptr<GrFragmentProcessor> create_random_proc_tree(GrProcessorT
|
||||
(int)SkBlendMode::kLastMode));
|
||||
std::unique_ptr<GrFragmentProcessor> fp;
|
||||
if (d->fRandom->nextF() < 0.5f) {
|
||||
fp = GrBlendFragmentProcessor::Make(std::move(minLevelsChild), std::move(otherChild), mode);
|
||||
fp = GrBlendFragmentProcessor::Make(
|
||||
std::move(minLevelsChild),
|
||||
std::move(otherChild),
|
||||
mode,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kComposeTwoBehavior);
|
||||
SkASSERT(fp);
|
||||
} else {
|
||||
fp = GrBlendFragmentProcessor::Make(std::move(otherChild), std::move(minLevelsChild), mode);
|
||||
fp = GrBlendFragmentProcessor::Make(
|
||||
std::move(otherChild),
|
||||
std::move(minLevelsChild),
|
||||
mode,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kComposeTwoBehavior);
|
||||
SkASSERT(fp);
|
||||
}
|
||||
return fp;
|
||||
|
Loading…
Reference in New Issue
Block a user