From 10a378822424eabebee232df3dfe96056507985e Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 18 Dec 2022 15:26:21 +0100 Subject: [PATCH] Add bindings for new Win2D exports for ICanvasEffect --- .../ICanvasEffect.cs | 2 +- .../ABI.Microsoft.Graphics.Canvas/Win2D.cs | 65 +++++++++++++++++++ .../PixelShaderEffect{T}.cs | 2 +- 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ICanvasEffect.cs b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ICanvasEffect.cs index e97d4a19..4a599ce0 100644 --- a/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ICanvasEffect.cs +++ b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ICanvasEffect.cs @@ -6,7 +6,7 @@ using TerraFX.Interop.Windows; #pragma warning disable CS0649, IDE1006 -namespace ABI.Microsoft.Graphics.Canvas; +namespace ABI.Microsoft.Graphics.Canvas.Effects; /// /// The native WinRT interface for objects. diff --git a/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/Win2D.cs b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/Win2D.cs index 9674c68d..2e8b25d0 100644 --- a/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/Win2D.cs +++ b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/Win2D.cs @@ -1,5 +1,6 @@ using System.Numerics; using System.Runtime.InteropServices; +using ABI.Microsoft.Graphics.Canvas.Effects; using TerraFX.Interop; using Windows.Foundation; @@ -19,9 +20,73 @@ internal static unsafe class Win2D /// The resulting bounds. /// The for the operation. [DllImport("Microsoft.Graphics.Canvas.dll", PreserveSig = true, ExactSpelling = true)] + [return: NativeTypeName("HRESULT")] public static extern int GetBoundsForICanvasImageInterop( ICanvasResourceCreator* resourceCreator, ICanvasImageInterop* image, [NativeTypeName("Windows::Foundation::Numerics::Matrix3x2 const*")] Matrix3x2* transform, Rect* rect); + + /// + /// Implements support for for an external instance. + /// + /// The input instance to use to perform the operation. + /// The target instance to execute the operation upon. + /// The input index to invalidate. + /// The rectangle to invalidate. + /// The for the operation. + [DllImport("Microsoft.Graphics.Canvas.dll", PreserveSig = true, ExactSpelling = true)] + [return: NativeTypeName("HRESULT")] + public static extern int InvalidateSourceRectangleForICanvasImageInterop( + ICanvasResourceCreatorWithDpi* resourceCreator, + ICanvasImageInterop* image, + uint sourceIndex, + [NativeTypeName("Windows::Foundation::Rect const*")] Rect* invalidRectangle); + + /// + /// Implements support for for an external instance. + /// + /// The input instance to use to perform the operation. + /// The target instance to execute the operation upon. + /// The resulting length of the COM array returned via . + /// The COM array with the sequence of invalid rectangles for the effect. + /// The for the operation. + [DllImport("Microsoft.Graphics.Canvas.dll", PreserveSig = true, ExactSpelling = true)] + [return: NativeTypeName("HRESULT")] + public static extern int GetInvalidRectanglesForICanvasImageInterop( + ICanvasResourceCreatorWithDpi* resourceCreator, + ICanvasImageInterop* image, + uint* valueCount, + Rect** valueElements); + + /// + /// Implements support for and + /// for an external instance. + /// + /// The input instance to use to perform the operation. + /// The target instance to execute the operation upon. + /// The portion of the output image whose inputs are being inspected. + /// The length of the sequence of input effects. + /// The sequence of input effects whose rectangles are being queries. + /// The length of the sequence of indices for the input effects. + /// The sequence of indices for the input effects. + /// The length of the sequence of bounds to consider. + /// The sequence of bounds to consider in the resulting output. + /// The number of elements provided in . + /// The sequence of resulting required rectangles to compute. + /// The for the operation. + [DllImport("Microsoft.Graphics.Canvas.dll", PreserveSig = true, ExactSpelling = true)] + [return: NativeTypeName("HRESULT")] + public static extern int GetRequiredSourceRectanglesForICanvasImageInterop( + ICanvasResourceCreatorWithDpi* resourceCreator, + ICanvasImageInterop* image, + [NativeTypeName("Windows::Foundation::Rect const*")] Rect* outputRectangle, + uint sourceEffectCount, + [NativeTypeName("ABI::Microsoft::Graphics::Canvas::Effects::ICanvasEffect* const*")] ICanvasEffect** sourceEffects, + uint sourceIndexCount, + [NativeTypeName("uint32_t const*")] uint* sourceIndices, + uint sourceBoundsCount, + [NativeTypeName("Windows::Foundation::Rect const*")] Rect* sourceBounds, + uint valueCount, + Rect* valueElements); } diff --git a/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.cs b/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.cs index b653dc3b..7c3c389c 100644 --- a/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.cs +++ b/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.cs @@ -2,9 +2,9 @@ using ABI.Microsoft.Graphics.Canvas; using ComputeSharp.D2D1.Interop; using ComputeSharp.Interop; using Microsoft.Graphics.Canvas; +using Microsoft.Graphics.Canvas.Effects; using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; -using ICanvasEffect = Microsoft.Graphics.Canvas.Effects.ICanvasEffect; namespace ComputeSharp.D2D1.Uwp;