From bc1a392e9f739a81af78c9d38eaaba306197b218 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 30 Oct 2022 20:38:51 +0100 Subject: [PATCH] Add ID2D1TransformMapperManager binding type --- .../ID2D1ResourceTextureManager.cs | 6 +- .../ID2D1ResourceTextureManagerInternal.cs | 8 +- .../ID2D1TransformMapperManager.cs | 113 ++++++++++++++++++ 3 files changed, 120 insertions(+), 7 deletions(-) create mode 100644 src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMapperManagers/ID2D1TransformMapperManager.cs diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ID2D1ResourceTextureManager.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ID2D1ResourceTextureManager.cs index 651f511c..370d8f9a 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ID2D1ResourceTextureManager.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ID2D1ResourceTextureManager.cs @@ -15,7 +15,7 @@ namespace ComputeSharp.D2D1.Shaders.Interop.Effects.ResourceManagers; internal unsafe struct ID2D1ResourceTextureManager { /// - /// Gets the for ID2D1ResourceTextureManager (3C4FC7E4-A419-46CA-B5F6-66EB4FF18D64). + /// Gets the for (3C4FC7E4-A419-46CA-B5F6-66EB4FF18D64). /// public static ref readonly Guid Guid { @@ -54,7 +54,7 @@ internal unsafe struct ID2D1ResourceTextureManager /// The size, in bytes, of the data. /// An for the operation. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public int Initialize( + public HRESULT Initialize( Guid* resourceId, D2D1_RESOURCE_TEXTURE_PROPERTIES* resourceTextureProperties, byte* data, @@ -81,7 +81,7 @@ internal unsafe struct ID2D1ResourceTextureManager /// The size of the data buffer to be used to update the resource texture. /// An for the operation. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public int Update( + public HRESULT Update( uint* minimumExtents, uint* maximimumExtents, uint* strides, diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ID2D1ResourceTextureManagerInternal.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ID2D1ResourceTextureManagerInternal.cs index d8b7c894..e9bf555c 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ID2D1ResourceTextureManagerInternal.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ID2D1ResourceTextureManagerInternal.cs @@ -15,7 +15,7 @@ namespace ComputeSharp.D2D1.Shaders.Interop.Effects.ResourceManagers; internal unsafe struct ID2D1ResourceTextureManagerInternal { /// - /// Gets the for ID2D1ResourceTextureManagerInternal (5CBB1024-8EA1-4689-81BF-8AD190B5EF5D). + /// Gets the for (5CBB1024-8EA1-4689-81BF-8AD190B5EF5D). /// public static ref readonly Guid Guid { @@ -44,13 +44,13 @@ internal unsafe struct ID2D1ResourceTextureManagerInternal private readonly void** lpVtbl; /// - /// Sets the for the current ID2D1ResourceTextureManagerInternal instance. + /// Sets the for the current instance. /// /// The input for the manager. /// A pointer to an optional amount of dimensions for the target resource texture, for validation. /// An for the operation. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public int Initialize(ID2D1EffectContext* effectContext, uint* dimensions) + public HRESULT Initialize(ID2D1EffectContext* effectContext, uint* dimensions) { return ((delegate* unmanaged[Stdcall])this.lpVtbl[3])( (ID2D1ResourceTextureManagerInternal*)Unsafe.AsPointer(ref this), @@ -64,7 +64,7 @@ internal unsafe struct ID2D1ResourceTextureManagerInternal /// The resulting instance. /// An for the operation. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public int GetResourceTexture(ID2D1ResourceTexture** resourceTexture) + public HRESULT GetResourceTexture(ID2D1ResourceTexture** resourceTexture) { return ((delegate* unmanaged[Stdcall])this.lpVtbl[4])( (ID2D1ResourceTextureManagerInternal*)Unsafe.AsPointer(ref this), diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMapperManagers/ID2D1TransformMapperManager.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMapperManagers/ID2D1TransformMapperManager.cs new file mode 100644 index 00000000..97dbb7d8 --- /dev/null +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMapperManagers/ID2D1TransformMapperManager.cs @@ -0,0 +1,113 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using TerraFX.Interop.Windows; + +#pragma warning disable CS0649 + +namespace ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMapperManagers; + +/// +/// The transform mapper manager type to use with built-in effects. +/// +[Guid("02E6D48D-B892-4FBC-AA54-119203BAB802")] +internal unsafe struct ID2D1TransformMapperManager +{ + /// + /// Gets the for (02E6D48D-B892-4FBC-AA54-119203BAB802). + /// + public static ref readonly Guid Guid + { + get + { + ReadOnlySpan data = new byte[] { + 0x02, 0xE6, 0xD4, 0x8D, + 0xB8, 0x92, + 0x4F, 0xBC, + 0xAA, 0x54, + 0x11, + 0x92, + 0x03, + 0xBA, + 0xB8, + 0x02 + }; + + return ref Unsafe.As(ref MemoryMarshal.GetReference(data)); + } + } + + /// + /// The vtable for the current instance. + /// + private readonly void** lpVtbl; + + /// + /// Performs the inverse mapping to . + /// + /// The input instance. + /// An array of input rectangles to be mapped to the output rectangle. + /// An array of input rectangles to be mapped to the opaque output rectangle. + /// The number of inputs specified. + /// The output rectangle that maps to the corresponding input rectangle. + /// The output rectangle that maps to the corresponding opaque input rectangle. + /// An for the operation. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public HRESULT MapInputRectsToOutputRect( + ID2D1DrawInfoUpdateContex* updateContext, + RECT* inputRects, + RECT* inputOpaqueSubRects, + uint inputRectCount, + RECT* outputRect, + RECT* outputOpaqueSubRect) + { + return ((delegate* unmanaged[Stdcall])this.lpVtbl[3])( + (ID2D1TransformMapperManager*)Unsafe.AsPointer(ref this), + updateContext, + inputRects, + inputOpaqueSubRects, + inputRectCount, + outputRect, + outputOpaqueSubRect); + } + + /// + /// Allows a transform to state how it would map a rectangle requested on its output to a set of sample rectangles on its input. + /// + /// The output rectangle from which the inputs must be mapped. + /// The corresponding set of inputs. The inputs will directly correspond to the transform inputs. + /// The number of inputs specified. + /// An for the operation. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public HRESULT MapOutputRectToInputRects( + RECT* outputRect, + RECT* inputRects, + uint inputRectsCount) + { + return ((delegate* unmanaged[Stdcall])this.lpVtbl[4])( + (ID2D1TransformMapperManager*)Unsafe.AsPointer(ref this), + outputRect, + inputRects, + inputRectsCount); + } + + /// + /// Sets the input rectangles for this rendering pass into the transform. + /// + /// The index of the input rectangle. + /// The invalid input rectangle. + /// The output rectangle to which the input rectangle must be mapped. + /// An for the operation. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public HRESULT MapInputRectsToOutputRect( + uint inputIndex, + RECT invalidInputRect, + RECT* invalidOutputRect) + { + return ((delegate* unmanaged[Stdcall])this.lpVtbl[5])( + (ID2D1TransformMapperManager*)Unsafe.AsPointer(ref this), + inputIndex, + invalidInputRect, + invalidOutputRect); + } +} \ No newline at end of file