Merge pull request #376 from Sergio0694/dev/transform-helpers
Add D2D1 transform helper APIs
このコミットが含まれているのは:
20ファイル変更
+895
-139
検索条件に一致するファイルはありません
@@ -0,0 +1,15 @@
|
||||
namespace ComputeSharp.D2D1;
|
||||
|
||||
/// <summary>
|
||||
/// An <see langword="interface"/> acting as a factory for <see cref="ID2D1TransformMapper{T}"/> instances.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of shader this factory creates transform mapper instances for.</typeparam>
|
||||
public interface ID2D1TransformMapperFactory<T>
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ID2D1TransformMapper{T}"/> instance for a given shader.
|
||||
/// </summary>
|
||||
/// <returns>A new <see cref="ID2D1TransformMapper{T}"/> instance for the input shader.</returns>
|
||||
ID2D1TransformMapper<T> Create();
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#if NET6_0_OR_GREATER
|
||||
using System.Numerics;
|
||||
#endif
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
@@ -55,7 +58,7 @@ internal ref struct ArrayPoolBinaryWriter
|
||||
ThrowObjectDisposedException();
|
||||
}
|
||||
|
||||
return array!.AsSpan(0, this.index);
|
||||
return array.AsSpan(0, this.index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +111,7 @@ internal ref struct ArrayPoolBinaryWriter
|
||||
ThrowArgumentOutOfRangeExceptionForNegativeCount();
|
||||
}
|
||||
|
||||
if (this.index > array!.Length - count)
|
||||
if (this.index > array.Length - count)
|
||||
{
|
||||
ThrowArgumentExceptionForAdvancedTooFar();
|
||||
}
|
||||
@@ -152,7 +155,7 @@ internal ref struct ArrayPoolBinaryWriter
|
||||
sizeHint = 1;
|
||||
}
|
||||
|
||||
if (sizeHint > array!.Length - this.index)
|
||||
if (sizeHint > array.Length - this.index)
|
||||
{
|
||||
ResizeBuffer(sizeHint);
|
||||
}
|
||||
@@ -204,6 +207,7 @@ internal ref struct ArrayPoolBinaryWriter
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> when the requested count is negative.
|
||||
/// </summary>
|
||||
[DoesNotReturn]
|
||||
private static void ThrowArgumentOutOfRangeExceptionForNegativeCount()
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count", "The count can't be a negative value.");
|
||||
@@ -212,6 +216,7 @@ internal ref struct ArrayPoolBinaryWriter
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> when the size hint is negative.
|
||||
/// </summary>
|
||||
[DoesNotReturn]
|
||||
private static void ThrowArgumentOutOfRangeExceptionForNegativeSizeHint()
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("sizeHint", "The size hint can't be a negative value.");
|
||||
@@ -220,6 +225,7 @@ internal ref struct ArrayPoolBinaryWriter
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> when the requested count is negative.
|
||||
/// </summary>
|
||||
[DoesNotReturn]
|
||||
private static void ThrowArgumentExceptionForAdvancedTooFar()
|
||||
{
|
||||
throw new ArgumentException("The buffer writer has advanced too far.");
|
||||
@@ -228,6 +234,7 @@ internal ref struct ArrayPoolBinaryWriter
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ObjectDisposedException"/> when <see cref="array"/> is <see langword="null"/>.
|
||||
/// </summary>
|
||||
[DoesNotReturn]
|
||||
private static void ThrowObjectDisposedException()
|
||||
{
|
||||
throw new ObjectDisposedException("The current buffer has already been disposed.");
|
||||
|
||||
@@ -59,7 +59,7 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(d2D1Factory1), "The input ID2D1Factory1 object cannot be null.");
|
||||
}
|
||||
|
||||
RegisterForD2D1Factory1(d2D1Factory1, static () => new TMapper(), out effectId);
|
||||
RegisterForD2D1Factory1(d2D1Factory1, D2D1TransformMapper.FactoryOf<T, TMapper>.Instance, out effectId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -72,7 +72,7 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="d2D1Factory1"/> is <see langword="null"/>.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if an effect is registered multiple times with different properties.</exception>
|
||||
/// <remarks>For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1_1/nf-d2d1_1-id2d1factory1-registereffectfromstring"/>.</remarks>
|
||||
public static void RegisterForD2D1Factory1<T>(void* d2D1Factory1, Func<ID2D1TransformMapper<T>>? mapperFactory, out Guid effectId)
|
||||
public static void RegisterForD2D1Factory1<T>(void* d2D1Factory1, ID2D1TransformMapperFactory<T>? mapperFactory, out Guid effectId)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
if (d2D1Factory1 is null)
|
||||
@@ -258,7 +258,7 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
/// <param name="effectId">The <see cref="Guid"/> of the registered effect, which can be used to call <c>ID2D1DeviceContext::CreateEffect</c>.</param>
|
||||
/// <returns>A blob containing serialized information that can be used to register an effect.</returns>
|
||||
/// <exception cref="InvalidOperationException">Thrown if an effect is registered multiple times with different properties.</exception>
|
||||
/// <remarks>For more info and for details on the binary format, see <see cref="GetRegistrationBlob{T}(Func{ID2D1TransformMapper{T}}?, out Guid)"/>.</remarks>
|
||||
/// <remarks>For more info and for details on the binary format, see <see cref="GetRegistrationBlob{T}(ID2D1TransformMapperFactory{T}?, out Guid)"/>.</remarks>
|
||||
public static ReadOnlyMemory<byte> GetRegistrationBlob<T>(out Guid effectId)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
@@ -273,12 +273,12 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
/// <param name="effectId">The <see cref="Guid"/> of the registered effect, which can be used to call <c>ID2D1DeviceContext::CreateEffect</c>.</param>
|
||||
/// <returns>A blob containing serialized information that can be used to register an effect.</returns>
|
||||
/// <exception cref="InvalidOperationException">Thrown if an effect is registered multiple times with different properties.</exception>
|
||||
/// <remarks>For more info and for details on the binary format, see <see cref="GetRegistrationBlob{T}(Func{ID2D1TransformMapper{T}}?, out Guid)"/>.</remarks>
|
||||
/// <remarks>For more info and for details on the binary format, see <see cref="GetRegistrationBlob{T}(ID2D1TransformMapperFactory{T}?, out Guid)"/>.</remarks>
|
||||
public static ReadOnlyMemory<byte> GetRegistrationBlob<T, TMapper>(out Guid effectId)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
where TMapper : class, ID2D1TransformMapper<T>, new()
|
||||
{
|
||||
return GetRegistrationBlob(static () => new TMapper(), out effectId);
|
||||
return GetRegistrationBlob(D2D1TransformMapper.FactoryOf<T, TMapper>.Instance, out effectId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -321,7 +321,7 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
/// For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1_1/nf-d2d1_1-id2d1factory1-registereffectfromstring"/>.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public static ReadOnlyMemory<byte> GetRegistrationBlob<T>(Func<ID2D1TransformMapper<T>>? mapperFactory, out Guid effectId)
|
||||
public static ReadOnlyMemory<byte> GetRegistrationBlob<T>(ID2D1TransformMapperFactory<T>? mapperFactory, out Guid effectId)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
effectId = default;
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
using System.Numerics;
|
||||
using ComputeSharp.D2D1.Helpers;
|
||||
using ComputeSharp.D2D1.Shaders.Interop.Factories;
|
||||
|
||||
namespace ComputeSharp.D2D1.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Provides built-in transform mapper factories for common transform mapping operations.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of D2D1 pixel shader associated to the transform mapper.</typeparam>
|
||||
public static class D2D1TransformMapperFactory<T>
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates an <see cref="ID2D1TransformMapperFactory{T}"/> instance for an inflate transform.
|
||||
/// </summary>
|
||||
/// <param name="amount">The fixed inflate amount to use (applies to all edges of the input area).</param>
|
||||
/// <returns>The resulting <see cref="ID2D1TransformMapperFactory{T}"/> instance for an inflate transform.</returns>
|
||||
public static ID2D1TransformMapperFactory<T> Inflate(int amount)
|
||||
{
|
||||
return new D2D1InflateTransformMapperFactory<T> { ParametersAccessor = new D2D1InflateTransformMapperFactory<T>.ConstantAmount { Amount = amount } };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="ID2D1TransformMapperFactory{T}"/> instance for an inflate transform.
|
||||
/// </summary>
|
||||
/// <param name="left">The fixed left inflate amount to use.</param>
|
||||
/// <param name="top">The fixed top inflate amount to use.</param>
|
||||
/// <param name="right">The fixed right inflate amount to use.</param>
|
||||
/// <param name="bottom">The fixed bottom inflate amount to use.</param>
|
||||
/// <returns>The resulting <see cref="ID2D1TransformMapperFactory{T}"/> instance for an inflate transform.</returns>
|
||||
public static ID2D1TransformMapperFactory<T> Inflate(int left, int top, int right, int bottom)
|
||||
{
|
||||
return new D2D1InflateTransformMapperFactory<T> { ParametersAccessor = new D2D1InflateTransformMapperFactory<T>.ConstantLeftTopRightBottomAmount { Left = left, Top = top, Right = right, Bottom = bottom } };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="ID2D1TransformMapperFactory{T}"/> instance for an inflate transform.
|
||||
/// </summary>
|
||||
/// <param name="accessor">The input <see cref="Accessor{TResult}"/> instance to retrieve the inflate amount to use (applies to all edges of the input area).</param>
|
||||
/// <returns>The resulting <see cref="ID2D1TransformMapperFactory{T}"/> instance for an inflate transform.</returns>
|
||||
public static ID2D1TransformMapperFactory<T> Inflate(Accessor<int> accessor)
|
||||
{
|
||||
if (accessor is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(accessor), "The input D2D1TransformMapperFactory<T>.Accessor<int> object cannot be null.");
|
||||
}
|
||||
|
||||
return new D2D1InflateTransformMapperFactory<T> { ParametersAccessor = new D2D1InflateTransformMapperFactory<T>.DynamicAmount { Accessor = accessor } };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="ID2D1TransformMapperFactory{T}"/> instance for an inflate transform.
|
||||
/// </summary>
|
||||
/// <param name="accessor">The input <see cref="Accessor{TResult}"/> instance to retrieve the inflate amount to use.</param>
|
||||
/// <returns>The resulting <see cref="ID2D1TransformMapperFactory{T}"/> instance for an inflate transform.</returns>
|
||||
public static ID2D1TransformMapperFactory<T> Inflate(Accessor<(int Left, int Top, int Right, int Bottom)> accessor)
|
||||
{
|
||||
if (accessor is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(accessor), "The input D2D1TransformMapperFactory<T>.Accessor<(int Left, int Top, int Right, int Bottom)> object cannot be null.");
|
||||
}
|
||||
|
||||
return new D2D1InflateTransformMapperFactory<T> { ParametersAccessor = new D2D1InflateTransformMapperFactory<T>.DynamicLeftTopRightBottomAmount { Accessor = accessor } };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="ID2D1TransformMapperFactory{T}"/> instance for an affine transform.
|
||||
/// </summary>
|
||||
/// <param name="matrix">The fixed transformation matrix to use.</param>
|
||||
/// <returns>The resulting <see cref="ID2D1TransformMapperFactory{T}"/> instance for an affine transform.</returns>
|
||||
public static ID2D1TransformMapperFactory<T> Transform(Matrix3x2 matrix)
|
||||
{
|
||||
return new D2D1AffineTransformMapperFactory.For<T> { ParametersAccessor = new D2D1AffineTransformMapperFactory.For<T>.ConstantMatrix { Amount = matrix } };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="ID2D1TransformMapperFactory{T}"/> instance for an affine transform.
|
||||
/// </summary>
|
||||
/// <param name="accessor">The input <see cref="Accessor{TResult}"/> instance to retrieve the transformation matrix to use.</param>
|
||||
/// <returns>The resulting <see cref="ID2D1TransformMapperFactory{T}"/> instance for an affine transform.</returns>
|
||||
public static ID2D1TransformMapperFactory<T> Transform(Accessor<Matrix3x2> accessor)
|
||||
{
|
||||
if (accessor is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(accessor), "The input D2D1TransformMapperFactory<T>.Accessor<Matrix3x2> object cannot be null.");
|
||||
}
|
||||
|
||||
return new D2D1AffineTransformMapperFactory.For<T> { ParametersAccessor = new D2D1AffineTransformMapperFactory.For<T>.DynamicMatrix { Accessor = accessor } };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An accessor of parameters to be used in D2D1 transform mapping implementations.
|
||||
/// </summary>
|
||||
/// <typeparam name="TResult">The type of parameters that the transform mapper will use.</typeparam>
|
||||
/// <param name="shader">The input D2D1 pixel shader being executed on the current effect (this can be used to retrieve shader properties).</param>
|
||||
/// <returns>The resulting parameters to be used by the transform mapper.</returns>
|
||||
public delegate TResult Accessor<TResult>(in T shader);
|
||||
}
|
||||
@@ -61,14 +61,23 @@ internal abstract class D2D1TransformMapper
|
||||
/// </summary>
|
||||
/// <param name="transformMapper">The <see cref="ID2D1TransformMapper{T}"/> instance to usse, if there is one.</param>
|
||||
/// <returns>A new <see cref="For{T}"/> instance wrapping <paramref name="transformMapper"/>, or <see langword="null"/>.</returns>
|
||||
public static For<T>? Get(ID2D1TransformMapper<T>? transformMapper)
|
||||
public static D2D1TransformMapper? Get(ID2D1TransformMapper<T>? transformMapper)
|
||||
{
|
||||
if (transformMapper is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new(transformMapper);
|
||||
// If one of the built-in transform mapper factories from D2D1TransformMapperFactory<T> was used,
|
||||
// the returned ID2D1TransformMapper<T> instance will already inherit from D2D1TransformMapper.
|
||||
// If that's the case, that object can be returned directly, saving one allocation and avoiding
|
||||
// an extra interface stub dispatch call every time one of the transform mapping APIs is called.
|
||||
if (transformMapper is D2D1TransformMapper d2D1TransformMapper)
|
||||
{
|
||||
return d2D1TransformMapper;
|
||||
}
|
||||
|
||||
return new For<T>(transformMapper);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -93,4 +102,32 @@ internal abstract class D2D1TransformMapper
|
||||
this.transformMapper.MapInvalidOutput(inputIndex, invalidInput, out invalidOutput);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A generic <see cref="ID2D1TransformMapperFactory{T}"/> implementation for a mapper with a parameterless constructor.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of D2D1 pixel shader to register.</typeparam>
|
||||
/// <typeparam name="TMapper">The type of <see cref="ID2D1TransformMapper{T}"/> implementation to register.</typeparam>
|
||||
public sealed class FactoryOf<T, TMapper> : ID2D1TransformMapperFactory<T>
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
where TMapper : class, ID2D1TransformMapper<T>, new()
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="FactoryOf{T, TMapper}"/> instance.
|
||||
/// </summary>
|
||||
private FactoryOf()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the shared <see cref="FactoryOf{T, TMapper}"/> instance for a given transform mapper.
|
||||
/// </summary>
|
||||
public static FactoryOf<T, TMapper> Instance { get; } = new();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public ID2D1TransformMapper<T> Create()
|
||||
{
|
||||
return new TMapper();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,14 +107,14 @@ internal unsafe partial struct PixelShaderEffect
|
||||
/// <summary>
|
||||
/// The factory of <see cref="ID2D1TransformMapper{T}"/> instances to use for each created effect.
|
||||
/// </summary>
|
||||
private static Func<ID2D1TransformMapper<T>>? d2D1DrawTransformMapperFactory;
|
||||
private static ID2D1TransformMapperFactory<T>? d2D1DrawTransformMapperFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the <see cref="For{T}"/> shared state.
|
||||
/// </summary>
|
||||
/// <param name="d2D1DrawTransformMapperFactory">The factory of <see cref="ID2D1TransformMapper{T}"/> instances to use for each created effect.</param>
|
||||
/// <exception cref="InvalidOperationException">Thrown if initialization is attempted with a mismatched transform factory.</exception>
|
||||
public static void Initialize(Func<ID2D1TransformMapper<T>>? d2D1DrawTransformMapperFactory)
|
||||
public static void Initialize(ID2D1TransformMapperFactory<T>? d2D1DrawTransformMapperFactory)
|
||||
{
|
||||
// This conceptually acts as a static constructor, and this type is
|
||||
// internal, so in this very specific case locking on the type is fine.
|
||||
@@ -253,7 +253,7 @@ internal unsafe partial struct PixelShaderEffect
|
||||
// and managed exceptions should never cross the ABI boundary. If it throws, just return the HRESULT.
|
||||
try
|
||||
{
|
||||
ID2D1TransformMapper<T>? d2D1DrawTransformMapper = d2D1DrawTransformMapperFactory?.Invoke();
|
||||
ID2D1TransformMapper<T>? d2D1DrawTransformMapper = d2D1DrawTransformMapperFactory?.Create();
|
||||
|
||||
d2D1TransformMapper = D2D1TransformMapper.For<T>.Get(d2D1DrawTransformMapper);
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
namespace ComputeSharp.D2D1.Shaders.Interop.Factories.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// A base type for a transform mapper factory to be used in a D2D1 pixel shader effect.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of D2D1 pixel shader associated to the transform mapper.</typeparam>
|
||||
/// <typeparam name="TParameters">The type of parameters that the transform mapper will use.</typeparam>
|
||||
/// <typeparam name="TTransformMapper">The type of concrete transform mapper to produce from this factory.</typeparam>
|
||||
internal abstract class D2D1TransformMapperFactory<T, TParameters, TTransformMapper> : ID2D1TransformMapperFactory<T>
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
where TParameters : unmanaged
|
||||
where TTransformMapper : D2D1TransformMapper<T, TParameters>, new()
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
ID2D1TransformMapper<T> ID2D1TransformMapperFactory<T>.Create()
|
||||
{
|
||||
return new TTransformMapper { ParametersAccessor = ParametersAccessor };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D2D1TransformMapperParametersAccessor{T, TParameters}"/> instance to use to retrieve parameters for the transform mapper.
|
||||
/// </summary>
|
||||
public D2D1TransformMapperParametersAccessor<T, TParameters>? ParametersAccessor { get; init; }
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
namespace ComputeSharp.D2D1.Shaders.Interop.Factories.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// A base type for an accessor of parameters to be used in D2D1 transform mapping implementations.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of D2D1 pixel shader associated to the transform mapper.</typeparam>
|
||||
/// <typeparam name="TParameters">The type of parameters that the transform mapper will use.</typeparam>
|
||||
internal abstract class D2D1TransformMapperParametersAccessor<T, TParameters>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the parameters to be used by the transform mapper.
|
||||
/// </summary>
|
||||
/// <param name="shader">The input D2D1 pixel shader being executed on the current effect (this can be used to retrieve shader properties).</param>
|
||||
/// <returns>The resulting parameters to be used by the transform mapper.</returns>
|
||||
public abstract TParameters Get(in T shader);
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.D2D1.Interop.Effects;
|
||||
using ComputeSharp.D2D1.Shaders.Interop.Helpers;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp.D2D1.Shaders.Interop.Factories.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// A base type for a transform mapper to be used in a D2D1 pixel shader effect.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of D2D1 pixel shader associated to the transform mapper.</typeparam>
|
||||
/// <typeparam name="TParameters">The type of parameters that the transform mapper will use.</typeparam>
|
||||
internal abstract class D2D1TransformMapper<T, TParameters> : D2D1TransformMapper, ID2D1TransformMapper<T>
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
where TParameters : unmanaged
|
||||
{
|
||||
/// <summary>
|
||||
/// The parameters to use in this transform mapper.
|
||||
/// </summary>
|
||||
private TParameters parameters;
|
||||
|
||||
/// <inheritdoc cref="D2D1TransformMapperFactory{T, TParameters, TTransformMapper}.ParametersAccessor"/>
|
||||
public D2D1TransformMapperParametersAccessor<T, TParameters>? ParametersAccessor { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Transforms an input rectangle to an output rectangle.
|
||||
/// </summary>
|
||||
/// <param name="parameters">The parameters to be used to inform the transformation.</param>
|
||||
/// <param name="rectangle">The input rectangle to transform to output.</param>
|
||||
protected abstract void TransformInputToOutput(in TParameters parameters, ref Rectangle64 rectangle);
|
||||
|
||||
/// <summary>
|
||||
/// Transforms an output rectangle to an input rectangle.
|
||||
/// </summary>
|
||||
/// <param name="parameters">The parameters to be used to inform the transformation.</param>
|
||||
/// <param name="rectangle">The output rectangle to transform to input.</param>
|
||||
protected abstract void TransformOutputToInput(in TParameters parameters, ref Rectangle64 rectangle);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void MapInputsToOutput(ReadOnlySpan<byte> buffer, ReadOnlySpan<Rectangle> inputs, ReadOnlySpan<Rectangle> opaqueInputs, out Rectangle output, out Rectangle opaqueOutput)
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
shader.InitializeFromDispatchData(buffer);
|
||||
|
||||
MapInputsToOutput(in shader, inputs, opaqueInputs, out output, out opaqueOutput);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void MapOutputToInputs(in Rectangle output, Span<Rectangle> inputs)
|
||||
{
|
||||
Rectangle64 output64 = Rectangle64.FromRectangle(output);
|
||||
|
||||
TransformOutputToInput(in this.parameters, ref output64);
|
||||
|
||||
inputs.Fill(output64.ToRectangleWithD2D1LogicallyInfiniteClamping());
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void MapInvalidOutput(int inputIndex, Rectangle invalidInput, out Rectangle invalidOutput)
|
||||
{
|
||||
Rectangle64 output64 = Rectangle64.FromRectangle(invalidInput);
|
||||
|
||||
TransformInputToOutput(in this.parameters, ref output64);
|
||||
|
||||
invalidOutput = output64.ToRectangleWithD2D1LogicallyInfiniteClamping();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void MapInputsToOutput(in T shader, ReadOnlySpan<Rectangle> inputs, ReadOnlySpan<Rectangle> opaqueInputs, out Rectangle output, out Rectangle opaqueOutput)
|
||||
{
|
||||
this.parameters = ParametersAccessor!.Get(in shader);
|
||||
|
||||
if (inputs.IsEmpty)
|
||||
{
|
||||
Unsafe.SkipInit(out output);
|
||||
|
||||
output.ToD2D1Infinite();
|
||||
opaqueOutput = Rectangle.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
Rectangle64 output64 = Rectangle64.Empty;
|
||||
|
||||
foreach (ref readonly Rectangle input in inputs)
|
||||
{
|
||||
output64.Union(Rectangle64.FromRectangle(input));
|
||||
}
|
||||
|
||||
TransformInputToOutput(in this.parameters, ref output64);
|
||||
|
||||
output = output64.ToRectangleWithD2D1LogicallyInfiniteClamping();
|
||||
opaqueOutput = Rectangle.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
using ComputeSharp.D2D1.Shaders.Interop.Factories.Abstract;
|
||||
using ComputeSharp.D2D1.Shaders.Interop.Helpers;
|
||||
|
||||
namespace ComputeSharp.D2D1.Shaders.Interop.Factories;
|
||||
|
||||
/// <summary>
|
||||
/// A container for shader-specific affine transform mapper factory.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This non-generic type is used so that <see cref="Transform"/> and <see cref="SubtractAndClampToMaxIfOverflow"/> are not recompiled for each generic type instantiation.
|
||||
/// </remarks>
|
||||
internal sealed class D2D1AffineTransformMapperFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Transforms a target rectangle using a given transform matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">The transform matrix to use.</param>
|
||||
/// <param name="rectangle">The rectangle to transform.</param>
|
||||
private static void Transform(in Matrix3x2 matrix, ref Rectangle64 rectangle)
|
||||
{
|
||||
// Get the rectangle corners
|
||||
Point64 topLeft = new(rectangle.Left, rectangle.Top);
|
||||
Point64 topRight = new(rectangle.Right, rectangle.Top);
|
||||
Point64 bottomLeft = new(rectangle.Left, rectangle.Bottom);
|
||||
Point64 bottomRight = new(rectangle.Right, rectangle.Bottom);
|
||||
|
||||
// Transform them with the current matrix
|
||||
var transformedTopLeft = topLeft.Transform(in matrix);
|
||||
var transformedTopRight = topRight.Transform(in matrix);
|
||||
var transformedBottomLeft = bottomLeft.Transform(in matrix);
|
||||
var transformedBottomRight = bottomRight.Transform(in matrix);
|
||||
|
||||
// Calculate the bounding box of the transformed points
|
||||
double transformedLeft = Math.Min(Math.Min(transformedTopLeft.X, transformedTopRight.X), Math.Min(transformedBottomLeft.X, transformedBottomRight.X));
|
||||
double transformedTop = Math.Min(Math.Min(transformedTopLeft.Y, transformedTopRight.Y), Math.Min(transformedBottomLeft.Y, transformedBottomRight.Y));
|
||||
double transformedRight = Math.Max(Math.Max(transformedTopLeft.X, transformedTopRight.X), Math.Max(transformedBottomLeft.X, transformedBottomRight.X));
|
||||
double transformedBottom = Math.Max(Math.Max(transformedTopLeft.Y, transformedTopRight.Y), Math.Max(transformedBottomLeft.Y, transformedBottomRight.Y));
|
||||
|
||||
// Round each coordinate as needed and compute the rectangle bounds
|
||||
long left = (long)Math.Floor(Math.Max(transformedLeft, long.MinValue));
|
||||
long top = (long)Math.Floor(Math.Max(transformedTop, long.MinValue));
|
||||
long right = (long)Math.Ceiling(Math.Min(transformedRight, long.MaxValue));
|
||||
long bottom = (long)Math.Ceiling(Math.Min(transformedBottom, long.MaxValue));
|
||||
|
||||
// Calculate the width and height, with clamping in case of overflows
|
||||
long width = SubtractAndClampToMaxIfOverflow(right, left);
|
||||
long height = SubtractAndClampToMaxIfOverflow(bottom, top);
|
||||
|
||||
rectangle = new(left, top, width, height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts two values and clamps to <see cref="long.MaxValue"/> if there is an overflow.
|
||||
/// </summary>
|
||||
/// <param name="x">The first value.</param>
|
||||
/// <param name="y">The value to subtract.</param>
|
||||
/// <returns>The result of the subtraction, clamped to <see cref="long.MaxValue"/>.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static long SubtractAndClampToMaxIfOverflow(long x, long y)
|
||||
{
|
||||
long z = unchecked(x - y);
|
||||
|
||||
// Overflow in (x - y) with carry occurs if and only if x and y have opposite signs
|
||||
// and the sign of (x - y) with carry is opposite of x (or equivalently same as y).
|
||||
if (((x ^ y) & (z ^ x)) < 0)
|
||||
{
|
||||
return long.MaxValue;
|
||||
}
|
||||
|
||||
return z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A custom <see cref="D2D1TransformMapperFactory{T, TParameters, TTransformMapper}"/> implementation for an affine transform.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of D2D1 pixel shader associated to the transform mapper.</typeparam>
|
||||
public sealed class For<T> : D2D1TransformMapperFactory<T, Matrix3x2, For<T>.TransformMapper>
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="D2D1TransformMapperParametersAccessor{T, TParameters}"/> implementation for a constant affine transform matrix.
|
||||
/// </summary>
|
||||
public sealed class ConstantMatrix : D2D1TransformMapperParametersAccessor<T, Matrix3x2>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the fixed affine transform matrix.
|
||||
/// </summary>
|
||||
public Matrix3x2 Amount { get; init; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Matrix3x2 Get(in T shader)
|
||||
{
|
||||
return Amount;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="D2D1TransformMapperParametersAccessor{T, TParameters}"/> implementation for a dynamic affine transform matrix.
|
||||
/// </summary>
|
||||
public sealed class DynamicMatrix : D2D1TransformMapperParametersAccessor<T, Matrix3x2>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="D2D1TransformMapperFactory{T}.Accessor{TResult}"/> instance to get the dynamic affine transform matrix.
|
||||
/// </summary>
|
||||
public D2D1TransformMapperFactory<T>.Accessor<Matrix3x2>? Accessor { get; init; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Matrix3x2 Get(in T shader)
|
||||
{
|
||||
return Accessor!(in shader);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A custom <see cref="D2D1TransformMapper{T, TParameters}"/> implementation for an affine transform.
|
||||
/// </summary>
|
||||
public sealed class TransformMapper : D2D1TransformMapper<T, Matrix3x2>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override void TransformInputToOutput(in Matrix3x2 parameters, ref Rectangle64 rectangle)
|
||||
{
|
||||
Transform(in parameters, ref rectangle);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void TransformOutputToInput(in Matrix3x2 parameters, ref Rectangle64 rectangle)
|
||||
{
|
||||
if (!Matrix3x2.Invert(parameters, out Matrix3x2 matrix))
|
||||
{
|
||||
static void Throw()
|
||||
{
|
||||
throw new ArgumentException("The input transform matrix can't be inverted, so it can't be used for a transform mapper.");
|
||||
}
|
||||
|
||||
Throw();
|
||||
}
|
||||
|
||||
Transform(in matrix, ref rectangle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
using ComputeSharp.D2D1.Shaders.Interop.Factories.Abstract;
|
||||
using ComputeSharp.D2D1.Shaders.Interop.Helpers;
|
||||
|
||||
namespace ComputeSharp.D2D1.Shaders.Interop.Factories;
|
||||
|
||||
/// <summary>
|
||||
/// A custom <see cref="D2D1TransformMapperFactory{T, TParameters, TTransformMapper}"/> implementation for an inflate transform.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of D2D1 pixel shader associated to the transform mapper.</typeparam>
|
||||
internal sealed class D2D1InflateTransformMapperFactory<T> : D2D1TransformMapperFactory<T, (int, int, int, int), D2D1InflateTransformMapperFactory<T>.TransformMapper>
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="D2D1TransformMapperParametersAccessor{T, TParameters}"/> implementation for a constant inflate amount.
|
||||
/// </summary>
|
||||
public sealed class ConstantAmount : D2D1TransformMapperParametersAccessor<T, (int, int, int, int)>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the fixed inflate amount.
|
||||
/// </summary>
|
||||
public int Amount { get; init; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override (int, int, int, int) Get(in T shader)
|
||||
{
|
||||
return (Amount, Amount, Amount, Amount);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="D2D1TransformMapperParametersAccessor{T, TParameters}"/> implementation for a constant inflate LTRB amount.
|
||||
/// </summary>
|
||||
public sealed class ConstantLeftTopRightBottomAmount : D2D1TransformMapperParametersAccessor<T, (int, int, int, int)>
|
||||
{
|
||||
/// <summary>
|
||||
/// The constant left inflate amount.
|
||||
/// </summary>
|
||||
public int Left { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The constant top inflate amount.
|
||||
/// </summary>
|
||||
public int Top { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The constant right inflate amount.
|
||||
/// </summary>
|
||||
public int Right { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The constant bottom inflate amount.
|
||||
/// </summary>
|
||||
public int Bottom { get; init; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override (int, int, int, int) Get(in T shader)
|
||||
{
|
||||
return (Left, Top, Right, Bottom);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="D2D1TransformMapperParametersAccessor{T, TParameters}"/> implementation for a dynamic inflate amount.
|
||||
/// </summary>
|
||||
public sealed class DynamicAmount : D2D1TransformMapperParametersAccessor<T, (int, int, int, int)>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="D2D1TransformMapperFactory{T}.Accessor{TResult}"/> instance to get the dynamic inflate amount.
|
||||
/// </summary>
|
||||
public D2D1TransformMapperFactory<T>.Accessor<int>? Accessor { get; init; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override (int, int, int, int) Get(in T shader)
|
||||
{
|
||||
int amount = Accessor!(in shader);
|
||||
|
||||
return (amount, amount, amount, amount);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="D2D1TransformMapperParametersAccessor{T, TParameters}"/> implementation for a dynamic inflate LTRB amount.
|
||||
/// </summary>
|
||||
public sealed class DynamicLeftTopRightBottomAmount : D2D1TransformMapperParametersAccessor<T, (int, int, int, int)>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="D2D1TransformMapperFactory{T}.Accessor{TResult}"/> instance to get the dynamic inflate LTRB amount.
|
||||
/// </summary>
|
||||
public D2D1TransformMapperFactory<T>.Accessor<(int, int, int, int)>? Accessor { get; init; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override (int, int, int, int) Get(in T shader)
|
||||
{
|
||||
return Accessor!(in shader);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A custom <see cref="D2D1TransformMapper{T, TParameters}"/> implementation for an inflate transform.
|
||||
/// </summary>
|
||||
public sealed class TransformMapper : D2D1TransformMapper<T, (int Left, int Top, int Right, int Bottom)>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override void TransformInputToOutput(in (int Left, int Top, int Right, int Bottom) parameters, ref Rectangle64 rectangle)
|
||||
{
|
||||
rectangle.Inflate(parameters.Left, parameters.Top, parameters.Right, parameters.Bottom);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void TransformOutputToInput(in (int Left, int Top, int Right, int Bottom) parameters, ref Rectangle64 rectangle)
|
||||
{
|
||||
rectangle.Inflate(parameters.Left, parameters.Top, parameters.Right, parameters.Bottom);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace ComputeSharp.D2D1.Shaders.Interop.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// A 64-bit version of the <see cref="Point"/> type.
|
||||
/// </summary>
|
||||
internal struct Point64
|
||||
{
|
||||
/// <summary>
|
||||
/// The left coordinate of the current point.
|
||||
/// </summary>
|
||||
private long x;
|
||||
|
||||
/// <summary>
|
||||
/// The top coordinate of the current point.
|
||||
/// </summary>
|
||||
private long y;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Point64"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The horizontal coordinate of the point.</param>
|
||||
/// <param name="y">The vertical coordinate of the point.</param>
|
||||
public Point64(long x, long y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the horizontal coordinate of the current point.
|
||||
/// </summary>
|
||||
public readonly long X
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => this.x;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the vertical coordinate of the current point.
|
||||
/// </summary>
|
||||
public readonly long Y
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => this.y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transforms the current point using an input matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">The transformation matrix to use.</param>
|
||||
/// <returns>The transformed points, with no rounding.</returns>
|
||||
public (double X, double Y) Transform(in Matrix3x2 matrix)
|
||||
{
|
||||
// A 3x2 transformation matrix can be thought of a 2x2 matrix with an extra
|
||||
// 1x2 row representing absolute offsets. As such, these do not compute into
|
||||
// the actual cross product with the point (which would not be doable otherwise).
|
||||
//
|
||||
// Consider a 3x2 matrix as follows:
|
||||
//
|
||||
// [ M11 , M12 ]
|
||||
// [ M21 , M22 ]
|
||||
// [ OffsetX (M31), OffsetY (M32) ]
|
||||
//
|
||||
// We first transform the point by doint the cross product with the 2x2 sub-matrix:
|
||||
//
|
||||
// [ M11, M12 ]
|
||||
// [ x, y] [ M21, M22 ] = [ x * M11 + y * M21, x * M12 + y * M22]
|
||||
//
|
||||
// Then we sum the absolute offsets, which results in the following formula:
|
||||
//
|
||||
// [ M11, M12 ]
|
||||
// [ M21, M22 ]
|
||||
// [ x, y] [ M31, M32 ] = [ x * M11 + y * M21 + M31, x * M12 + y * M22 + m32]
|
||||
return (
|
||||
Math.Round((double)this.x * matrix.M11 + (double)this.y * matrix.M21 + matrix.M31),
|
||||
Math.Round((double)this.x * matrix.M12 + (double)this.y * matrix.M22 + matrix.M32));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace ComputeSharp.D2D1.Shaders.Interop.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// A 64-bit version of the <see cref="Rectangle"/> type.
|
||||
/// </summary>
|
||||
internal struct Rectangle64
|
||||
{
|
||||
/// <summary>
|
||||
/// The left coordinate of the current rectangle.
|
||||
/// </summary>
|
||||
private long x;
|
||||
|
||||
/// <summary>
|
||||
/// The top coordinate of the current rectangle.
|
||||
/// </summary>
|
||||
private long y;
|
||||
|
||||
/// <summary>
|
||||
/// The width of the current rectangle.
|
||||
/// </summary>
|
||||
private long width;
|
||||
|
||||
/// <summary>
|
||||
/// The height of the current rectangle.
|
||||
/// </summary>
|
||||
private long height;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Rectangle64"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The left coordinate of the rectangle.</param>
|
||||
/// <param name="y">The top coordinate of the rectangle.</param>
|
||||
/// <param name="width">The width of the rectangle.</param>
|
||||
/// <param name="height">The height of the rectangle.</param>
|
||||
public Rectangle64(long x, long y, long width, long height)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the left coordinate of the current rectangle.
|
||||
/// </summary>
|
||||
public readonly long Left
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => this.x;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the top coordinate of the current rectangle.
|
||||
/// </summary>
|
||||
public readonly long Top
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => this.y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the right coordinate of the current rectangle.
|
||||
/// </summary>
|
||||
public readonly long Right
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => this.x + this.width;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the bottom coordinate of the current rectangle.
|
||||
/// </summary>
|
||||
public readonly long Bottom
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => this.y + this.height;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Rectangle64"/> instance representing an empty rectangle.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The returned instance is such that computing the union of it with any other rectangle yields the other
|
||||
/// rectangle, and computing the intersection of it with any other rectangle yields the empty rectangle.
|
||||
/// </remarks>
|
||||
public static Rectangle64 Empty => new(long.MaxValue, long.MaxValue, long.MinValue, long.MinValue);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the current rectangle to be the union of itself and a given input rectangle.
|
||||
/// </summary>
|
||||
/// <param name="rectangle">The input <see cref="Rectangle64"/> instance to compute the union with.</param>
|
||||
public void Union(Rectangle64 rectangle)
|
||||
{
|
||||
long left = Math.Min(this.Left, rectangle.Left);
|
||||
long top = Math.Min(this.Top, rectangle.Top);
|
||||
long right = Math.Max(this.Right, rectangle.Right);
|
||||
long bottom = Math.Max(this.Bottom, rectangle.Bottom);
|
||||
|
||||
this.x = left;
|
||||
this.y = top;
|
||||
this.width = right - left;
|
||||
this.height = bottom - top;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the current rectangle to be the intersection of itself and a given input rectangle.
|
||||
/// </summary>
|
||||
/// <param name="rectangle">The input <see cref="Rectangle64"/> instance to compute the intersection with.</param>
|
||||
public void Intersect(Rectangle64 rectangle)
|
||||
{
|
||||
long left = Math.Max(this.x, rectangle.x);
|
||||
long top = Math.Max(this.y, rectangle.y);
|
||||
long right = Math.Min(this.Right, rectangle.Right);
|
||||
long bottom = Math.Min(this.Bottom, rectangle.Bottom);
|
||||
|
||||
this.x = left;
|
||||
this.y = top;
|
||||
this.width = Math.Max(right - left, 0);
|
||||
this.height = Math.Max(bottom - top, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inflates the current rectangle by a specified amount.
|
||||
/// </summary>
|
||||
/// <param name="left">The amount fo use to inflate the left edge.</param>
|
||||
/// <param name="top"></param>
|
||||
/// <param name="right"></param>
|
||||
/// <param name="bottom"></param>
|
||||
public void Inflate(long left, long top, long right, long bottom)
|
||||
{
|
||||
this.x -= left;
|
||||
this.y -= top;
|
||||
this.width += left + right;
|
||||
this.height += top + bottom;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Rectangle"/> from the current <see cref="Rectangle64"/> instance, clamping to a D2D1 logically infinite rectangle.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="Rectangle"/> equivalent of the current instance.</returns>
|
||||
public Rectangle ToRectangleWithD2D1LogicallyInfiniteClamping()
|
||||
{
|
||||
Intersect(new Rectangle64(int.MinValue / 2, int.MinValue / 2, int.MaxValue, int.MaxValue));
|
||||
|
||||
return new((int)this.x, (int)this.y, (int)this.width, (int)this.height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Rectangle64"/> instance from an input <see cref="Rectangle"/> value.
|
||||
/// </summary>
|
||||
/// <param name="rectangle">The input <see cref="Rectangle"/> value.</param>
|
||||
/// <returns>The resulting <see cref="Rectangle64"/> instance representing <paramref name="rectangle"/>.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Rectangle64 FromRectangle(Rectangle rectangle)
|
||||
{
|
||||
return new(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
|
||||
}
|
||||
}
|
||||
バイナリファイルは表示されません。
|
変更前 幅: | 高さ: | サイズ: 24 KiB 変更後 幅: | 高さ: | サイズ: 88 KiB |
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
using ComputeSharp.D2D1.Tests.Effects;
|
||||
using ComputeSharp.D2D1.Tests.Helpers;
|
||||
@@ -24,14 +25,37 @@ public partial class D2D1PixelShaderEffectTests
|
||||
[ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes = false)]
|
||||
public unsafe void RegisterForD2D1Factory1_WithTransformMapper_NullD2D1Factory1()
|
||||
{
|
||||
D2D1PixelShaderEffect.RegisterForD2D1Factory1<PixelateEffect.Shader, PixelateEffect>(null, out _);
|
||||
D2D1PixelShaderEffect.RegisterForD2D1Factory1<DummyTransformMapper.Shader, DummyTransformMapper>(null, out _);
|
||||
}
|
||||
|
||||
public sealed partial class DummyTransformMapper : ID2D1TransformMapper<DummyTransformMapper.Shader>
|
||||
{
|
||||
public void MapInputsToOutput(in Shader shader, ReadOnlySpan<Rectangle> inputs, ReadOnlySpan<Rectangle> opaqueInputs, out Rectangle output, out Rectangle opaqueOutput)
|
||||
{
|
||||
output = default;
|
||||
opaqueOutput = default;
|
||||
}
|
||||
|
||||
public void MapInvalidOutput(int inputIndex, Rectangle invalidInput, out Rectangle invalidOutput)
|
||||
{
|
||||
invalidOutput = default;
|
||||
}
|
||||
|
||||
public void MapOutputToInputs(in Rectangle output, Span<Rectangle> inputs)
|
||||
{
|
||||
}
|
||||
|
||||
public partial struct Shader : ID2D1PixelShader
|
||||
{
|
||||
public float4 Execute() => default;
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes = false)]
|
||||
public unsafe void RegisterForD2D1Factory1_WithTransformMapperFactory_NullD2D1Factory1()
|
||||
{
|
||||
D2D1PixelShaderEffect.RegisterForD2D1Factory1(null, () => new PixelateEffect(), out _);
|
||||
D2D1PixelShaderEffect.RegisterForD2D1Factory1<PixelateEffect>(null, null, out _);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
@@ -15,7 +15,7 @@ public partial class D2D1PixelShaderTests
|
||||
public unsafe void GetInputCount()
|
||||
{
|
||||
Assert.AreEqual(D2D1PixelShader.GetInputCount<InvertEffect>(), 1);
|
||||
Assert.AreEqual(D2D1PixelShader.GetInputCount<PixelateEffect.Shader>(), 1);
|
||||
Assert.AreEqual(D2D1PixelShader.GetInputCount<PixelateEffect>(), 1);
|
||||
Assert.AreEqual(D2D1PixelShader.GetInputCount<ZonePlateEffect>(), 0);
|
||||
Assert.AreEqual(D2D1PixelShader.GetInputCount<ShaderWithMultipleInputs>(), 7);
|
||||
}
|
||||
@@ -109,7 +109,7 @@ public partial class D2D1PixelShaderTests
|
||||
Assert.AreEqual(D2D1PixelShader.GetInputDescriptions<CheckerboardClipEffect>().Length, 0);
|
||||
Assert.AreEqual(D2D1PixelShader.GetInputDescriptions<InvertEffect>().Length, 0);
|
||||
Assert.AreEqual(D2D1PixelShader.GetInputDescriptions<InvertWithThresholdEffect>().Length, 0);
|
||||
Assert.AreEqual(D2D1PixelShader.GetInputDescriptions<PixelateEffect.Shader>().Length, 0);
|
||||
Assert.AreEqual(D2D1PixelShader.GetInputDescriptions<PixelateEffect>().Length, 0);
|
||||
Assert.AreEqual(D2D1PixelShader.GetInputDescriptions<ZonePlateEffect>().Length, 0);
|
||||
|
||||
Assert.AreEqual(D2D1PixelShader.GetInputDescriptions<ShaderWithMultipleInputs>().Length, 0);
|
||||
@@ -175,7 +175,7 @@ public partial class D2D1PixelShaderTests
|
||||
Assert.AreEqual(D2D1PixelShader.GetResourceTextureDescriptions<CheckerboardClipEffect>().Length, 0);
|
||||
Assert.AreEqual(D2D1PixelShader.GetResourceTextureDescriptions<InvertEffect>().Length, 0);
|
||||
Assert.AreEqual(D2D1PixelShader.GetResourceTextureDescriptions<InvertWithThresholdEffect>().Length, 0);
|
||||
Assert.AreEqual(D2D1PixelShader.GetResourceTextureDescriptions<PixelateEffect.Shader>().Length, 0);
|
||||
Assert.AreEqual(D2D1PixelShader.GetResourceTextureDescriptions<PixelateEffect>().Length, 0);
|
||||
Assert.AreEqual(D2D1PixelShader.GetResourceTextureDescriptions<ZonePlateEffect>().Length, 0);
|
||||
|
||||
Assert.AreEqual(D2D1PixelShader.GetResourceTextureDescriptions<ShaderWithMultipleInputs>().Length, 0);
|
||||
|
||||
@@ -303,8 +303,8 @@ public sealed partial class BokehBlurEffect
|
||||
d2D1DeviceContext.Get()->SetRenderingControls(&d2D1RenderingControls);
|
||||
|
||||
// Register all necessary effects
|
||||
D2D1PixelShaderEffect.RegisterForD2D1Factory1(d2D1Factory2.Get(), static () => new VerticalConvolution(), out _);
|
||||
D2D1PixelShaderEffect.RegisterForD2D1Factory1(d2D1Factory2.Get(), static () => 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,35 +477,12 @@ public sealed partial class BokehBlurEffect
|
||||
/// <summary>
|
||||
/// The vertical convolution shader and transform.
|
||||
/// </summary>
|
||||
private sealed partial class VerticalConvolution : 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 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.
|
||||
@@ -547,35 +524,12 @@ public sealed partial class BokehBlurEffect
|
||||
/// <summary>
|
||||
/// The horizontal convolutin and partial accumulation effect and transform.
|
||||
/// </summary>
|
||||
private sealed partial class HorizontalConvolutionAndAccumulatePartials : 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 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.
|
||||
|
||||
@@ -1,69 +1,44 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
namespace ComputeSharp.D2D1.Tests.Effects;
|
||||
|
||||
namespace ComputeSharp.D2D1.Tests.Effects;
|
||||
|
||||
public sealed partial class PixelateEffect : ID2D1TransformMapper<PixelateEffect.Shader>
|
||||
[D2DInputCount(1)]
|
||||
[D2DInputComplex(0)]
|
||||
[D2DRequiresScenePosition]
|
||||
[D2DShaderProfile(D2D1ShaderProfile.PixelShader40)]
|
||||
[AutoConstructor]
|
||||
public partial struct PixelateEffect : ID2D1PixelShader
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
void ID2D1TransformMapper<Shader>.MapInputsToOutput(in Shader shader, ReadOnlySpan<Rectangle> inputs, ReadOnlySpan<Rectangle> opaqueInputs, out Rectangle output, out Rectangle opaqueOutput)
|
||||
{
|
||||
output = inputs[0];
|
||||
opaqueOutput = Rectangle.Empty;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
void ID2D1TransformMapper<Shader>.MapInvalidOutput(int inputIndex, Rectangle invalidInput, out Rectangle invalidOutput)
|
||||
{
|
||||
invalidOutput = invalidInput;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
void ID2D1TransformMapper<Shader>.MapOutputToInputs(in Rectangle output, Span<Rectangle> inputs)
|
||||
{
|
||||
inputs.Fill(output);
|
||||
}
|
||||
|
||||
[D2DInputCount(1)]
|
||||
[D2DInputComplex(0)]
|
||||
[D2DRequiresScenePosition]
|
||||
[D2DShaderProfile(D2D1ShaderProfile.PixelShader40)]
|
||||
[AutoConstructor]
|
||||
public partial struct Shader : ID2D1PixelShader
|
||||
public partial struct Constants
|
||||
{
|
||||
[AutoConstructor]
|
||||
public partial struct Constants
|
||||
{
|
||||
public readonly int inputWidth;
|
||||
public readonly int inputHeight;
|
||||
public readonly int cellSize;
|
||||
}
|
||||
public readonly int inputWidth;
|
||||
public readonly int inputHeight;
|
||||
public readonly int cellSize;
|
||||
}
|
||||
|
||||
private readonly Constants constants;
|
||||
private readonly Constants constants;
|
||||
|
||||
public float4 Execute()
|
||||
{
|
||||
float2 scenePos = D2D.GetScenePosition().XY;
|
||||
uint x = (uint)Hlsl.Floor(scenePos.X);
|
||||
uint y = (uint)Hlsl.Floor(scenePos.Y);
|
||||
public float4 Execute()
|
||||
{
|
||||
float2 scenePos = D2D.GetScenePosition().XY;
|
||||
uint x = (uint)Hlsl.Floor(scenePos.X);
|
||||
uint y = (uint)Hlsl.Floor(scenePos.Y);
|
||||
|
||||
int cellX = (int)Hlsl.Floor(x / this.constants.cellSize);
|
||||
int cellY = (int)Hlsl.Floor(y / this.constants.cellSize);
|
||||
int cellX = (int)Hlsl.Floor(x / this.constants.cellSize);
|
||||
int cellY = (int)Hlsl.Floor(y / this.constants.cellSize);
|
||||
|
||||
int x0 = cellX * this.constants.cellSize;
|
||||
int y0 = cellY * this.constants.cellSize;
|
||||
int x0 = cellX * this.constants.cellSize;
|
||||
int y0 = cellY * this.constants.cellSize;
|
||||
|
||||
int x1 = Hlsl.Min(this.constants.inputWidth, x0 + this.constants.cellSize) - 1;
|
||||
int y1 = Hlsl.Min(this.constants.inputHeight, y0 + this.constants.cellSize) - 1;
|
||||
int x1 = Hlsl.Min(this.constants.inputWidth, x0 + this.constants.cellSize) - 1;
|
||||
int y1 = Hlsl.Min(this.constants.inputHeight, y0 + this.constants.cellSize) - 1;
|
||||
|
||||
float4 sample0 = D2D.SampleInputAtPosition(0, new int2(x0, y0));
|
||||
float4 sample1 = D2D.SampleInputAtPosition(0, new int2(x1, y0));
|
||||
float4 sample2 = D2D.SampleInputAtPosition(0, new int2(x0, y1));
|
||||
float4 sample3 = D2D.SampleInputAtPosition(0, new int2(x1, y1));
|
||||
float4 sample0 = D2D.SampleInputAtPosition(0, new float2(x0 + 0.5f, y0 + 0.5f));
|
||||
float4 sample1 = D2D.SampleInputAtPosition(0, new float2(x1 + 0.5f, y0 + 0.5f));
|
||||
float4 sample2 = D2D.SampleInputAtPosition(0, new float2(x0 + 0.5f, y1 + 0.5f));
|
||||
float4 sample3 = D2D.SampleInputAtPosition(0, new float2(x1 + 0.5f, y1 + 0.5f));
|
||||
|
||||
float4 color = (sample0 + sample1 + sample2 + sample3) / 4;
|
||||
float4 color = (sample0 + sample1 + sample2 + sample3) / 4;
|
||||
|
||||
return color;
|
||||
}
|
||||
return color;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using ComputeSharp.BokehBlur.Processors;
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
using ComputeSharp.D2D1.Tests.Effects;
|
||||
using ComputeSharp.D2D1.Tests.Helpers;
|
||||
using ComputeSharp.Tests.Helpers;
|
||||
@@ -37,8 +38,8 @@ public class EndToEndTests
|
||||
public unsafe void Pixelate()
|
||||
{
|
||||
D2D1TestRunner.RunAndCompareShader(
|
||||
new PixelateEffect.Shader(new PixelateEffect.Shader.Constants(1280, 840, 16)),
|
||||
static () => new PixelateEffect(),
|
||||
new PixelateEffect(new PixelateEffect.Constants(1280, 840, 16)),
|
||||
D2D1TransformMapperFactory<PixelateEffect>.Inflate(16),
|
||||
"Landscape.png",
|
||||
"Landscape_Pixelate.png");
|
||||
}
|
||||
@@ -46,7 +47,7 @@ public class EndToEndTests
|
||||
[TestMethod]
|
||||
public unsafe void ZonePlate()
|
||||
{
|
||||
D2D1TestRunner.RunAndCompareShader(new ZonePlateEffect(1280, 720, 800), null, 1280, 720, "ZonePlate.png");
|
||||
D2D1TestRunner.RunAndCompareShader(new ZonePlateEffect(1280, 720, 800), 1280, 720, "ZonePlate.png");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
@@ -25,7 +25,7 @@ internal static class D2D1TestRunner
|
||||
/// <param name="shader">The shader to run.</param>
|
||||
public static void RunAndCompareShader<T>(
|
||||
in T shader,
|
||||
Func<ID2D1TransformMapper<T>>? transformMapperFactory,
|
||||
ID2D1TransformMapperFactory<T>? transformMapperFactory,
|
||||
string originalFileName,
|
||||
string expectedFileName,
|
||||
[CallerMemberName] string destinationFileName = "")
|
||||
@@ -55,7 +55,6 @@ internal static class D2D1TestRunner
|
||||
/// Executes a pixel shader and compares the expected results.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of pixel shader to run.</typeparam>
|
||||
/// <param name="transformMapperFactory">A custom <see cref="ID2D1TransformMapper{T}"/> factory for the effect.</param>
|
||||
/// <param name="width">The resulting width.</param>
|
||||
/// <param name="height">The resulting height.</param>
|
||||
/// <param name="expectedFileName">The name of the expected result image.</param>
|
||||
@@ -63,7 +62,6 @@ internal static class D2D1TestRunner
|
||||
/// <param name="shader">The shader to run.</param>
|
||||
public static void RunAndCompareShader<T>(
|
||||
in T shader,
|
||||
Func<ID2D1TransformMapper<T>>? transformMapperFactory,
|
||||
int width,
|
||||
int height,
|
||||
string expectedFileName,
|
||||
@@ -81,7 +79,7 @@ internal static class D2D1TestRunner
|
||||
// Run the shader
|
||||
ExecutePixelShaderAndSaveToFile(
|
||||
in shader,
|
||||
transformMapperFactory,
|
||||
null,
|
||||
width,
|
||||
height,
|
||||
destinationPath);
|
||||
@@ -98,9 +96,9 @@ internal static class D2D1TestRunner
|
||||
/// <param name="transformMapperFactory">A custom <see cref="ID2D1TransformMapper{T}"/> factory for the effect.</param>
|
||||
/// <param name="sourcePath">The source path for the image to run the shader on.</param>
|
||||
/// <param name="destinationPath">The destination path for the result.</param>
|
||||
public static unsafe void ExecutePixelShaderAndSaveToFile<T>(
|
||||
private static unsafe void ExecutePixelShaderAndSaveToFile<T>(
|
||||
in T shader,
|
||||
Func<ID2D1TransformMapper<T>>? transformMapperFactory,
|
||||
ID2D1TransformMapperFactory<T>? transformMapperFactory,
|
||||
string sourcePath,
|
||||
string destinationPath)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
@@ -139,9 +137,9 @@ internal static class D2D1TestRunner
|
||||
/// <param name="height">The resulting height.</param>
|
||||
/// <param name="transformMapperFactory">A custom <see cref="ID2D1TransformMapper{T}"/> factory for the effect.</param>
|
||||
/// <param name="destinationPath">The destination path for the result.</param>
|
||||
public static unsafe void ExecutePixelShaderAndSaveToFile<T>(
|
||||
private static unsafe void ExecutePixelShaderAndSaveToFile<T>(
|
||||
in T shader,
|
||||
Func<ID2D1TransformMapper<T>>? transformMapperFactory,
|
||||
ID2D1TransformMapperFactory<T>? transformMapperFactory,
|
||||
int width,
|
||||
int height,
|
||||
string destinationPath)
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする