From 303246fffd2465caf6be4f8a4ab30c0d50dc58c1 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 16 Dec 2022 16:40:36 +0100 Subject: [PATCH] Add ID2D1DeviceContextPool and ID2D1DeviceContextLease bindings --- .../ID2D1DeviceContextLease.cs | 60 +++++++++++++++++++ .../ID2D1DeviceContextPool.cs | 58 ++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ID2D1DeviceContextLease.cs create mode 100644 src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ID2D1DeviceContextPool.cs diff --git a/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ID2D1DeviceContextLease.cs b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ID2D1DeviceContextLease.cs new file mode 100644 index 00000000..c0e19200 --- /dev/null +++ b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ID2D1DeviceContextLease.cs @@ -0,0 +1,60 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using TerraFX.Interop; +using TerraFX.Interop.DirectX; +using TerraFX.Interop.Windows; + +#pragma warning disable CS0649, IDE1006 + +namespace ABI.Microsoft.Graphics.Canvas; + +/// +/// An interface for a COM object that provides access to a pooled object. +/// +[Guid("A0928F38-F7D5-44DD-A5C9-E23D94734BBB")] +[NativeTypeName("class ID2D1DeviceContextLease : IUnknown")] +[NativeInheritance("IUnknown")] +internal unsafe struct ID2D1DeviceContextLease +{ + public void** lpVtbl; + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(0)] + public HRESULT QueryInterface([NativeTypeName("const IID &")] Guid* riid, void** ppvObject) + { + return ((delegate* unmanaged[Stdcall])this.lpVtbl[0])((ID2D1DeviceContextLease*)Unsafe.AsPointer(ref this), riid, ppvObject); + } + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(1)] + [return: NativeTypeName("ULONG")] + public uint AddRef() + { + return ((delegate* unmanaged[Stdcall])this.lpVtbl[1])((ID2D1DeviceContextLease*)Unsafe.AsPointer(ref this)); + } + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(2)] + [return: NativeTypeName("ULONG")] + public uint Release() + { + return ((delegate* unmanaged[Stdcall])this.lpVtbl[2])((ID2D1DeviceContextLease*)Unsafe.AsPointer(ref this)); + } + + /// + /// Provides access to the object wrapped by the current instance. + /// + /// The resulting object wrapped by the current instance. + /// The for the operation. + /// The returned cannot be used once the owning lease has been released. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(3)] + public HRESULT GetD2DDeviceContext(ID2D1DeviceContext** deviceContext) + { + return ((delegate* unmanaged[Stdcall])this.lpVtbl[3])((ID2D1DeviceContextLease*)Unsafe.AsPointer(ref this), deviceContext); + } +} \ No newline at end of file diff --git a/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ID2D1DeviceContextPool.cs b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ID2D1DeviceContextPool.cs new file mode 100644 index 00000000..500b65ab --- /dev/null +++ b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ID2D1DeviceContextPool.cs @@ -0,0 +1,58 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using TerraFX.Interop; +using TerraFX.Interop.Windows; + +#pragma warning disable CS0649, IDE1006 + +namespace ABI.Microsoft.Graphics.Canvas; + +/// +/// An interface for an object that provides access to pooled objects. +/// +[Guid("454A82A1-F024-40DB-BD5B-8F527FD58AD0")] +[NativeTypeName("class ID2D1DeviceContextPool : IUnknown")] +[NativeInheritance("IUnknown")] +internal unsafe struct ID2D1DeviceContextPool +{ + public void** lpVtbl; + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(0)] + public HRESULT QueryInterface([NativeTypeName("const IID &")] Guid* riid, void** ppvObject) + { + return ((delegate* unmanaged[Stdcall])this.lpVtbl[0])((ID2D1DeviceContextPool*)Unsafe.AsPointer(ref this), riid, ppvObject); + } + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(1)] + [return: NativeTypeName("ULONG")] + public uint AddRef() + { + return ((delegate* unmanaged[Stdcall])this.lpVtbl[1])((ID2D1DeviceContextPool*)Unsafe.AsPointer(ref this)); + } + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(2)] + [return: NativeTypeName("ULONG")] + public uint Release() + { + return ((delegate* unmanaged[Stdcall])this.lpVtbl[2])((ID2D1DeviceContextPool*)Unsafe.AsPointer(ref this)); + } + + /// + /// Retrieves a new object from the current instance. + /// + /// The resulting object to use. + /// The for the operation. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(3)] + public HRESULT GetDeviceContextLease(ID2D1DeviceContextLease** lease) + { + return ((delegate* unmanaged[Stdcall])this.lpVtbl[3])((ID2D1DeviceContextPool*)Unsafe.AsPointer(ref this), lease); + } +} \ No newline at end of file