[skif] Fix required input recursion for Runtime image filters
Change-Id: Ie59ef73ae15fa6b58c25172a733d2315bea86ba1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/703616
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/effects/imagefilters/SkRuntimeImageFilter.cpp b/src/effects/imagefilters/SkRuntimeImageFilter.cpp
index 0a9415e..691e0b0 100644
--- a/src/effects/imagefilters/SkRuntimeImageFilter.cpp
+++ b/src/effects/imagefilters/SkRuntimeImageFilter.cpp
@@ -82,6 +82,15 @@
const skif::Mapping&,
const skif::LayerSpace<SkIRect>& contentBounds) const override;
+ skif::LayerSpace<SkIRect> applyMaxSampleRadius(
+ const skif::Mapping& mapping,
+ skif::LayerSpace<SkIRect> bounds) const {
+ skif::LayerSpace<SkISize> maxSampleRadius = mapping.paramToLayer(
+ skif::ParameterSpace<SkSize>({fMaxSampleRadius, fMaxSampleRadius})).ceil();
+ bounds.outset(maxSampleRadius);
+ return bounds;
+ }
+
mutable SkSpinlock fRuntimeEffectLock;
mutable SkRuntimeShaderBuilder fRuntimeEffectBuilder;
STArray<1, SkString> fChildShaderNames;
@@ -230,9 +239,11 @@
const int inputCount = this->countInputs();
SkASSERT(inputCount == fChildShaderNames.size());
+ skif::Context inputCtx = ctx.withNewDesiredOutput(
+ this->applyMaxSampleRadius(ctx.mapping(), ctx.desiredOutput()));
skif::FilterResult::Builder builder{ctx};
for (int i = 0; i < inputCount; ++i) {
- builder.add(this->getChildOutput(i, ctx));
+ builder.add(this->getChildOutput(i, inputCtx));
}
return builder.eval([&](SkSpan<sk_sp<SkShader>> inputs) {
// lock the mutation of the builder and creation of the shader so that the builder's state
@@ -263,11 +274,8 @@
return skif::LayerSpace<SkIRect>::Empty();
} else {
// Provide 'maxSampleRadius' pixels (in layer space) to the child shaders.
- skif::LayerSpace<SkISize> maxSampleRadius = mapping.paramToLayer(
- skif::ParameterSpace<SkSize>({fMaxSampleRadius, fMaxSampleRadius})).ceil();
-
- skif::LayerSpace<SkIRect> requiredInput = desiredOutput;
- requiredInput.outset(maxSampleRadius);
+ skif::LayerSpace<SkIRect> requiredInput =
+ this->applyMaxSampleRadius(mapping, desiredOutput);
// Union of all child input bounds so that one source image can provide for all of them.
skif::LayerSpace<SkIRect> merged =