diff --git a/src/ComputeSharp.D2D1.UI/ABI.Microsoft.Graphics.Canvas/ICanvasEffectFactoryNative.cs b/src/ComputeSharp.D2D1.UI/ABI.Microsoft.Graphics.Canvas/ICanvasEffectFactoryNative.cs
new file mode 100644
index 00000000..69201dfb
--- /dev/null
+++ b/src/ComputeSharp.D2D1.UI/ABI.Microsoft.Graphics.Canvas/ICanvasEffectFactoryNative.cs
@@ -0,0 +1,72 @@
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using TerraFX.Interop;
+using TerraFX.Interop.DirectX;
+using TerraFX.Interop.Windows;
+using TerraFX.Interop.WinRT;
+
+#pragma warning disable CS0649, IDE1006
+
+namespace ABI.Microsoft.Graphics.Canvas;
+
+///
+/// The interop Win2D interface for factories of external effects.
+///
+[Guid("29BA1A1F-1CFE-44C3-984D-426D61B51427")]
+[NativeTypeName("class ICanvasEffectFactoryNative : IUnknown")]
+[NativeInheritance("IUnknown")]
+internal unsafe struct ICanvasEffectFactoryNative
+{
+ 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])((ICanvasEffectFactoryNative*)Unsafe.AsPointer(ref this), riid, ppvObject);
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(1)]
+ [return: NativeTypeName("ULONG")]
+ public uint AddRef()
+ {
+ return ((delegate* unmanaged[Stdcall])this.lpVtbl[1])((ICanvasEffectFactoryNative*)Unsafe.AsPointer(ref this));
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(2)]
+ [return: NativeTypeName("ULONG")]
+ public uint Release()
+ {
+ return ((delegate* unmanaged[Stdcall])this.lpVtbl[2])((ICanvasEffectFactoryNative*)Unsafe.AsPointer(ref this));
+ }
+
+ ///
+ /// Creates a new inspectable wrapper for an inpute D2D effect previosly registered through .
+ ///
+ /// The input canvas device.
+ /// The input native effect to create a wrapper for.
+ /// The realization DPIs for .
+ /// The resulting wrapper for .
+ /// The for the operation.
+ ///
+ /// All parameters are directly forwarded from the ones the caller passed to . The returned
+ /// wrapper should implement to be returned correctly from Win2D after this call.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(3)]
+ public HRESULT CreateWrapper(ICanvasDevice* device, ID2D1Effect* resource, float dpi, IInspectable** wrapper)
+ {
+ return ((delegate* unmanaged[Stdcall])this.lpVtbl[3])(
+ (ICanvasEffectFactoryNative*)Unsafe.AsPointer(ref this),
+ device,
+ resource,
+ dpi,
+ wrapper);
+ }
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.UI/ABI.Microsoft.Graphics.Canvas/ICanvasFactoryNative.cs b/src/ComputeSharp.D2D1.UI/ABI.Microsoft.Graphics.Canvas/ICanvasFactoryNative.cs
index 7c4df69a..2e14c612 100644
--- a/src/ComputeSharp.D2D1.UI/ABI.Microsoft.Graphics.Canvas/ICanvasFactoryNative.cs
+++ b/src/ComputeSharp.D2D1.UI/ABI.Microsoft.Graphics.Canvas/ICanvasFactoryNative.cs
@@ -50,12 +50,11 @@ internal unsafe struct ICanvasFactoryNative
///
/// The input canvas device (as a marshalled ).
/// The input native resource to create a wrapper for.
- /// The realization DPIs for
+ /// The realization DPIs for .
/// The resulting wrapper for .
/// The for the operation.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(6)]
- [return: NativeTypeName("ULONG")]
public HRESULT GetOrCreate(ICanvasDevice* device, IUnknown* resource, float dpi, IInspectable** wrapper)
{
return ((delegate* unmanaged[Stdcall])this.lpVtbl[6])(
@@ -65,4 +64,82 @@ internal unsafe struct ICanvasFactoryNative
dpi,
wrapper);
}
+
+ ///
+ /// Registers an IInspectable wrapper for a given native D2D resource.
+ ///
+ /// The input native resource to register a wrapper for.
+ /// The wrapper to register for .
+ ///
+ /// The for the operation. In case of success, it will be if the wrapper
+ /// was not previously registered, or if was already registered.
+ ///
+ ///
+ /// The method validates at runtime that is an
+ /// and that is an . Additionally,
+ /// has to implement IWeakReferenceSource for this method to be successful.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(7)]
+ public HRESULT RegisterWrapper(IUnknown* resource, IInspectable* wrapper)
+ {
+ return ((delegate* unmanaged[Stdcall])this.lpVtbl[7])(
+ (ICanvasFactoryNative*)Unsafe.AsPointer(ref this),
+ resource,
+ wrapper);
+ }
+
+ ///
+ /// Unregisters a native D2D resource previously registered with .
+ ///
+ /// The input native resource to unregister.
+ ///
+ /// The for the operation. In case of success, it will be if the
+ /// resource was previously registered and could be correctly unregistered, otherwise.
+ ///
+ ///
+ /// The method validates at runtime that is an .
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(8)]
+ public HRESULT UnregisterWrapper(IUnknown* resource)
+ {
+ return ((delegate* unmanaged[Stdcall])this.lpVtbl[8])(
+ (ICanvasFactoryNative*)Unsafe.AsPointer(ref this),
+ resource);
+ }
+
+ ///
+ /// Registers a factory of wrappers for custom effects.
+ ///
+ /// The id of the effects to register a factory for.
+ /// The input factory to create wrappers of native effects.
+ ///
+ /// The for the operation. In case of success, it will be if the factory
+ /// was not previously registered, or if was already registered.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(9)]
+ public HRESULT RegisterEffectFactory([NativeTypeName("const IID &")] Guid* effectId, ICanvasEffectFactoryNative* factory)
+ {
+ return ((delegate* unmanaged[Stdcall])this.lpVtbl[9])(
+ (ICanvasFactoryNative*)Unsafe.AsPointer(ref this),
+ factory);
+ }
+
+ ///
+ /// Unregisters an effect factory that was previosuly registered with .
+ ///
+ /// The id of the effects to unregister the factory for.
+ ///
+ /// The for the operation. In case of success, it will be if the
+ /// factory was previously registered and could be correctly unregistered, otherwise.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(10)]
+ public HRESULT UnregisterEffectFactory([NativeTypeName("const IID &")] Guid* effectId)
+ {
+ return ((delegate* unmanaged[Stdcall])this.lpVtbl[10])(
+ (ICanvasFactoryNative*)Unsafe.AsPointer(ref this));
+ }
}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.UI/ComputeSharp.D2D1.UI.projitems b/src/ComputeSharp.D2D1.UI/ComputeSharp.D2D1.UI.projitems
index 7d30c6fc..ebda8706 100644
--- a/src/ComputeSharp.D2D1.UI/ComputeSharp.D2D1.UI.projitems
+++ b/src/ComputeSharp.D2D1.UI/ComputeSharp.D2D1.UI.projitems
@@ -10,6 +10,7 @@
+