Move transform mapper factory methods into same type

Simplify names
このコミットが含まれているのは:
Sergio Pedri committed 2023-12-14 16:43:50 +01:00
1 親 d6ed7dd696
コミット 726bac4818
7ファイル変更
+19 -22

検索条件に一致するファイルはありません

@@ -1,16 +1,11 @@
using System;
using System.Numerics;
using ComputeSharp.D2D1.Descriptors;
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, ID2D1PixelShaderDescriptor<T>
/// <inheritdoc cref="D2D1TransformMapper{T}"/>
partial class D2D1TransformMapper<T>
{
/// <summary>
/// Creates an <see cref="D2D1TransformMapper{T}"/> instance for an inflate transform.
@@ -40,6 +35,7 @@ public static class D2D1TransformMapperFactory<T>
/// </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="D2D1TransformMapper{T}"/> instance for an inflate transform.</returns>
/// <exception cref="ArgumentNullException">Thrown if <paramref name="accessor"/> is <see langword="null"/>.</exception>
public static D2D1TransformMapper<T> Inflate(Accessor<int> accessor)
{
default(ArgumentNullException).ThrowIfNull(accessor);
@@ -74,6 +70,7 @@ public static class D2D1TransformMapperFactory<T>
/// </summary>
/// <param name="accessor">The input <see cref="Accessor{TResult}"/> instance to retrieve the transformation matrix to use.</param>
/// <returns>The resulting <see cref="D2D1TransformMapper{T}"/> instance for an affine transform.</returns>
/// <exception cref="ArgumentNullException">Thrown if <paramref name="accessor"/> is <see langword="null"/>.</exception>
public static D2D1TransformMapper<T> Transform(Accessor<Matrix3x2> accessor)
{
default(ArgumentNullException).ThrowIfNull(accessor);
+2 -2
ファイルの表示
@@ -86,7 +86,7 @@ namespace ComputeSharp.D2D1.Interop;
/// <para>
/// This interface is implemented by ComputeSharp.D2D1, and it can be used through the APIs in <see cref="D2D1TransformMapper{T}"/>, in several ways.
/// That is, consumers can either implement a type inheriting from <see cref="D2D1TransformMapper{T}"/> to implement their own fully customized transform
/// mapping logic, or they can use the helper methods exposed by <see cref="D2D1TransformMapperFactory{T}"/> to easily retrieve ready to use transforms.
/// mapping logic, or they can use the helper methods exposed by <see cref="D2D1TransformMapper{T}"/> to easily retrieve ready to use transforms.
/// </para>
/// <para>
/// A CCW (COM callable wrapper, see <see href="https://learn.microsoft.com/dotnet/standard/native-interop/com-callable-wrapper"/>) is also available for all
@@ -94,7 +94,7 @@ namespace ComputeSharp.D2D1.Interop;
/// <see cref="ICustomQueryInterface"/> interface, and this can then be passed to an existing D2D1 effect instance.
/// </para>
/// </remarks>
public abstract unsafe class D2D1TransformMapper<T> : ICustomQueryInterface, ID2D1TransformMapperInterop
public abstract unsafe partial class D2D1TransformMapper<T> : ICustomQueryInterface, ID2D1TransformMapperInterop
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
{
/// <summary>
+2 -2
ファイルの表示
@@ -130,9 +130,9 @@ internal abstract class D2D1AffineTransformMapper<T> : D2D1TransformMapper<T, Ma
public sealed class DynamicMatrix : D2D1AffineTransformMapper<T>
{
/// <summary>
/// Gets the <see cref="D2D1TransformMapperFactory{T}.Accessor{TResult}"/> instance to get the dynamic affine transform matrix.
/// Gets the <see cref="D2D1TransformMapper{T}.Accessor{TResult}"/> instance to get the dynamic affine transform matrix.
/// </summary>
public required D2D1TransformMapperFactory<T>.Accessor<Matrix3x2> Accessor { get; init; }
public required Accessor<Matrix3x2> Accessor { get; init; }
/// <inheritdoc/>
protected override Matrix3x2 GetParameters(D2D1DrawInfoUpdateContext<T> drawInfoUpdateContext)
+4 -4
ファイルの表示
@@ -79,9 +79,9 @@ internal abstract class D2D1InflateTransformMapper<T> : D2D1TransformMapper<T, (
public sealed class DynamicAmount : D2D1InflateTransformMapper<T>
{
/// <summary>
/// Gets the <see cref="D2D1TransformMapperFactory{T}.Accessor{TResult}"/> instance to get the dynamic inflate amount.
/// Gets the <see cref="D2D1TransformMapper{T}.Accessor{TResult}"/> instance to get the dynamic inflate amount.
/// </summary>
public required D2D1TransformMapperFactory<T>.Accessor<int> Accessor { get; init; }
public required Accessor<int> Accessor { get; init; }
/// <inheritdoc/>
protected override (int Left, int Top, int Right, int Bottom) GetParameters(D2D1DrawInfoUpdateContext<T> drawInfoUpdateContext)
@@ -98,9 +98,9 @@ internal abstract class D2D1InflateTransformMapper<T> : D2D1TransformMapper<T, (
public sealed class DynamicLeftTopRightBottomAmount : D2D1InflateTransformMapper<T>
{
/// <summary>
/// Gets the <see cref="D2D1TransformMapperFactory{T}.Accessor{TResult}"/> instance to get the dynamic inflate LTRB amount.
/// Gets the <see cref="D2D1TransformMapper{T}.Accessor{TResult}"/> instance to get the dynamic inflate LTRB amount.
/// </summary>
public required D2D1TransformMapperFactory<T>.Accessor<(int, int, int, int)> Accessor { get; init; }
public required Accessor<(int, int, int, int)> Accessor { get; init; }
/// <inheritdoc/>
protected override (int Left, int Top, int Right, int Bottom) GetParameters(D2D1DrawInfoUpdateContext<T> drawInfoUpdateContext)
+4 -4
ファイルの表示
@@ -20,7 +20,7 @@ public partial class D2D1TransformMapperTests
[TestMethod]
public unsafe void VerifyInterfaces()
{
D2D1TransformMapper<HelloWorld> transformMapper = D2D1TransformMapperFactory<HelloWorld>.Inflate(4);
D2D1TransformMapper<HelloWorld> transformMapper = D2D1TransformMapper<HelloWorld>.Inflate(4);
using ComPtr<IUnknown> unknown = default;
using ComPtr<IUnknown> transformMapper2 = default;
@@ -58,7 +58,7 @@ public partial class D2D1TransformMapperTests
D2D1PixelShaderEffect.RegisterForD2D1Factory1<DummyShader>(d2D1Factory2.Get(), out _);
D2D1TransformMapper<HelloWorld> transformMapper = D2D1TransformMapperFactory<HelloWorld>.Inflate(4);
D2D1TransformMapper<HelloWorld> transformMapper = D2D1TransformMapper<HelloWorld>.Inflate(4);
using ComPtr<IUnknown> transformMapper2 = default;
@@ -99,7 +99,7 @@ public partial class D2D1TransformMapperTests
[TestMethod]
public unsafe void VerifyManagedWrapperRetrieval()
{
D2D1TransformMapper<HelloWorld> transformMapper = D2D1TransformMapperFactory<HelloWorld>.Inflate(4);
D2D1TransformMapper<HelloWorld> transformMapper = D2D1TransformMapper<HelloWorld>.Inflate(4);
using ComPtr<IUnknown> unknown = default;
using ComPtr<IUnknown> transformMapperInternal = default;
@@ -139,7 +139,7 @@ public partial class D2D1TransformMapperTests
IUnknown** transformMapperUnknown,
out GCHandle transformMapperHandle)
{
D2D1TransformMapper<HelloWorld> transformMapper = D2D1TransformMapperFactory<HelloWorld>.Inflate(4);
D2D1TransformMapper<HelloWorld> transformMapper = D2D1TransformMapper<HelloWorld>.Inflate(4);
Guid uuidOfTransformMapper = new("02E6D48D-B892-4FBC-AA54-119203BAB802");
+2 -2
ファイルの表示
@@ -481,7 +481,7 @@ public sealed partial class BokehBlurEffect
/// <summary>
/// The <see cref="D2D1TransformMapper{T}"/> for the shader.
/// </summary>
public static D2D1TransformMapper<Shader> Transform { get; } = D2D1TransformMapperFactory<Shader>.Inflate(static (in Shader shader) => (0, shader.kernelLength, 0, shader.kernelLength));
public static D2D1TransformMapper<Shader> Transform { get; } = D2D1TransformMapper<Shader>.Inflate(static (in Shader shader) => (0, shader.kernelLength, 0, shader.kernelLength));
/// <summary>
/// Kernel for the vertical convolution pass for real or imaginary components.
@@ -528,7 +528,7 @@ public sealed partial class BokehBlurEffect
/// <summary>
/// The <see cref="D2D1TransformMapper{T}"/> for the shader.
/// </summary>
public static D2D1TransformMapper<Shader> Transform { get; } = D2D1TransformMapperFactory<Shader>.Inflate(static (in Shader shader) => (shader.kernelLength, 0, shader.kernelLength, 0));
public static D2D1TransformMapper<Shader> Transform { get; } = D2D1TransformMapper<Shader>.Inflate(static (in Shader shader) => (shader.kernelLength, 0, shader.kernelLength, 0));
/// <summary>
/// Kernel for the horizontal convolution pass.
+1 -1
ファイルの表示
@@ -49,7 +49,7 @@ public class EffectsTests
{
D2D1TestRunner.RunAndCompareShader(
new PixelateEffect(new PixelateEffect.Constants(1280, 840, 16)),
D2D1TransformMapperFactory<PixelateEffect>.Inflate(16),
D2D1TransformMapper<PixelateEffect>.Inflate(16),
"Landscape.png",
"Landscape_Pixelate.png");
}