Merge pull request #715 from Sergio0694/dev/rename-transform-mappers
Refactor D2DTransformMapper<T> APIs
このコミットが含まれているのは:
27ファイル変更
+240
-246
検索条件に一致するファイルはありません
@@ -76,17 +76,17 @@ internal static unsafe class ID2D1EffectExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="D2D1TransformMapper{T}"/> instance from a given <see cref="ID2D1Effect"/> object.
|
||||
/// Gets the <see cref="D2D1DrawTransformMapper{T}"/> instance from a given <see cref="ID2D1Effect"/> object.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of shader being used.</typeparam>
|
||||
/// <param name="d2D1Effect">The input <see cref="ID2D1Effect"/> instance.</param>
|
||||
/// <returns>The <see cref="D2D1TransformMapper{T}"/> instance for <paramref name="d2D1Effect"/>.</returns>
|
||||
public static D2D1TransformMapper<T>? GetTransformMapper<T>(this ref ID2D1Effect d2D1Effect)
|
||||
/// <returns>The <see cref="D2D1DrawTransformMapper{T}"/> instance for <paramref name="d2D1Effect"/>.</returns>
|
||||
public static D2D1DrawTransformMapper<T>? GetTransformMapper<T>(this ref ID2D1Effect d2D1Effect)
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
using ComPtr<ID2D1TransformMapper> d2D1TransformMapper = default;
|
||||
using ComPtr<ID2D1DrawTransformMapper> d2D1TransformMapper = default;
|
||||
|
||||
// Get the ID2D1TransformMapper object from the effect
|
||||
// Get the ID2D1DrawTransformMapper object from the effect
|
||||
d2D1Effect.GetValue(
|
||||
index: D2D1PixelShaderEffectProperty.TransformMapper,
|
||||
type: D2D1_PROPERTY_TYPE.D2D1_PROPERTY_TYPE_IUNKNOWN,
|
||||
@@ -100,7 +100,7 @@ internal static unsafe class ID2D1EffectExtensions
|
||||
}
|
||||
|
||||
// Otherwise, check if it's an internal CCW and retrieve the managed wrapper
|
||||
using ComPtr<ID2D1TransformMapperInternal> d2D1TransformMapperInternal = default;
|
||||
using ComPtr<ID2D1DrawTransformMapperInternal> d2D1TransformMapperInternal = default;
|
||||
|
||||
d2D1TransformMapper.CopyTo(d2D1TransformMapperInternal.GetAddressOf()).Assert();
|
||||
|
||||
@@ -110,7 +110,7 @@ internal static unsafe class ID2D1EffectExtensions
|
||||
d2D1TransformMapperInternal.Get()->GetManagedWrapperHandle((void**)&handlePtr).Assert();
|
||||
|
||||
// Retrieve the managed wrapper from the GCHandle
|
||||
return (D2D1TransformMapper<T>)GCHandle.FromIntPtr(handlePtr).Target!;
|
||||
return (D2D1DrawTransformMapper<T>)GCHandle.FromIntPtr(handlePtr).Target!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -55,7 +55,7 @@ unsafe partial class PixelShaderEffect<T>
|
||||
/// Gets the marshalled value for <see cref="TransformMapper"/>.
|
||||
/// </summary>
|
||||
/// <returns>The marshalled value for <see cref="TransformMapper"/>.</returns>
|
||||
private D2D1TransformMapper<T>? GetTransformMapper()
|
||||
private D2D1DrawTransformMapper<T>? GetTransformMapper()
|
||||
{
|
||||
using ReferenceTracker.Lease _0 = GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -73,7 +73,7 @@ unsafe partial class PixelShaderEffect<T>
|
||||
/// Sets the marshalled value for <see cref="TransformMapper"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to set for <see cref="TransformMapper"/>.</param>
|
||||
private void SetTransformMapper(D2D1TransformMapper<T> value)
|
||||
private void SetTransformMapper(D2D1DrawTransformMapper<T> value)
|
||||
{
|
||||
using ReferenceTracker.Lease _0 = GetReferenceTracker().GetLease();
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ partial class PixelShaderEffect<T>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="D2D1TransformMapper{T}"/> instance to use for the effect, if any.
|
||||
/// Gets or sets the <see cref="D2D1DrawTransformMapper{T}"/> instance to use for the effect, if any.
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentNullException">Thrown if the value is set to <see langword="null"/>.</exception>
|
||||
[DisallowNull]
|
||||
public D2D1TransformMapper<T>? TransformMapper
|
||||
public D2D1DrawTransformMapper<T>? TransformMapper
|
||||
{
|
||||
get => GetTransformMapper();
|
||||
set => SetTransformMapper(value);
|
||||
|
||||
@@ -54,7 +54,7 @@ public sealed partial class PixelShaderEffect<T> : IReferenceTrackedObject, ICan
|
||||
/// <summary>
|
||||
/// The backing field for <see cref="TransformMapper"/>.
|
||||
/// </summary>
|
||||
private D2D1TransformMapper<T>? transformMapper;
|
||||
private D2D1DrawTransformMapper<T>? transformMapper;
|
||||
|
||||
/// <summary>
|
||||
/// The backing field for <see cref="CacheOutput"/>.
|
||||
|
||||
@@ -7,7 +7,7 @@ using ComputeSharp.D2D1.Shaders.Loaders;
|
||||
namespace ComputeSharp.D2D1.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// An object allowing <see cref="D2D1TransformMapper{T}.MapInputsToOutput"/> to interact with the shader data from within a transform.
|
||||
/// An object allowing <see cref="D2D1DrawTransformMapper{T}.MapInputsToOutput"/> to interact with the shader data from within a transform.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of shader the transform will interact with.</typeparam>
|
||||
public readonly unsafe ref struct D2D1DrawInfoUpdateContext<T>
|
||||
|
||||
+22
-25
@@ -1,46 +1,42 @@
|
||||
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="D2D1DrawTransformMapper{T}"/>
|
||||
partial class D2D1DrawTransformMapper<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates an <see cref="D2D1TransformMapper{T}"/> instance for an inflate transform.
|
||||
/// Creates an <see cref="D2D1DrawTransformMapper{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="D2D1TransformMapper{T}"/> instance for an inflate transform.</returns>
|
||||
public static D2D1TransformMapper<T> Inflate(int amount)
|
||||
/// <returns>The resulting <see cref="D2D1DrawTransformMapper{T}"/> instance for an inflate transform.</returns>
|
||||
public static D2D1DrawTransformMapper<T> Inflate(int amount)
|
||||
{
|
||||
return new D2D1InflateTransformMapper<T>.ConstantAmount { Amount = amount };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="D2D1TransformMapper{T}"/> instance for an inflate transform.
|
||||
/// Creates an <see cref="D2D1DrawTransformMapper{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="D2D1TransformMapper{T}"/> instance for an inflate transform.</returns>
|
||||
public static D2D1TransformMapper<T> Inflate(int left, int top, int right, int bottom)
|
||||
/// <returns>The resulting <see cref="D2D1DrawTransformMapper{T}"/> instance for an inflate transform.</returns>
|
||||
public static D2D1DrawTransformMapper<T> Inflate(int left, int top, int right, int bottom)
|
||||
{
|
||||
return new D2D1InflateTransformMapper<T>.ConstantLeftTopRightBottomAmount { Left = left, Top = top, Right = right, Bottom = bottom };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="D2D1TransformMapper{T}"/> instance for an inflate transform.
|
||||
/// Creates an <see cref="D2D1DrawTransformMapper{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="D2D1TransformMapper{T}"/> instance for an inflate transform.</returns>
|
||||
public static D2D1TransformMapper<T> Inflate(Accessor<int> accessor)
|
||||
/// <returns>The resulting <see cref="D2D1DrawTransformMapper{T}"/> instance for an inflate transform.</returns>
|
||||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="accessor"/> is <see langword="null"/>.</exception>
|
||||
public static D2D1DrawTransformMapper<T> Inflate(Accessor<int> accessor)
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(accessor);
|
||||
|
||||
@@ -48,11 +44,11 @@ public static class D2D1TransformMapperFactory<T>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="D2D1TransformMapper{T}"/> instance for an inflate transform.
|
||||
/// Creates an <see cref="D2D1DrawTransformMapper{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="D2D1TransformMapper{T}"/> instance for an inflate transform.</returns>
|
||||
public static D2D1TransformMapper<T> Inflate(Accessor<(int Left, int Top, int Right, int Bottom)> accessor)
|
||||
/// <returns>The resulting <see cref="D2D1DrawTransformMapper{T}"/> instance for an inflate transform.</returns>
|
||||
public static D2D1DrawTransformMapper<T> Inflate(Accessor<(int Left, int Top, int Right, int Bottom)> accessor)
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(accessor);
|
||||
|
||||
@@ -60,21 +56,22 @@ public static class D2D1TransformMapperFactory<T>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="D2D1TransformMapper{T}"/> instance for an affine transform.
|
||||
/// Creates an <see cref="D2D1DrawTransformMapper{T}"/> instance for an affine transform.
|
||||
/// </summary>
|
||||
/// <param name="matrix">The fixed transformation matrix to use.</param>
|
||||
/// <returns>The resulting <see cref="D2D1TransformMapper{T}"/> instance for an affine transform.</returns>
|
||||
public static D2D1TransformMapper<T> Transform(Matrix3x2 matrix)
|
||||
/// <returns>The resulting <see cref="D2D1DrawTransformMapper{T}"/> instance for an affine transform.</returns>
|
||||
public static D2D1DrawTransformMapper<T> Transform(Matrix3x2 matrix)
|
||||
{
|
||||
return new D2D1AffineTransformMapper<T>.ConstantMatrix { Amount = matrix };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="D2D1TransformMapper{T}"/> instance for an affine transform.
|
||||
/// Creates an <see cref="D2D1DrawTransformMapper{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="D2D1TransformMapper{T}"/> instance for an affine transform.</returns>
|
||||
public static D2D1TransformMapper<T> Transform(Accessor<Matrix3x2> accessor)
|
||||
/// <returns>The resulting <see cref="D2D1DrawTransformMapper{T}"/> instance for an affine transform.</returns>
|
||||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="accessor"/> is <see langword="null"/>.</exception>
|
||||
public static D2D1DrawTransformMapper<T> Transform(Accessor<Matrix3x2> accessor)
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(accessor);
|
||||
|
||||
+22
-23
@@ -3,7 +3,6 @@ using System.Drawing;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.D2D1.Descriptors;
|
||||
using ComputeSharp.D2D1.Interop.Effects;
|
||||
using ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMappers;
|
||||
using ComputeSharp.Win32;
|
||||
|
||||
@@ -12,7 +11,7 @@ using ComputeSharp.Win32;
|
||||
namespace ComputeSharp.D2D1.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Provides an <c>ID2D1TransformMapper</c> implementation, which can be used to customize the draw transform logic in
|
||||
/// Provides an <c>ID2D1DrawTransformMapper</c> implementation, which can be used to customize the draw transform logic in
|
||||
/// an effect created with <see cref="D2D1PixelShaderEffect"/> and also shared across multiple instances of a given effect.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of shader the transform will interact with.</typeparam>
|
||||
@@ -27,7 +26,7 @@ namespace ComputeSharp.D2D1.Interop;
|
||||
/// These managers are COM objects implementing the following interface:
|
||||
/// <code language="cpp">
|
||||
/// [uuid(02E6D48D-B892-4FBC-AA54-119203BAB802)]
|
||||
/// interface ID2D1TransformMapper : IUnknown
|
||||
/// interface ID2D1DrawTransformMapper : IUnknown
|
||||
/// {
|
||||
/// HRESULT MapInputRectsToOutputRect(
|
||||
/// [in] const ID2D1DrawInfoUpdateContext* updateContext,
|
||||
@@ -79,44 +78,44 @@ namespace ComputeSharp.D2D1.Interop;
|
||||
/// </code>
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// That is, <c>ID2D1DrawInfoUpdateContext</c> allows a custom transform (an <c>ID2D1TransformMapper</c> instance) to interact with the underlying <c>ID2D1DrawInfo</c> object
|
||||
/// That is, <c>ID2D1DrawInfoUpdateContext</c> allows a custom transform (an <c>ID2D1DrawTransformMapper</c> instance) to interact with the underlying <c>ID2D1DrawInfo</c> object
|
||||
/// that is owned by the effect being used, in a safe way. For instance, it allows a transform to read and update the constant buffer, which can be used to allow a transform to
|
||||
/// pass the exact dispatch area size to an input shader, without the consumer having to manually query that information beforehand (which might not be available either).
|
||||
/// </para>
|
||||
/// <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.
|
||||
/// This interface is implemented by ComputeSharp.D2D1, and it can be used through the APIs in <see cref="D2D1DrawTransformMapper{T}"/>, in several ways.
|
||||
/// That is, consumers can either implement a type inheriting from <see cref="D2D1DrawTransformMapper{T}"/> to implement their own fully customized transform
|
||||
/// mapping logic, or they can use the helper methods exposed by <see cref="D2D1DrawTransformMapper{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
|
||||
/// of these APIs, implemented via the same <see cref="D2D1TransformMapper{T}"/> type. That is, a given instance can expose its underlying CCW through the
|
||||
/// of these APIs, implemented via the same <see cref="D2D1DrawTransformMapper{T}"/> type. That is, a given instance can expose its underlying CCW through the
|
||||
/// <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 D2D1DrawTransformMapper<T> : ICustomQueryInterface, ID2D1DrawTransformMapperInterop
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="D2D1TransformMapperImpl"/> object wrapped by the current instance.
|
||||
/// The <see cref="D2D1DrawTransformMapperImpl"/> object wrapped by the current instance.
|
||||
/// </summary>
|
||||
private ComPtr<D2D1TransformMapperImpl> d2D1TransformMapperImpl;
|
||||
private ComPtr<D2D1DrawTransformMapperImpl> d2D1TransformMapperImpl;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="D2D1TransformMapper{T}"/> instance.
|
||||
/// Creates a new <see cref="D2D1DrawTransformMapper{T}"/> instance.
|
||||
/// </summary>
|
||||
public D2D1TransformMapper()
|
||||
public D2D1DrawTransformMapper()
|
||||
{
|
||||
fixed (D2D1TransformMapperImpl** d2D1TransformMapperImpl = this.d2D1TransformMapperImpl)
|
||||
fixed (D2D1DrawTransformMapperImpl** d2D1TransformMapperImpl = this.d2D1TransformMapperImpl)
|
||||
{
|
||||
D2D1TransformMapperImpl.Factory(this, d2D1TransformMapperImpl);
|
||||
D2D1DrawTransformMapperImpl.Factory(this, d2D1TransformMapperImpl);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases the underlying <c>ID2D1TransformMapper</c> object.
|
||||
/// Releases the underlying <c>ID2D1DrawTransformMapper</c> object.
|
||||
/// </summary>
|
||||
~D2D1TransformMapper()
|
||||
~D2D1DrawTransformMapper()
|
||||
{
|
||||
this.d2D1TransformMapperImpl.Dispose();
|
||||
}
|
||||
@@ -189,11 +188,11 @@ public abstract unsafe class D2D1TransformMapper<T> : ICustomQueryInterface, ID2
|
||||
public abstract void MapInvalidOutput(int inputIndex, in Rectangle invalidInput, out Rectangle invalidOutput);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the underlying <see cref="ID2D1TransformMapper"/> object.
|
||||
/// Gets the underlying <see cref="ID2D1DrawTransformMapper"/> object.
|
||||
/// </summary>
|
||||
/// <param name="transformMapper">The underlying <see cref="ID2D1TransformMapper"/> object.</param>
|
||||
/// <param name="transformMapper">The underlying <see cref="ID2D1DrawTransformMapper"/> object.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal void GetD2D1TransformMapper(ID2D1TransformMapper** transformMapper)
|
||||
internal void GetD2D1TransformMapper(ID2D1DrawTransformMapper** transformMapper)
|
||||
{
|
||||
bool lockTaken = false;
|
||||
|
||||
@@ -249,7 +248,7 @@ public abstract unsafe class D2D1TransformMapper<T> : ICustomQueryInterface, ID2
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
void ID2D1TransformMapperInterop.MapInputsToOutput(
|
||||
void ID2D1DrawTransformMapperInterop.MapInputsToOutput(
|
||||
ID2D1DrawInfoUpdateContext* d2D1DrawInfoUpdateContext,
|
||||
ReadOnlySpan<Rectangle> inputs,
|
||||
ReadOnlySpan<Rectangle> opaqueInputs,
|
||||
@@ -265,13 +264,13 @@ public abstract unsafe class D2D1TransformMapper<T> : ICustomQueryInterface, ID2
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
void ID2D1TransformMapperInterop.MapOutputToInputs(in Rectangle output, Span<Rectangle> inputs)
|
||||
void ID2D1DrawTransformMapperInterop.MapOutputToInputs(in Rectangle output, Span<Rectangle> inputs)
|
||||
{
|
||||
MapOutputToInputs(in output, inputs);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
void ID2D1TransformMapperInterop.MapInvalidOutput(int inputIndex, in Rectangle invalidInput, out Rectangle invalidOutput)
|
||||
void ID2D1DrawTransformMapperInterop.MapInvalidOutput(int inputIndex, in Rectangle invalidInput, out Rectangle invalidOutput)
|
||||
{
|
||||
MapInvalidOutput(inputIndex, in invalidInput, out invalidOutput);
|
||||
}
|
||||
@@ -485,7 +485,7 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
/// Sets the transform mapper for an input D2D1 effect, by calling <c>ID2D1Effect::SetValue</c>.
|
||||
/// </summary>
|
||||
/// <param name="d2D1Effect">A pointer to the <c>ID2D1Effect</c> instance to use.</param>
|
||||
/// <param name="transformMapper">The input <c>ID2D1TransformMapper</c> object (see <see cref="D2D1TransformMapper{T}"/>).</param>
|
||||
/// <param name="transformMapper">The input <c>ID2D1DrawTransformMapper</c> object (see <see cref="D2D1DrawTransformMapper{T}"/>).</param>
|
||||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="d2D1Effect"/> or <paramref name="transformMapper"/> are <see langword="null"/>.</exception>
|
||||
/// <remarks>For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1_1/nf-d2d1_1-id2d1properties-setvalue(uint32_d2d1_property_type_constbyte_uint32)"/>.</remarks>
|
||||
public static void SetTransformMapperForD2D1Effect(void* d2D1Effect, void* transformMapper)
|
||||
@@ -504,16 +504,16 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
/// Sets the transform mapper for an input D2D1 effect, by calling <c>ID2D1Effect::SetValue</c>.
|
||||
/// </summary>
|
||||
/// <param name="d2D1Effect">A pointer to the <c>ID2D1Effect</c> instance to use.</param>
|
||||
/// <param name="transformMapper">The input <c>ID2D1TransformMapper</c> object.</param>
|
||||
/// <param name="transformMapper">The input <c>ID2D1DrawTransformMapper</c> object.</param>
|
||||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="d2D1Effect"/> or <paramref name="transformMapper"/> are <see langword="null"/>.</exception>
|
||||
/// <remarks>For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1_1/nf-d2d1_1-id2d1properties-setvalue(uint32_d2d1_property_type_constbyte_uint32)"/>.</remarks>
|
||||
public static void SetTransformMapperForD2D1Effect<T>(void* d2D1Effect, D2D1TransformMapper<T> transformMapper)
|
||||
public static void SetTransformMapperForD2D1Effect<T>(void* d2D1Effect, D2D1DrawTransformMapper<T> transformMapper)
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(d2D1Effect);
|
||||
default(ArgumentNullException).ThrowIfNull(transformMapper);
|
||||
|
||||
using ComPtr<ID2D1TransformMapper> transformMapper2 = default;
|
||||
using ComPtr<ID2D1DrawTransformMapper> transformMapper2 = default;
|
||||
|
||||
transformMapper.GetD2D1TransformMapper(transformMapper2.GetAddressOf());
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public static class D2D1PixelShaderEffectProperty
|
||||
public const uint ConstantBuffer = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The index for the <c>ID2D1TransformMapper</c> property of a <see cref="D2D1PixelShaderEffect"/> object.
|
||||
/// The index for the <c>ID2D1DrawTransformMapper</c> property of a <see cref="D2D1PixelShaderEffect"/> object.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>The value of this property is of type <c>D2D1_PROPERTY_TYPE_IUNKNOWN</c>.</para>
|
||||
|
||||
+3
-3
@@ -72,7 +72,7 @@ partial struct PixelShaderEffect
|
||||
|
||||
if (@this->d2D1TransformMapper.Get() is not null)
|
||||
{
|
||||
// Forward to the current ID2D1TransformMapper instance
|
||||
// Forward to the current ID2D1DrawTransformMapper instance
|
||||
@this->d2D1TransformMapper.Get()->MapOutputRectToInputRects(outputRect, inputRects, inputRectsCount).Assert();
|
||||
}
|
||||
else
|
||||
@@ -129,7 +129,7 @@ partial struct PixelShaderEffect
|
||||
constantBufferSize: @this->GetGlobals().ConstantBufferSize,
|
||||
d2D1DrawInfo: @this->d2D1DrawInfo.Get()).Assert();
|
||||
|
||||
// Forward the call to the input ID2D1TransformMapper instance
|
||||
// Forward the call to the input ID2D1DrawTransformMapper instance
|
||||
HRESULT hresult = @this->d2D1TransformMapper.Get()->MapInputRectsToOutputRect(
|
||||
updateContext: (ID2D1DrawInfoUpdateContext*)d2D1DrawInfoUpdateContext.Get(),
|
||||
inputRects: inputRects,
|
||||
@@ -212,7 +212,7 @@ partial struct PixelShaderEffect
|
||||
|
||||
if (@this->d2D1TransformMapper.Get() is not null)
|
||||
{
|
||||
// Forward to the current ID2D1TransformMapper instance
|
||||
// Forward to the current ID2D1DrawTransformMapper instance
|
||||
@this->d2D1TransformMapper.Get()->MapInvalidRect(inputIndex, invalidInputRect, invalidOutputRect).Assert();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -107,7 +107,7 @@ unsafe partial struct PixelShaderEffect
|
||||
default(ArgumentNullException).ThrowIfNull(data);
|
||||
default(ArgumentOutOfRangeException).ThrowIfLessThan((int)dataSize, sizeof(void*), nameof(dataSize));
|
||||
|
||||
@this->d2D1TransformMapper.CopyTo((ID2D1TransformMapper**)data).Assert();
|
||||
@this->d2D1TransformMapper.CopyTo((ID2D1DrawTransformMapper**)data).Assert();
|
||||
|
||||
if (actualSize is not null)
|
||||
{
|
||||
@@ -138,9 +138,9 @@ unsafe partial struct PixelShaderEffect
|
||||
default(ArgumentNullException).ThrowIfNull(value);
|
||||
|
||||
using ComPtr<IUnknown> unknown = new((IUnknown*)value);
|
||||
using ComPtr<ID2D1TransformMapper> transformMapper = default;
|
||||
using ComPtr<ID2D1DrawTransformMapper> transformMapper = default;
|
||||
|
||||
// Check that the input object implements ID2D1TransformMapper
|
||||
// Check that the input object implements ID2D1DrawTransformMapper
|
||||
unknown.CopyTo(transformMapper.GetAddressOf()).Assert();
|
||||
|
||||
// Store the transform mapper manager into the effect
|
||||
|
||||
@@ -78,9 +78,9 @@ internal unsafe partial struct PixelShaderEffect
|
||||
private byte* constantBuffer;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ID2D1TransformMapper"/> instance to use, if any.
|
||||
/// The <see cref="ID2D1DrawTransformMapper"/> instance to use, if any.
|
||||
/// </summary>
|
||||
private ComPtr<ID2D1TransformMapper> d2D1TransformMapper;
|
||||
private ComPtr<ID2D1DrawTransformMapper> d2D1TransformMapper;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ID2D1DrawInfo"/> instance currently in use.
|
||||
|
||||
+18
-19
@@ -3,44 +3,43 @@ using System.Drawing;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.D2D1.Extensions;
|
||||
using ComputeSharp.D2D1.Interop.Effects;
|
||||
using ComputeSharp.Win32;
|
||||
|
||||
namespace ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMappers;
|
||||
|
||||
/// <inheritdoc/>
|
||||
unsafe partial struct D2D1TransformMapperImpl
|
||||
unsafe partial struct D2D1DrawTransformMapperImpl
|
||||
{
|
||||
/// <summary>
|
||||
/// The implementation for <see cref="ID2D1TransformMapper"/>.
|
||||
/// The implementation for <see cref="ID2D1DrawTransformMapper"/>.
|
||||
/// </summary>
|
||||
private static class ID2D1TransformMapperMethods
|
||||
private static class ID2D1DrawTransformMapperMethods
|
||||
{
|
||||
/// <inheritdoc cref="D2D1TransformMapperImpl.QueryInterface"/>
|
||||
/// <inheritdoc cref="D2D1DrawTransformMapperImpl.QueryInterface"/>
|
||||
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])]
|
||||
public static int QueryInterface(D2D1TransformMapperImpl* @this, Guid* riid, void** ppvObject)
|
||||
public static int QueryInterface(D2D1DrawTransformMapperImpl* @this, Guid* riid, void** ppvObject)
|
||||
{
|
||||
return @this->QueryInterface(riid, ppvObject);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="D2D1TransformMapperImpl.AddRef"/>
|
||||
/// <inheritdoc cref="D2D1DrawTransformMapperImpl.AddRef"/>
|
||||
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])]
|
||||
public static uint AddRef(D2D1TransformMapperImpl* @this)
|
||||
public static uint AddRef(D2D1DrawTransformMapperImpl* @this)
|
||||
{
|
||||
return @this->AddRef();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="D2D1TransformMapperImpl.Release"/>
|
||||
/// <inheritdoc cref="D2D1DrawTransformMapperImpl.Release"/>
|
||||
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])]
|
||||
public static uint Release(D2D1TransformMapperImpl* @this)
|
||||
public static uint Release(D2D1DrawTransformMapperImpl* @this)
|
||||
{
|
||||
return @this->Release();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID2D1TransformMapper.MapInputRectsToOutputRect"/>
|
||||
/// <inheritdoc cref="ID2D1DrawTransformMapper.MapInputRectsToOutputRect"/>
|
||||
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])]
|
||||
public static int MapInputRectsToOutputRect(
|
||||
D2D1TransformMapperImpl* @this,
|
||||
D2D1DrawTransformMapperImpl* @this,
|
||||
ID2D1DrawInfoUpdateContext* d2D1DrawInfoUpdateContext,
|
||||
RECT* inputRects,
|
||||
RECT* inputOpaqueSubRects,
|
||||
@@ -63,7 +62,7 @@ unsafe partial struct D2D1TransformMapperImpl
|
||||
// Invoke MapInputsToOutput and handle exceptions so they don't cross the ABI boundary
|
||||
try
|
||||
{
|
||||
Unsafe.As<ID2D1TransformMapperInterop>(@this->transformMapperHandle.Target!).MapInputsToOutput(
|
||||
Unsafe.As<ID2D1DrawTransformMapperInterop>(@this->transformMapperHandle.Target!).MapInputsToOutput(
|
||||
d2D1DrawInfoUpdateContext,
|
||||
inputs,
|
||||
opaqueInputs,
|
||||
@@ -81,10 +80,10 @@ unsafe partial struct D2D1TransformMapperImpl
|
||||
return S.S_OK;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID2D1TransformMapper.MapOutputRectToInputRects"/>
|
||||
/// <inheritdoc cref="ID2D1DrawTransformMapper.MapOutputRectToInputRects"/>
|
||||
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])]
|
||||
public static int MapOutputRectToInputRects(
|
||||
D2D1TransformMapperImpl* @this,
|
||||
D2D1DrawTransformMapperImpl* @this,
|
||||
RECT* outputRect,
|
||||
RECT* inputRects,
|
||||
uint inputRectsCount)
|
||||
@@ -100,7 +99,7 @@ unsafe partial struct D2D1TransformMapperImpl
|
||||
// Handle exceptions, as mentioned above
|
||||
try
|
||||
{
|
||||
Unsafe.As<ID2D1TransformMapperInterop>(@this->transformMapperHandle.Target!).MapOutputToInputs(in output, inputs);
|
||||
Unsafe.As<ID2D1DrawTransformMapperInterop>(@this->transformMapperHandle.Target!).MapOutputToInputs(in output, inputs);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -115,10 +114,10 @@ unsafe partial struct D2D1TransformMapperImpl
|
||||
return S.S_OK;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID2D1TransformMapper.MapInvalidRect"/>
|
||||
/// <inheritdoc cref="ID2D1DrawTransformMapper.MapInvalidRect"/>
|
||||
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])]
|
||||
public static int MapInvalidRect(
|
||||
D2D1TransformMapperImpl* @this,
|
||||
D2D1DrawTransformMapperImpl* @this,
|
||||
uint inputIndex,
|
||||
RECT invalidInputRect,
|
||||
RECT* invalidOutputRect)
|
||||
@@ -129,7 +128,7 @@ unsafe partial struct D2D1TransformMapperImpl
|
||||
// Handle exceptions once again
|
||||
try
|
||||
{
|
||||
Unsafe.As<ID2D1TransformMapperInterop>(@this->transformMapperHandle.Target!).MapInvalidOutput((int)inputIndex, invalidInput, out invalidOutput);
|
||||
Unsafe.As<ID2D1DrawTransformMapperInterop>(@this->transformMapperHandle.Target!).MapInvalidOutput((int)inputIndex, invalidInput, out invalidOutput);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.Win32;
|
||||
|
||||
namespace ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMappers;
|
||||
|
||||
/// <inheritdoc/>
|
||||
unsafe partial struct D2D1DrawTransformMapperImpl
|
||||
{
|
||||
/// <summary>
|
||||
/// The implementation for <see cref="ID2D1DrawTransformMapperInternal"/>.
|
||||
/// </summary>
|
||||
private static class ID2D1DrawTransformMapperInternalMethods
|
||||
{
|
||||
/// <inheritdoc cref="D2D1DrawTransformMapperImpl.QueryInterface"/>
|
||||
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])]
|
||||
public static int QueryInterface(D2D1DrawTransformMapperImpl* @this, Guid* riid, void** ppvObject)
|
||||
{
|
||||
@this = (D2D1DrawTransformMapperImpl*)&((void**)@this)[-1];
|
||||
|
||||
return @this->QueryInterface(riid, ppvObject);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="D2D1DrawTransformMapperImpl.AddRef"/>
|
||||
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])]
|
||||
public static uint AddRef(D2D1DrawTransformMapperImpl* @this)
|
||||
{
|
||||
@this = (D2D1DrawTransformMapperImpl*)&((void**)@this)[-1];
|
||||
|
||||
return @this->AddRef();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="D2D1DrawTransformMapperImpl.Release"/>
|
||||
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])]
|
||||
public static uint Release(D2D1DrawTransformMapperImpl* @this)
|
||||
{
|
||||
@this = (D2D1DrawTransformMapperImpl*)&((void**)@this)[-1];
|
||||
|
||||
return @this->Release();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID2D1DrawTransformMapperInternal.GetManagedWrapperHandle"/>
|
||||
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])]
|
||||
public static int GetManagedWrapperHandle(D2D1DrawTransformMapperImpl* @this, void** ppvHandle)
|
||||
{
|
||||
@this = (D2D1DrawTransformMapperImpl*)&((void**)@this)[-1];
|
||||
|
||||
if (ppvHandle is null)
|
||||
{
|
||||
return E.E_POINTER;
|
||||
}
|
||||
|
||||
*ppvHandle = (void*)GCHandle.ToIntPtr(@this->transformMapperHandle);
|
||||
|
||||
return S.S_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
+42
-43
@@ -4,60 +4,59 @@ using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
using ComputeSharp.D2D1.Interop.Effects;
|
||||
using ComputeSharp.Win32;
|
||||
|
||||
namespace ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMappers;
|
||||
|
||||
/// <summary>
|
||||
/// An implementation of the <see cref="ID2D1TransformMapper"/> interface wrapping <see cref="ID2D1TransformMapperInterop"/>.
|
||||
/// An implementation of the <see cref="ID2D1DrawTransformMapper"/> interface wrapping <see cref="ID2D1DrawTransformMapperInterop"/>.
|
||||
/// </summary>
|
||||
internal unsafe partial struct D2D1TransformMapperImpl
|
||||
internal unsafe partial struct D2D1DrawTransformMapperImpl
|
||||
{
|
||||
/// <summary>
|
||||
/// The shared vtable pointer for <see cref="D2D1TransformMapperImpl"/> instance, for <see cref="ID2D1TransformMapper"/>.
|
||||
/// The shared vtable pointer for <see cref="D2D1DrawTransformMapperImpl"/> instance, for <see cref="ID2D1DrawTransformMapper"/>.
|
||||
/// </summary>
|
||||
private static readonly void** VtblForID2D1TransformMapper = InitVtblForID2D1TransformMapperAndID2D1TransformMapperInternal();
|
||||
private static readonly void** VtblForID2D1DrawTransformMapper = InitVtblForID2D1DrawTransformMapperAndID2D1DrawTransformMapperInternal();
|
||||
|
||||
/// <summary>
|
||||
/// The shared vtable pointer for <see cref="D2D1TransformMapperImpl"/> instance, for <see cref="ID2D1TransformMapperInternal"/>.
|
||||
/// The shared vtable pointer for <see cref="D2D1DrawTransformMapperImpl"/> instance, for <see cref="ID2D1DrawTransformMapperInternal"/>.
|
||||
/// </summary>
|
||||
private static readonly void** VtblForID2D1TransformMapperInternal = &VtblForID2D1TransformMapper[6];
|
||||
private static readonly void** VtblForID2D1DrawTransformMapperInternal = &VtblForID2D1DrawTransformMapper[6];
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the combined vtable for <see cref="ID2D1TransformMapper"/> and <see cref="ID2D1TransformMapperInternal"/>.
|
||||
/// Initializes the combined vtable for <see cref="ID2D1DrawTransformMapper"/> and <see cref="ID2D1DrawTransformMapperInternal"/>.
|
||||
/// </summary>
|
||||
/// <returns>The combined vtable for <see cref="ID2D1TransformMapper"/> and <see cref="ID2D1TransformMapperInternal"/>.</returns>
|
||||
private static void** InitVtblForID2D1TransformMapperAndID2D1TransformMapperInternal()
|
||||
/// <returns>The combined vtable for <see cref="ID2D1DrawTransformMapper"/> and <see cref="ID2D1DrawTransformMapperInternal"/>.</returns>
|
||||
private static void** InitVtblForID2D1DrawTransformMapperAndID2D1DrawTransformMapperInternal()
|
||||
{
|
||||
void** lpVtbl = (void**)D2D1AssemblyAssociatedMemory.Allocate(sizeof(void*) * 10);
|
||||
|
||||
// ID2D1ResourceTextureManager
|
||||
lpVtbl[0] = (delegate* unmanaged[MemberFunction]<D2D1TransformMapperImpl*, Guid*, void**, int>)&ID2D1TransformMapperMethods.QueryInterface;
|
||||
lpVtbl[1] = (delegate* unmanaged[MemberFunction]<D2D1TransformMapperImpl*, uint>)&ID2D1TransformMapperMethods.AddRef;
|
||||
lpVtbl[2] = (delegate* unmanaged[MemberFunction]<D2D1TransformMapperImpl*, uint>)&ID2D1TransformMapperMethods.Release;
|
||||
lpVtbl[3] = (delegate* unmanaged[MemberFunction]<D2D1TransformMapperImpl*, ID2D1DrawInfoUpdateContext*, RECT*, RECT*, uint, RECT*, RECT*, int>)&ID2D1TransformMapperMethods.MapInputRectsToOutputRect;
|
||||
lpVtbl[4] = (delegate* unmanaged[MemberFunction]<D2D1TransformMapperImpl*, RECT*, RECT*, uint, int>)&ID2D1TransformMapperMethods.MapOutputRectToInputRects;
|
||||
lpVtbl[5] = (delegate* unmanaged[MemberFunction]<D2D1TransformMapperImpl*, uint, RECT, RECT*, int>)&ID2D1TransformMapperMethods.MapInvalidRect;
|
||||
lpVtbl[0] = (delegate* unmanaged[MemberFunction]<D2D1DrawTransformMapperImpl*, Guid*, void**, int>)&ID2D1DrawTransformMapperMethods.QueryInterface;
|
||||
lpVtbl[1] = (delegate* unmanaged[MemberFunction]<D2D1DrawTransformMapperImpl*, uint>)&ID2D1DrawTransformMapperMethods.AddRef;
|
||||
lpVtbl[2] = (delegate* unmanaged[MemberFunction]<D2D1DrawTransformMapperImpl*, uint>)&ID2D1DrawTransformMapperMethods.Release;
|
||||
lpVtbl[3] = (delegate* unmanaged[MemberFunction]<D2D1DrawTransformMapperImpl*, ID2D1DrawInfoUpdateContext*, RECT*, RECT*, uint, RECT*, RECT*, int>)&ID2D1DrawTransformMapperMethods.MapInputRectsToOutputRect;
|
||||
lpVtbl[4] = (delegate* unmanaged[MemberFunction]<D2D1DrawTransformMapperImpl*, RECT*, RECT*, uint, int>)&ID2D1DrawTransformMapperMethods.MapOutputRectToInputRects;
|
||||
lpVtbl[5] = (delegate* unmanaged[MemberFunction]<D2D1DrawTransformMapperImpl*, uint, RECT, RECT*, int>)&ID2D1DrawTransformMapperMethods.MapInvalidRect;
|
||||
|
||||
// ID2D1TransformMapperInternal
|
||||
lpVtbl[6 + 0] = (delegate* unmanaged[MemberFunction]<D2D1TransformMapperImpl*, Guid*, void**, int>)&ID2D1TransformMapperInternalMethods.QueryInterface;
|
||||
lpVtbl[6 + 1] = (delegate* unmanaged[MemberFunction]<D2D1TransformMapperImpl*, uint>)&ID2D1TransformMapperInternalMethods.AddRef;
|
||||
lpVtbl[6 + 2] = (delegate* unmanaged[MemberFunction]<D2D1TransformMapperImpl*, uint>)&ID2D1TransformMapperInternalMethods.Release;
|
||||
lpVtbl[6 + 3] = (delegate* unmanaged[MemberFunction]<D2D1TransformMapperImpl*, void**, int>)&ID2D1TransformMapperInternalMethods.GetManagedWrapperHandle;
|
||||
// ID2D1DrawTransformMapperInternal
|
||||
lpVtbl[6 + 0] = (delegate* unmanaged[MemberFunction]<D2D1DrawTransformMapperImpl*, Guid*, void**, int>)&ID2D1DrawTransformMapperInternalMethods.QueryInterface;
|
||||
lpVtbl[6 + 1] = (delegate* unmanaged[MemberFunction]<D2D1DrawTransformMapperImpl*, uint>)&ID2D1DrawTransformMapperInternalMethods.AddRef;
|
||||
lpVtbl[6 + 2] = (delegate* unmanaged[MemberFunction]<D2D1DrawTransformMapperImpl*, uint>)&ID2D1DrawTransformMapperInternalMethods.Release;
|
||||
lpVtbl[6 + 3] = (delegate* unmanaged[MemberFunction]<D2D1DrawTransformMapperImpl*, void**, int>)&ID2D1DrawTransformMapperInternalMethods.GetManagedWrapperHandle;
|
||||
|
||||
return lpVtbl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The vtable pointer for the current instance, for <see cref="ID2D1TransformMapper"/>.
|
||||
/// The vtable pointer for the current instance, for <see cref="ID2D1DrawTransformMapper"/>.
|
||||
/// </summary>
|
||||
private void** lpVtblForID2D1TransformMapper;
|
||||
private void** lpVtblForID2D1DrawTransformMapper;
|
||||
|
||||
/// <summary>
|
||||
/// The vtable pointer for the current instance, for <see cref="ID2D1TransformMapperInternal"/>.
|
||||
/// The vtable pointer for the current instance, for <see cref="ID2D1DrawTransformMapperInternal"/>.
|
||||
/// </summary>
|
||||
private void** lpVtblForID2D1TransformMapperInternal;
|
||||
private void** lpVtblForID2D1DrawTransformMapperInternal;
|
||||
|
||||
/// <summary>
|
||||
/// The current reference count for the object (from <see cref="IUnknown"/>).
|
||||
@@ -65,7 +64,7 @@ internal unsafe partial struct D2D1TransformMapperImpl
|
||||
private volatile int referenceCount;
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="GCHandle"/> to the wrapped <see cref="ID2D1TransformMapperInterop"/> instance.
|
||||
/// A <see cref="GCHandle"/> to the wrapped <see cref="ID2D1DrawTransformMapperInterop"/> instance.
|
||||
/// </summary>
|
||||
private GCHandle transformMapperHandle;
|
||||
|
||||
@@ -75,18 +74,18 @@ internal unsafe partial struct D2D1TransformMapperImpl
|
||||
private SpinLock spinLock;
|
||||
|
||||
/// <summary>
|
||||
/// The factory method for <see cref="D2D1TransformMapperImpl"/> instances.
|
||||
/// The factory method for <see cref="D2D1DrawTransformMapperImpl"/> instances.
|
||||
/// </summary>
|
||||
/// <param name="transformMapper">The input <see cref="ID2D1TransformMapperInterop"/> instance to wrap.</param>
|
||||
/// <param name="d2D1TransformMapperProxy">The resulting <see cref="D2D1TransformMapperImpl"/> instance.</param>
|
||||
/// <param name="transformMapper">The input <see cref="ID2D1DrawTransformMapperInterop"/> instance to wrap.</param>
|
||||
/// <param name="d2D1TransformMapperProxy">The resulting <see cref="D2D1DrawTransformMapperImpl"/> instance.</param>
|
||||
public static void Factory(
|
||||
ID2D1TransformMapperInterop transformMapper,
|
||||
D2D1TransformMapperImpl** d2D1TransformMapperProxy)
|
||||
ID2D1DrawTransformMapperInterop transformMapper,
|
||||
D2D1DrawTransformMapperImpl** d2D1TransformMapperProxy)
|
||||
{
|
||||
D2D1TransformMapperImpl* @this = (D2D1TransformMapperImpl*)NativeMemory.Alloc((nuint)sizeof(D2D1TransformMapperImpl));
|
||||
D2D1DrawTransformMapperImpl* @this = (D2D1DrawTransformMapperImpl*)NativeMemory.Alloc((nuint)sizeof(D2D1DrawTransformMapperImpl));
|
||||
|
||||
@this->lpVtblForID2D1TransformMapper = VtblForID2D1TransformMapper;
|
||||
@this->lpVtblForID2D1TransformMapperInternal = VtblForID2D1TransformMapperInternal;
|
||||
@this->lpVtblForID2D1DrawTransformMapper = VtblForID2D1DrawTransformMapper;
|
||||
@this->lpVtblForID2D1DrawTransformMapperInternal = VtblForID2D1DrawTransformMapperInternal;
|
||||
@this->referenceCount = 1;
|
||||
@this->transformMapperHandle = GCHandle.Alloc(transformMapper);
|
||||
@this->spinLock = new SpinLock(enableThreadOwnerTracking: false);
|
||||
@@ -103,9 +102,9 @@ internal unsafe partial struct D2D1TransformMapperImpl
|
||||
/// <summary>
|
||||
/// Ensures the target of the current CCW is tracked and is keeping it alive.
|
||||
/// </summary>
|
||||
/// <param name="target">The associated <see cref="ID2D1TransformMapperInterop"/> object to track.</param>
|
||||
/// <param name="target">The associated <see cref="ID2D1DrawTransformMapperInterop"/> object to track.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void EnsureTargetIsTracked(ID2D1TransformMapperInterop target)
|
||||
public void EnsureTargetIsTracked(ID2D1DrawTransformMapperInterop target)
|
||||
{
|
||||
this.transformMapperHandle.Target = target;
|
||||
}
|
||||
@@ -113,15 +112,15 @@ internal unsafe partial struct D2D1TransformMapperImpl
|
||||
/// <summary>
|
||||
/// Copies the current object onto a target pointer.
|
||||
/// </summary>
|
||||
/// <param name="transformMapper">The target <see cref="ID2D1TransformMapper"/> pointer.</param>
|
||||
/// <param name="transformMapper">The target <see cref="ID2D1DrawTransformMapper"/> pointer.</param>
|
||||
/// <returns>The <see cref="HRESULT"/> for the operation.</returns>
|
||||
/// <remarks>This method must only be called if the caller has taken a lock on <see cref="SpinLock"/> already.</remarks>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CopyToWithNoLock(ID2D1TransformMapper** transformMapper)
|
||||
public void CopyToWithNoLock(ID2D1DrawTransformMapper** transformMapper)
|
||||
{
|
||||
this.referenceCount++;
|
||||
|
||||
*transformMapper = (ID2D1TransformMapper*)Unsafe.AsPointer(ref this);
|
||||
*transformMapper = (ID2D1DrawTransformMapper*)Unsafe.AsPointer(ref this);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IUnknown.QueryInterface"/>
|
||||
@@ -137,9 +136,9 @@ internal unsafe partial struct D2D1TransformMapperImpl
|
||||
return E.E_POINTER;
|
||||
}
|
||||
|
||||
// ID2D1TransformMapper
|
||||
// ID2D1DrawTransformMapper
|
||||
if (riid->Equals(Windows.__uuidof<IUnknown>()) ||
|
||||
riid->Equals(Windows.__uuidof<ID2D1TransformMapper>()))
|
||||
riid->Equals(Windows.__uuidof<ID2D1DrawTransformMapper>()))
|
||||
{
|
||||
this.referenceCount++;
|
||||
|
||||
@@ -148,8 +147,8 @@ internal unsafe partial struct D2D1TransformMapperImpl
|
||||
return S.S_OK;
|
||||
}
|
||||
|
||||
// ID2D1TransformMapperInternal
|
||||
if (riid->Equals(Windows.__uuidof<ID2D1TransformMapperInternal>()))
|
||||
// ID2D1DrawTransformMapperInternal
|
||||
if (riid->Equals(Windows.__uuidof<ID2D1DrawTransformMapperInternal>()))
|
||||
{
|
||||
this.referenceCount++;
|
||||
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.Win32;
|
||||
|
||||
namespace ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMappers;
|
||||
|
||||
/// <inheritdoc/>
|
||||
unsafe partial struct D2D1TransformMapperImpl
|
||||
{
|
||||
/// <summary>
|
||||
/// The implementation for <see cref="ID2D1TransformMapperInternal"/>.
|
||||
/// </summary>
|
||||
private static class ID2D1TransformMapperInternalMethods
|
||||
{
|
||||
/// <inheritdoc cref="D2D1TransformMapperImpl.QueryInterface"/>
|
||||
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])]
|
||||
public static int QueryInterface(D2D1TransformMapperImpl* @this, Guid* riid, void** ppvObject)
|
||||
{
|
||||
@this = (D2D1TransformMapperImpl*)&((void**)@this)[-1];
|
||||
|
||||
return @this->QueryInterface(riid, ppvObject);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="D2D1TransformMapperImpl.AddRef"/>
|
||||
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])]
|
||||
public static uint AddRef(D2D1TransformMapperImpl* @this)
|
||||
{
|
||||
@this = (D2D1TransformMapperImpl*)&((void**)@this)[-1];
|
||||
|
||||
return @this->AddRef();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="D2D1TransformMapperImpl.Release"/>
|
||||
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])]
|
||||
public static uint Release(D2D1TransformMapperImpl* @this)
|
||||
{
|
||||
@this = (D2D1TransformMapperImpl*)&((void**)@this)[-1];
|
||||
|
||||
return @this->Release();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID2D1TransformMapperInternal.GetManagedWrapperHandle"/>
|
||||
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])]
|
||||
public static int GetManagedWrapperHandle(D2D1TransformMapperImpl* @this, void** ppvHandle)
|
||||
{
|
||||
@this = (D2D1TransformMapperImpl*)&((void**)@this)[-1];
|
||||
|
||||
if (ppvHandle is null)
|
||||
{
|
||||
return E.E_POINTER;
|
||||
}
|
||||
|
||||
*ppvHandle = (void*)GCHandle.ToIntPtr(@this->transformMapperHandle);
|
||||
|
||||
return S.S_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -10,7 +10,7 @@ namespace ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMappers;
|
||||
/// <summary>
|
||||
/// The transform mapper manager type to use with built-in effects.
|
||||
/// </summary>
|
||||
internal unsafe struct ID2D1TransformMapper : IComObject
|
||||
internal unsafe struct ID2D1DrawTransformMapper : IComObject
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
static Guid* IComObject.IID
|
||||
@@ -60,8 +60,8 @@ internal unsafe struct ID2D1TransformMapper : IComObject
|
||||
RECT* outputRect,
|
||||
RECT* outputOpaqueSubRect)
|
||||
{
|
||||
return ((delegate* unmanaged[MemberFunction]<ID2D1TransformMapper*, ID2D1DrawInfoUpdateContext*, RECT*, RECT*, uint, RECT*, RECT*, int>)this.lpVtbl[3])(
|
||||
(ID2D1TransformMapper*)Unsafe.AsPointer(ref this),
|
||||
return ((delegate* unmanaged[MemberFunction]<ID2D1DrawTransformMapper*, ID2D1DrawInfoUpdateContext*, RECT*, RECT*, uint, RECT*, RECT*, int>)this.lpVtbl[3])(
|
||||
(ID2D1DrawTransformMapper*)Unsafe.AsPointer(ref this),
|
||||
updateContext,
|
||||
inputRects,
|
||||
inputOpaqueSubRects,
|
||||
@@ -83,8 +83,8 @@ internal unsafe struct ID2D1TransformMapper : IComObject
|
||||
RECT* inputRects,
|
||||
uint inputRectsCount)
|
||||
{
|
||||
return ((delegate* unmanaged[MemberFunction]<ID2D1TransformMapper*, RECT*, RECT*, uint, int>)this.lpVtbl[4])(
|
||||
(ID2D1TransformMapper*)Unsafe.AsPointer(ref this),
|
||||
return ((delegate* unmanaged[MemberFunction]<ID2D1DrawTransformMapper*, RECT*, RECT*, uint, int>)this.lpVtbl[4])(
|
||||
(ID2D1DrawTransformMapper*)Unsafe.AsPointer(ref this),
|
||||
outputRect,
|
||||
inputRects,
|
||||
inputRectsCount);
|
||||
@@ -103,8 +103,8 @@ internal unsafe struct ID2D1TransformMapper : IComObject
|
||||
RECT invalidInputRect,
|
||||
RECT* invalidOutputRect)
|
||||
{
|
||||
return ((delegate* unmanaged[MemberFunction]<ID2D1TransformMapper*, uint, RECT, RECT*, int>)this.lpVtbl[5])(
|
||||
(ID2D1TransformMapper*)Unsafe.AsPointer(ref this),
|
||||
return ((delegate* unmanaged[MemberFunction]<ID2D1DrawTransformMapper*, uint, RECT, RECT*, int>)this.lpVtbl[5])(
|
||||
(ID2D1DrawTransformMapper*)Unsafe.AsPointer(ref this),
|
||||
inputIndex,
|
||||
invalidInputRect,
|
||||
invalidOutputRect);
|
||||
+3
-3
@@ -10,7 +10,7 @@ namespace ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMappers;
|
||||
/// <summary>
|
||||
/// The internal transform mapper manager interface.
|
||||
/// </summary>
|
||||
internal unsafe struct ID2D1TransformMapperInternal : IComObject
|
||||
internal unsafe struct ID2D1DrawTransformMapperInternal : IComObject
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
static Guid* IComObject.IID
|
||||
@@ -49,8 +49,8 @@ internal unsafe struct ID2D1TransformMapperInternal : IComObject
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public HRESULT GetManagedWrapperHandle(void** ppvHandle)
|
||||
{
|
||||
return ((delegate* unmanaged[MemberFunction]<ID2D1TransformMapperInternal*, void**, int>)this.lpVtbl[3])(
|
||||
(ID2D1TransformMapperInternal*)Unsafe.AsPointer(ref this),
|
||||
return ((delegate* unmanaged[MemberFunction]<ID2D1DrawTransformMapperInternal*, void**, int>)this.lpVtbl[3])(
|
||||
(ID2D1DrawTransformMapperInternal*)Unsafe.AsPointer(ref this),
|
||||
ppvHandle);
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -1,15 +1,15 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMappers;
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
|
||||
namespace ComputeSharp.D2D1.Interop.Effects;
|
||||
namespace ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMappers;
|
||||
|
||||
/// <summary>
|
||||
/// A base type to support non-generic <see cref="D2D1TransformMapper{T}"/> uses.
|
||||
/// A base type to support non-generic <see cref="D2D1DrawTransformMapper{T}"/> uses.
|
||||
/// </summary>
|
||||
internal unsafe interface ID2D1TransformMapperInterop
|
||||
internal unsafe interface ID2D1DrawTransformMapperInterop
|
||||
{
|
||||
/// <inheritdoc cref="D2D1TransformMapper{T}.MapInputsToOutput"/>
|
||||
/// <inheritdoc cref="D2D1DrawTransformMapper{T}.MapInputsToOutput"/>
|
||||
/// <param name="d2D1DrawInfoUpdateContext">The <see cref="ID2D1DrawInfoUpdateContext"/> instance associated with the current effect.</param>
|
||||
/// <param name="inputs">The input rectangles to be mapped to the output rectangle. This parameter is always equal to the input bounds.</param>
|
||||
/// <param name="opaqueInputs">The input rectangles to be mapped to the opaque output rectangle.</param>
|
||||
@@ -22,9 +22,9 @@ internal unsafe interface ID2D1TransformMapperInterop
|
||||
out Rectangle output,
|
||||
out Rectangle opaqueOutput);
|
||||
|
||||
/// <inheritdoc cref="D2D1TransformMapper{T}.MapOutputToInputs"/>
|
||||
/// <inheritdoc cref="D2D1DrawTransformMapper{T}.MapOutputToInputs"/>
|
||||
void MapOutputToInputs(in Rectangle output, Span<Rectangle> inputs);
|
||||
|
||||
/// <inheritdoc cref="D2D1TransformMapper{T}.MapInvalidOutput"/>
|
||||
/// <inheritdoc cref="D2D1DrawTransformMapper{T}.MapInvalidOutput"/>
|
||||
void MapInvalidOutput(int inputIndex, in Rectangle invalidInput, out Rectangle invalidOutput);
|
||||
}
|
||||
+4
-4
@@ -12,7 +12,7 @@ namespace ComputeSharp.D2D1.Shaders.Interop.Factories.Abstract;
|
||||
/// </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<T>
|
||||
internal abstract class D2D1DrawTransformMapper<T, TParameters> : D2D1DrawTransformMapper<T>
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
where TParameters : unmanaged
|
||||
{
|
||||
@@ -22,7 +22,7 @@ internal abstract class D2D1TransformMapper<T, TParameters> : D2D1TransformMappe
|
||||
private TParameters parameters;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void MapInputsToOutput(
|
||||
public sealed override void MapInputsToOutput(
|
||||
D2D1DrawInfoUpdateContext<T> drawInfoUpdateContext,
|
||||
ReadOnlySpan<Rectangle> inputs,
|
||||
ReadOnlySpan<Rectangle> opaqueInputs,
|
||||
@@ -56,7 +56,7 @@ internal abstract class D2D1TransformMapper<T, TParameters> : D2D1TransformMappe
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void MapOutputToInputs(in Rectangle output, Span<Rectangle> inputs)
|
||||
public sealed override void MapOutputToInputs(in Rectangle output, Span<Rectangle> inputs)
|
||||
{
|
||||
Rectangle64 output64 = Rectangle64.FromRectangle(output);
|
||||
|
||||
@@ -66,7 +66,7 @@ internal abstract class D2D1TransformMapper<T, TParameters> : D2D1TransformMappe
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void MapInvalidOutput(int inputIndex, in Rectangle invalidInput, out Rectangle invalidOutput)
|
||||
public sealed override void MapInvalidOutput(int inputIndex, in Rectangle invalidInput, out Rectangle invalidOutput)
|
||||
{
|
||||
Rectangle64 output64 = Rectangle64.FromRectangle(invalidInput);
|
||||
|
||||
|
||||
@@ -77,10 +77,10 @@ file static class D2D1AffineTransformMapper
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A custom <see cref="D2D1TransformMapper{T, TParameters}"/> implementation for an affine transform.
|
||||
/// A custom <see cref="D2D1DrawTransformMapper{T, TParameters}"/> implementation for an affine transform.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of D2D1 pixel shader associated to the transform mapper.</typeparam>
|
||||
internal abstract class D2D1AffineTransformMapper<T> : D2D1TransformMapper<T, Matrix3x2>
|
||||
internal abstract class D2D1AffineTransformMapper<T> : D2D1DrawTransformMapper<T, Matrix3x2>
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
@@ -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="D2D1DrawTransformMapper{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)
|
||||
|
||||
@@ -6,10 +6,10 @@ using ComputeSharp.D2D1.Shaders.Interop.Helpers;
|
||||
namespace ComputeSharp.D2D1.Shaders.Interop.Factories;
|
||||
|
||||
/// <summary>
|
||||
/// A custom <see cref="D2D1TransformMapper{T, TParameters}"/> implementation for an inflate transform.
|
||||
/// A custom <see cref="D2D1DrawTransformMapper{T, TParameters}"/> implementation for an inflate transform.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of D2D1 pixel shader associated to the transform mapper.</typeparam>
|
||||
internal abstract class D2D1InflateTransformMapper<T> : D2D1TransformMapper<T, (int Left, int Top, int Right, int Bottom)>
|
||||
internal abstract class D2D1InflateTransformMapper<T> : D2D1DrawTransformMapper<T, (int Left, int Top, int Right, int Bottom)>
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
@@ -42,7 +42,7 @@ internal abstract class D2D1InflateTransformMapper<T> : D2D1TransformMapper<T, (
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="D2D1TransformMapper{T, TParameters}"/> implementation for a constant inflate LTRB amount.
|
||||
/// A <see cref="D2D1DrawTransformMapper{T, TParameters}"/> implementation for a constant inflate LTRB amount.
|
||||
/// </summary>
|
||||
public sealed class ConstantLeftTopRightBottomAmount : D2D1InflateTransformMapper<T>
|
||||
{
|
||||
@@ -74,14 +74,14 @@ internal abstract class D2D1InflateTransformMapper<T> : D2D1TransformMapper<T, (
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="D2D1TransformMapper{T, TParameters}"/> implementation for a dynamic inflate amount.
|
||||
/// A <see cref="D2D1DrawTransformMapper{T, TParameters}"/> implementation for a dynamic inflate amount.
|
||||
/// </summary>
|
||||
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="D2D1DrawTransformMapper{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)
|
||||
@@ -93,14 +93,14 @@ internal abstract class D2D1InflateTransformMapper<T> : D2D1TransformMapper<T, (
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="D2D1TransformMapper{T, TParameters}"/> implementation for a dynamic inflate LTRB amount.
|
||||
/// A <see cref="D2D1DrawTransformMapper{T, TParameters}"/> implementation for a dynamic inflate LTRB amount.
|
||||
/// </summary>
|
||||
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="D2D1DrawTransformMapper{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)
|
||||
|
||||
@@ -95,7 +95,7 @@ public partial class D2D1PixelShaderEffectTests
|
||||
[ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes = false)]
|
||||
public unsafe void SetTransformMapperForD2D1Effect_RCW_NullD2D1ResourceTextureManager()
|
||||
{
|
||||
D2D1PixelShaderEffect.SetTransformMapperForD2D1Effect((void*)1, (D2D1TransformMapper<NullConstantBufferShader>)null!);
|
||||
D2D1PixelShaderEffect.SetTransformMapperForD2D1Effect((void*)1, (D2D1DrawTransformMapper<NullConstantBufferShader>)null!);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
@@ -20,7 +20,7 @@ public partial class D2D1TransformMapperTests
|
||||
[TestMethod]
|
||||
public unsafe void VerifyInterfaces()
|
||||
{
|
||||
D2D1TransformMapper<HelloWorld> transformMapper = D2D1TransformMapperFactory<HelloWorld>.Inflate(4);
|
||||
D2D1DrawTransformMapper<HelloWorld> transformMapper = D2D1DrawTransformMapper<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);
|
||||
D2D1DrawTransformMapper<HelloWorld> transformMapper = D2D1DrawTransformMapper<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);
|
||||
D2D1DrawTransformMapper<HelloWorld> transformMapper = D2D1DrawTransformMapper<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);
|
||||
D2D1DrawTransformMapper<HelloWorld> transformMapper = D2D1DrawTransformMapper<HelloWorld>.Inflate(4);
|
||||
|
||||
Guid uuidOfTransformMapper = new("02E6D48D-B892-4FBC-AA54-119203BAB802");
|
||||
|
||||
@@ -243,7 +243,7 @@ public partial class D2D1TransformMapperTests
|
||||
TolerantImageComparer.AssertEqual(destinationPath, expectedPath, 0.00001f);
|
||||
}
|
||||
|
||||
private sealed class DispatchAreaTransformMapper : D2D1TransformMapper<ShaderWithDispatchArea>
|
||||
private sealed class DispatchAreaTransformMapper : D2D1DrawTransformMapper<ShaderWithDispatchArea>
|
||||
{
|
||||
public int ExpectedWidth;
|
||||
public int ExpectedHeight;
|
||||
|
||||
@@ -479,9 +479,9 @@ public sealed partial class BokehBlurEffect
|
||||
internal sealed partial class VerticalConvolution
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="D2D1TransformMapper{T}"/> for the shader.
|
||||
/// The <see cref="D2D1DrawTransformMapper{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 D2D1DrawTransformMapper<Shader> Transform { get; } = D2D1DrawTransformMapper<Shader>.Inflate(static (in Shader shader) => (0, shader.kernelLength, 0, shader.kernelLength));
|
||||
|
||||
/// <summary>
|
||||
/// Kernel for the vertical convolution pass for real or imaginary components.
|
||||
@@ -526,9 +526,9 @@ public sealed partial class BokehBlurEffect
|
||||
internal sealed partial class HorizontalConvolutionAndAccumulatePartials
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="D2D1TransformMapper{T}"/> for the shader.
|
||||
/// The <see cref="D2D1DrawTransformMapper{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 D2D1DrawTransformMapper<Shader> Transform { get; } = D2D1DrawTransformMapper<Shader>.Inflate(static (in Shader shader) => (shader.kernelLength, 0, shader.kernelLength, 0));
|
||||
|
||||
/// <summary>
|
||||
/// Kernel for the horizontal convolution pass.
|
||||
|
||||
@@ -49,7 +49,7 @@ public class EffectsTests
|
||||
{
|
||||
D2D1TestRunner.RunAndCompareShader(
|
||||
new PixelateEffect(new PixelateEffect.Constants(1280, 840, 16)),
|
||||
D2D1TransformMapperFactory<PixelateEffect>.Inflate(16),
|
||||
D2D1DrawTransformMapper<PixelateEffect>.Inflate(16),
|
||||
"Landscape.png",
|
||||
"Landscape_Pixelate.png");
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ 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="transformMapper">A custom <see cref="D2D1TransformMapper{T}"/> instance for the effect.</param>
|
||||
/// <param name="transformMapper">A custom <see cref="D2D1DrawTransformMapper{T}"/> instance for the effect.</param>
|
||||
/// <param name="originalFileName">The name of the source image.</param>
|
||||
/// <param name="expectedFileName">The name of the expected result image.</param>
|
||||
/// <param name="destinationFileName">The name of the destination image to save results to.</param>
|
||||
@@ -27,7 +27,7 @@ internal static class D2D1TestRunner
|
||||
/// <param name="threshold">The allowed difference threshold for the normalized delta.</param>
|
||||
public static void RunAndCompareShader<T>(
|
||||
in T shader,
|
||||
D2D1TransformMapper<T>? transformMapper,
|
||||
D2D1DrawTransformMapper<T>? transformMapper,
|
||||
string originalFileName,
|
||||
string expectedFileName,
|
||||
[CallerMemberName] string destinationFileName = "",
|
||||
@@ -101,12 +101,12 @@ internal static class D2D1TestRunner
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The shader type to execute.</typeparam>
|
||||
/// <param name="shader">The shader to run.</param>
|
||||
/// <param name="transformMapper">A custom <see cref="D2D1TransformMapper{T}"/> instance for the effect.</param>
|
||||
/// <param name="transformMapper">A custom <see cref="D2D1DrawTransformMapper{T}"/> instance 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>
|
||||
private static unsafe void ExecutePixelShaderAndSaveToFile<T>(
|
||||
in T shader,
|
||||
D2D1TransformMapper<T>? transformMapper,
|
||||
D2D1DrawTransformMapper<T>? transformMapper,
|
||||
string sourcePath,
|
||||
string destinationPath)
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
@@ -148,12 +148,12 @@ internal static class D2D1TestRunner
|
||||
/// <param name="shader">The shader to run.</param>
|
||||
/// <param name="width">The resulting width.</param>
|
||||
/// <param name="height">The resulting height.</param>
|
||||
/// <param name="transformMapper">A custom <see cref="D2D1TransformMapper{T}"/> instance for the effect.</param>
|
||||
/// <param name="transformMapper">A custom <see cref="D2D1DrawTransformMapper{T}"/> instance for the effect.</param>
|
||||
/// <param name="destinationPath">The destination path for the result.</param>
|
||||
/// <param name="resourceTextures">The additional resource textures to use to run the shader.</param>
|
||||
private static unsafe void ExecutePixelShaderAndSaveToFile<T>(
|
||||
in T shader,
|
||||
D2D1TransformMapper<T>? transformMapper,
|
||||
D2D1DrawTransformMapper<T>? transformMapper,
|
||||
int width,
|
||||
int height,
|
||||
string destinationPath,
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする