Add new ICanvasFactoryNative APIs and ICanvasEffectFactoryNative type

このコミットが含まれているのは:
Sergio Pedri committed 2023-04-21 00:07:35 +02:00
1 親 f2406ea1da
コミット 9e1677e06f
3ファイル変更
+152 -2

検索条件に一致するファイルはありません

@@ -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;
/// <summary>
/// The interop Win2D interface for factories of external effects.
/// </summary>
[Guid("29BA1A1F-1CFE-44C3-984D-426D61B51427")]
[NativeTypeName("class ICanvasEffectFactoryNative : IUnknown")]
[NativeInheritance("IUnknown")]
internal unsafe struct ICanvasEffectFactoryNative
{
public void** lpVtbl;
/// <inheritdoc cref="IUnknown.QueryInterface"/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(0)]
public HRESULT QueryInterface([NativeTypeName("const IID &")] Guid* riid, void** ppvObject)
{
return ((delegate* unmanaged[Stdcall]<ICanvasEffectFactoryNative*, Guid*, void**, int>)this.lpVtbl[0])((ICanvasEffectFactoryNative*)Unsafe.AsPointer(ref this), riid, ppvObject);
}
/// <inheritdoc cref="IUnknown.AddRef"/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(1)]
[return: NativeTypeName("ULONG")]
public uint AddRef()
{
return ((delegate* unmanaged[Stdcall]<ICanvasEffectFactoryNative*, uint>)this.lpVtbl[1])((ICanvasEffectFactoryNative*)Unsafe.AsPointer(ref this));
}
/// <inheritdoc cref="IUnknown.Release"/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(2)]
[return: NativeTypeName("ULONG")]
public uint Release()
{
return ((delegate* unmanaged[Stdcall]<ICanvasEffectFactoryNative*, uint>)this.lpVtbl[2])((ICanvasEffectFactoryNative*)Unsafe.AsPointer(ref this));
}
/// <summary>
/// Creates a new inspectable wrapper for an inpute D2D effect previosly registered through <see cref="ICanvasFactoryNative.RegisterEffectFactory"/>.
/// </summary>
/// <param name="device">The input canvas device.</param>
/// <param name="resource">The input native effect to create a wrapper for.</param>
/// <param name="dpi">The realization DPIs for <paramref name="resource"/>.</param>
/// <param name="wrapper">The resulting wrapper for <paramref name="resource"/>.</param>
/// <returns>The <see cref="HRESULT"/> for the operation.</returns>
/// <remarks>
/// All parameters are directly forwarded from the ones the caller passed to <see cref="ICanvasFactoryNative.GetOrCreate"/>. The returned
/// wrapper should implement <see cref="global::Microsoft.Graphics.Canvas.ICanvasImage"/> to be returned correctly from Win2D after this call.
/// </remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(3)]
public HRESULT CreateWrapper(ICanvasDevice* device, ID2D1Effect* resource, float dpi, IInspectable** wrapper)
{
return ((delegate* unmanaged[Stdcall]<ICanvasEffectFactoryNative*, ICanvasDevice*, ID2D1Effect*, float, IInspectable**, int>)this.lpVtbl[3])(
(ICanvasEffectFactoryNative*)Unsafe.AsPointer(ref this),
device,
resource,
dpi,
wrapper);
}
}
+79 -2
ファイルの表示
@@ -50,12 +50,11 @@ internal unsafe struct ICanvasFactoryNative
/// </summary>
/// <param name="device">The input canvas device (as a marshalled <see cref="global::Microsoft.Graphics.Canvas.CanvasDevice"/>).</param>
/// <param name="resource">The input native resource to create a wrapper for.</param>
/// <param name="dpi">The realization DPIs for <paramref name="resource"/></param>
/// <param name="dpi">The realization DPIs for <paramref name="resource"/>.</param>
/// <param name="wrapper">The resulting wrapper for <paramref name="resource"/>.</param>
/// <returns>The <see cref="HRESULT"/> for the operation.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(6)]
[return: NativeTypeName("ULONG")]
public HRESULT GetOrCreate(ICanvasDevice* device, IUnknown* resource, float dpi, IInspectable** wrapper)
{
return ((delegate* unmanaged[Stdcall]<ICanvasFactoryNative*, ICanvasDevice*, IUnknown*, float, IInspectable**, int>)this.lpVtbl[6])(
@@ -65,4 +64,82 @@ internal unsafe struct ICanvasFactoryNative
dpi,
wrapper);
}
/// <summary>
/// Registers an <c>IInspectable</c> wrapper for a given native D2D resource.
/// </summary>
/// <param name="resource">The input native resource to register a wrapper for.</param>
/// <param name="wrapper">The wrapper to register for <paramref name="resource"/>.</param>
/// <returns>
/// The <see cref="HRESULT"/> for the operation. In case of success, it will be <see cref="S.S_OK"/> if the wrapper
/// was not previously registered, or <see cref="S.S_FALSE"/> if <paramref name="resource"/> was already registered.
/// </returns>
/// <remarks>
/// The method validates at runtime that <paramref name="resource"/> is an <see cref="TerraFX.Interop.DirectX.ID2D1Image"/>
/// and that <paramref name="wrapper"/> is an <see cref="global::Microsoft.Graphics.Canvas.ICanvasImage"/>. Additionally,
/// <paramref name="wrapper"/> has to implement <c>IWeakReferenceSource</c> for this method to be successful.
/// </remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(7)]
public HRESULT RegisterWrapper(IUnknown* resource, IInspectable* wrapper)
{
return ((delegate* unmanaged[Stdcall]<ICanvasFactoryNative*, IUnknown*, IInspectable*, int>)this.lpVtbl[7])(
(ICanvasFactoryNative*)Unsafe.AsPointer(ref this),
resource,
wrapper);
}
/// <summary>
/// Unregisters a native D2D resource previously registered with <see cref="RegisterWrapper"/>.
/// </summary>
/// <param name="resource">The input native resource to unregister.</param>
/// <returns>
/// The <see cref="HRESULT"/> for the operation. In case of success, it will be <see cref="S.S_OK"/> if the
/// resource was previously registered and could be correctly unregistered, <see cref="S.S_FALSE"/> otherwise.
/// </returns>
/// <remarks>
/// The method validates at runtime that <paramref name="resource"/> is an <see cref="TerraFX.Interop.DirectX.ID2D1Image"/>.
/// </remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(8)]
public HRESULT UnregisterWrapper(IUnknown* resource)
{
return ((delegate* unmanaged[Stdcall]<ICanvasFactoryNative*, IUnknown*, int>)this.lpVtbl[8])(
(ICanvasFactoryNative*)Unsafe.AsPointer(ref this),
resource);
}
/// <summary>
/// Registers a factory of wrappers for custom effects.
/// </summary>
/// <param name="effectId">The id of the effects to register a factory for.</param>
/// <param name="factory">The input factory to create wrappers of native effects.</param>
/// <returns>
/// The <see cref="HRESULT"/> for the operation. In case of success, it will be <see cref="S.S_OK"/> if the factory
/// was not previously registered, or <see cref="S.S_FALSE"/> if <paramref name="effectId"/> was already registered.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(9)]
public HRESULT RegisterEffectFactory([NativeTypeName("const IID &")] Guid* effectId, ICanvasEffectFactoryNative* factory)
{
return ((delegate* unmanaged[Stdcall]<ICanvasFactoryNative*, ICanvasEffectFactoryNative*, int>)this.lpVtbl[9])(
(ICanvasFactoryNative*)Unsafe.AsPointer(ref this),
factory);
}
/// <summary>
/// Unregisters an effect factory that was previosuly registered with <see cref="RegisterEffectFactory"/>.
/// </summary>
/// <param name="effectId">The id of the effects to unregister the factory for.</param>
/// <returns>
/// The <see cref="HRESULT"/> for the operation. In case of success, it will be <see cref="S.S_OK"/> if the
/// factory was previously registered and could be correctly unregistered, <see cref="S.S_FALSE"/> otherwise.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(10)]
public HRESULT UnregisterEffectFactory([NativeTypeName("const IID &")] Guid* effectId)
{
return ((delegate* unmanaged[Stdcall]<ICanvasFactoryNative*, int>)this.lpVtbl[10])(
(ICanvasFactoryNative*)Unsafe.AsPointer(ref this));
}
}
+1
ファイルの表示
@@ -10,6 +10,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)ABI.Microsoft.Graphics.Canvas\ICanvasDevice.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ABI.Microsoft.Graphics.Canvas\ICanvasEffectFactoryNative.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ABI.Microsoft.Graphics.Canvas\ICanvasEffect.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ABI.Microsoft.Graphics.Canvas\ICanvasFactoryNative.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ABI.Microsoft.Graphics.Canvas\ICanvasImageInterop.cs" />