Switch bokeh blur shader to built-in transform mappers

このコミットが含まれているのは:
Sergio Pedri committed 2022-09-06 02:32:57 +02:00
1 親 7925952e07
コミット b888820e39
1ファイル変更
+8 -66
+8 -66
ファイルの表示
@@ -303,8 +303,8 @@ public sealed partial class BokehBlurEffect
d2D1DeviceContext.Get()->SetRenderingControls(&d2D1RenderingControls);
// Register all necessary effects
D2D1PixelShaderEffect.RegisterForD2D1Factory1(d2D1Factory2.Get(), new VerticalConvolution(), out _);
D2D1PixelShaderEffect.RegisterForD2D1Factory1(d2D1Factory2.Get(), new HorizontalConvolutionAndAccumulatePartials(), out _);
D2D1PixelShaderEffect.RegisterForD2D1Factory1(d2D1Factory2.Get(), VerticalConvolution.Transform, out _);
D2D1PixelShaderEffect.RegisterForD2D1Factory1(d2D1Factory2.Get(), HorizontalConvolutionAndAccumulatePartials.Transform, out _);
D2D1PixelShaderEffect.RegisterForD2D1Factory1<GammaHighlight>(d2D1Factory2.Get(), out _);
D2D1PixelShaderEffect.RegisterForD2D1Factory1<InverseGammaHighlight>(d2D1Factory2.Get(), out _);
@@ -477,41 +477,12 @@ public sealed partial class BokehBlurEffect
/// <summary>
/// The vertical convolution shader and transform.
/// </summary>
private sealed partial class VerticalConvolution : ID2D1TransformMapperFactory<VerticalConvolution.Shader>, ID2D1TransformMapper<VerticalConvolution.Shader>
private sealed partial class VerticalConvolution
{
/// <summary>
/// The length of the convolution kernel.
/// The <see cref="ID2D1TransformMapperFactory{T}"/> for the shader.
/// </summary>
private int kernelLength;
/// <inheritdoc/>
public ID2D1TransformMapper<Shader> Create()
{
return new VerticalConvolution();
}
/// <inheritdoc/>
public void MapInputsToOutput(in Shader shader, ReadOnlySpan<Rectangle> inputs, ReadOnlySpan<Rectangle> opaqueInputs, out Rectangle output, out Rectangle opaqueOutput)
{
this.kernelLength = shader.kernelLength;
output = inputs[0];
opaqueOutput = Rectangle.Empty;
}
/// <inheritdoc/>
public void MapInvalidOutput(int inputIndex, Rectangle invalidInput, out Rectangle invalidOutput)
{
invalidOutput = invalidInput;
}
/// <inheritdoc/>
public void MapOutputToInputs(in Rectangle output, Span<Rectangle> inputs)
{
Rectangle input = Rectangle.Inflate(output, 0, this.kernelLength);
inputs.Fill(input);
}
public static ID2D1TransformMapperFactory<Shader> Transform { get; } = D2D1TransformMapperFactory<Shader>.Inflate(static (in Shader shader) => (0, shader.kernelLength, 0, shader.kernelLength));
/// <summary>
/// Kernel for the vertical convolution pass for real or imaginary components.
@@ -553,41 +524,12 @@ public sealed partial class BokehBlurEffect
/// <summary>
/// The horizontal convolutin and partial accumulation effect and transform.
/// </summary>
private sealed partial class HorizontalConvolutionAndAccumulatePartials : ID2D1TransformMapperFactory<HorizontalConvolutionAndAccumulatePartials.Shader>, ID2D1TransformMapper<HorizontalConvolutionAndAccumulatePartials.Shader>
private sealed partial class HorizontalConvolutionAndAccumulatePartials
{
/// <summary>
/// The length of the convolution kernel.
/// The <see cref="ID2D1TransformMapperFactory{T}"/> for the shader.
/// </summary>
private int kernelLength;
/// <inheritdoc/>
public ID2D1TransformMapper<Shader> Create()
{
return new HorizontalConvolutionAndAccumulatePartials();
}
/// <inheritdoc/>
public void MapInputsToOutput(in Shader shader, ReadOnlySpan<Rectangle> inputs, ReadOnlySpan<Rectangle> opaqueInputs, out Rectangle output, out Rectangle opaqueOutput)
{
this.kernelLength = shader.kernelLength;
output = inputs[0];
opaqueOutput = Rectangle.Empty;
}
/// <inheritdoc/>
public void MapInvalidOutput(int inputIndex, Rectangle invalidInput, out Rectangle invalidOutput)
{
invalidOutput = invalidInput;
}
/// <inheritdoc/>
public void MapOutputToInputs(in Rectangle output, Span<Rectangle> inputs)
{
Rectangle input = Rectangle.Inflate(output, this.kernelLength, 0);
inputs.Fill(input);
}
public static ID2D1TransformMapperFactory<Shader> Transform { get; } = D2D1TransformMapperFactory<Shader>.Inflate(static (in Shader shader) => (shader.kernelLength, 0, shader.kernelLength, 0));
/// <summary>
/// Kernel for the horizontal convolution pass.