diff --git a/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/CanvasImageGetD2DImageFlags.cs b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/CanvasImageGetD2DImageFlags.cs index 613d6221..23ecb8cc 100644 --- a/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/CanvasImageGetD2DImageFlags.cs +++ b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/CanvasImageGetD2DImageFlags.cs @@ -3,7 +3,7 @@ using System; namespace ABI.Microsoft.Graphics.Canvas; /// -/// Options for fine-tuning the behavior of . +/// Options for fine-tuning the behavior of . /// [Flags] internal enum CanvasImageGetD2DImageFlags diff --git a/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs index b62ce00f..ef451257 100644 --- a/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs +++ b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs @@ -1,60 +1,73 @@ -using System.Runtime.InteropServices; using System; +using System.Runtime.InteropServices; using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; using TerraFX.Interop; +#pragma warning disable CS0649 + namespace ABI.Microsoft.Graphics.Canvas; /// /// An interop Win2D interface for all images and effects that can be drawn. /// -[ComImport] [Guid("E042D1F7-F9AD-4479-A713-67627EA31863")] -[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] -internal unsafe interface ICanvasImageInterop +[NativeTypeName("class ICanvasImageInterop : IUnknown")] +[NativeInheritance("IUnknown")] +internal unsafe struct ICanvasImageInterop { - /// - /// Gets the device that the effect is currently realized on, if any. - /// - /// The resulting device, if available ((as a marshalled )). - /// The for the operation. - [PreserveSig] - [return: NativeTypeName("HRESULT")] - int GetDevice(ICanvasDevice** device); + public void** lpVtbl; /// - /// Gets an from an instance. + /// The implementation of . /// - /// The input canvas device (as a marshalled ). - /// - /// The device context in use. This value is is optional (but recommended), except when the - /// flag is specified. This is because - /// not all callers of have easy access to a context. It is always - /// possible to get a resource creation context from the device, but the context is only - /// actually necessary if a new effect realization needs to be created, so it is more efficient - /// to have the implementation do this lookup only if/when it turns out to be needed. - /// - /// The flags to use to get the image. - /// - /// The DPI of the target device context. This is used to determine when a D2D1DpiCompensation - /// effect needs to be inserted. Behavior of this parameter can be overridden by the flag values - /// , - /// or - /// - /// - /// The DPI of a source bitmap, or zero if the image does not have a fixed DPI. A D2D1DpiCompensation effect - /// will be inserted if and are different (flags permitting). - /// - /// The resulting for the effect. - /// The for the operation. - [PreserveSig] - [return: NativeTypeName("HRESULT")] - int GetD2DImage( - ICanvasDevice* device, - ID2D1DeviceContext* deviceContext, - CanvasImageGetD2DImageFlags flags, - float targetDpi, - float* realizeDpi, - ID2D1Image** ppImage); + [ComImport] + [Guid("E042D1F7-F9AD-4479-A713-67627EA31863")] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + public interface Interface + { + /// + /// Gets the device that the effect is currently realized on, if any. + /// + /// The resulting device, if available ((as a marshalled )). + /// The for the operation. + [PreserveSig] + [return: NativeTypeName("HRESULT")] + int GetDevice(ICanvasDevice** device); + + /// + /// Gets an from an instance. + /// + /// The input canvas device (as a marshalled ). + /// + /// The device context in use. This value is is optional (but recommended), except when the + /// flag is specified. This is because + /// not all callers of have easy access to a context. It is always + /// possible to get a resource creation context from the device, but the context is only + /// actually necessary if a new effect realization needs to be created, so it is more efficient + /// to have the implementation do this lookup only if/when it turns out to be needed. + /// + /// The flags to use to get the image. + /// + /// The DPI of the target device context. This is used to determine when a D2D1DpiCompensation + /// effect needs to be inserted. Behavior of this parameter can be overridden by the flag values + /// , + /// or + /// + /// + /// The DPI of a source bitmap, or zero if the image does not have a fixed DPI. A D2D1DpiCompensation effect + /// will be inserted if and are different (flags permitting). + /// + /// The resulting for the effect. + /// The for the operation. + [PreserveSig] + [return: NativeTypeName("HRESULT")] + int GetD2DImage( + ICanvasDevice* device, + ID2D1DeviceContext* deviceContext, + CanvasImageGetD2DImageFlags flags, + float targetDpi, + float* realizeDpi, + ID2D1Image** ppImage); + } } \ No newline at end of file diff --git a/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ICanvasResourceWrapperNative.cs b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ICanvasResourceWrapperNative.cs index 7d877958..2f31d72e 100644 --- a/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ICanvasResourceWrapperNative.cs +++ b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ICanvasResourceWrapperNative.cs @@ -49,9 +49,8 @@ internal unsafe struct ICanvasResourceWrapperNative /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(3)] - [return: NativeTypeName("HRESULT")] - public HRESULT GetNativeResource([NativeTypeName("ICanvasDevice*")] void* device, float dpi, [NativeTypeName("REFIID")] Guid* iid, void** resource) + public HRESULT GetNativeResource(ICanvasDevice* device, float dpi, [NativeTypeName("REFIID")] Guid* iid, void** resource) { - return ((delegate* unmanaged[Stdcall])this.lpVtbl[3])((ICanvasResourceWrapperNative*)Unsafe.AsPointer(ref this), device, dpi, iid, resource); + return ((delegate* unmanaged[Stdcall])this.lpVtbl[3])((ICanvasResourceWrapperNative*)Unsafe.AsPointer(ref this), device, dpi, iid, resource); } } \ No newline at end of file diff --git a/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.ICanvasImageInterop.cs b/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.ICanvasImageInterop.cs index d4652e8c..0712a2f6 100644 --- a/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.ICanvasImageInterop.cs +++ b/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.ICanvasImageInterop.cs @@ -16,7 +16,7 @@ namespace ComputeSharp.D2D1.Uwp; unsafe partial class PixelShaderEffect { /// - int ICanvasImageInterop.GetDevice(ICanvasDevice** device) + int ICanvasImageInterop.Interface.GetDevice(ICanvasDevice** device) { using ReferenceTracker.Lease _0 = GetReferenceTracker().TryGetLease(out bool leaseTaken); @@ -49,7 +49,7 @@ unsafe partial class PixelShaderEffect } /// - int ICanvasImageInterop.GetD2DImage( + int ICanvasImageInterop.Interface.GetD2DImage( ICanvasDevice* device, ID2D1DeviceContext* deviceContext, CanvasImageGetD2DImageFlags flags, diff --git a/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.cs b/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.cs index 68e11821..e8a1273c 100644 --- a/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.cs +++ b/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.cs @@ -10,7 +10,7 @@ namespace ComputeSharp.D2D1.Uwp; /// A custom implementation powered by a supplied shader type. /// /// The type of shader to use to render frames. -public sealed partial class PixelShaderEffect : IReferenceTrackedObject, ICanvasImage, ICanvasImageInterop +public sealed partial class PixelShaderEffect : IReferenceTrackedObject, ICanvasImage, ICanvasImageInterop.Interface where T : unmanaged, ID2D1PixelShader { /// @@ -24,7 +24,7 @@ public sealed partial class PixelShaderEffect : IReferenceTrackedObject, ICan private readonly object lockObject = new(); /// - /// Flag to track whether a given call is recursively invoked by , to avoid graph cycles. + /// Flag to track whether a given call is recursively invoked by , to avoid graph cycles. /// private volatile int isInsideGetD2DImage;