Merge pull request #763 from Sergio0694/dev/cswinrt-aot
Update ComputeSharp.D2D1.WinUI to AOT-safe CsWinRT
このコミットが含まれているのは:
27ファイル変更
+352
-340
検索条件に一致するファイルはありません
-23
@@ -3,8 +3,6 @@ using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using TerraFX.Interop.Windows;
|
||||
using TerraFX.Interop;
|
||||
using WinRT;
|
||||
using WinRT.Interop;
|
||||
|
||||
#pragma warning disable CS0649, IDE0055, IDE1006
|
||||
|
||||
@@ -79,25 +77,4 @@ internal unsafe struct ICanvasFactoryNative : IUnknown.Interface
|
||||
dpi,
|
||||
wrapper);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The managed interface for <see cref="ICanvasFactoryNative"/>.
|
||||
/// </summary>
|
||||
[Guid("695C440D-04B3-4EDD-BFD9-63E51E9F7202")]
|
||||
[WindowsRuntimeType]
|
||||
[WindowsRuntimeHelperType(typeof(Interface))]
|
||||
public interface Interface
|
||||
{
|
||||
/// <summary>
|
||||
/// The vtable type for <see cref="Interface"/>.
|
||||
/// </summary>
|
||||
[Guid("695C440D-04B3-4EDD-BFD9-63E51E9F7202")]
|
||||
public readonly struct Vftbl
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows CsWinRT to retrieve a pointer to the projection vtable (the name is hardcoded by convention).
|
||||
/// </summary>
|
||||
public static readonly IntPtr AbiToProjectionVftablePtr = IUnknownVftbl.AbiToProjectionVftblPtr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ namespace ComputeSharp.SwapChain.D2D1.Backend;
|
||||
/// <summary>
|
||||
/// An base effect for an animated pixel shader.
|
||||
/// </summary>
|
||||
internal abstract class PixelShaderEffect : CanvasEffect
|
||||
internal abstract partial class PixelShaderEffect : CanvasEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// The current elapsed time.
|
||||
@@ -57,7 +57,7 @@ internal abstract class PixelShaderEffect : CanvasEffect
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of pixel shader to render.</typeparam>
|
||||
/// <param name="factory">The input <typeparamref name="T"/> factory.</param>
|
||||
public sealed class For<T>(For<T>.Factory factory) : PixelShaderEffect
|
||||
public sealed partial class For<T>(For<T>.Factory factory) : PixelShaderEffect
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -117,15 +117,11 @@ internal sealed class Win32Application
|
||||
using ComPtr<ICanvasFactoryNative> canvasFactoryNative = default;
|
||||
|
||||
// Get the activation factory for CanvasDevice
|
||||
using (ComPtr<IUnknown> canvasFactoryNativeUnknown = default)
|
||||
using (IObjectReference canvasDeviceActivationFactory = ActivationFactory.Get(
|
||||
typeName: "Microsoft.Graphics.Canvas.CanvasDevice",
|
||||
iid: Windows.__uuidof<ICanvasFactoryNative>()))
|
||||
{
|
||||
ICanvasFactoryNative.Interface canvasDeviceActivationFactory = CanvasDevice.As<ICanvasFactoryNative.Interface>();
|
||||
|
||||
canvasFactoryNativeUnknown.Attach((IUnknown*)MarshalInterface<ICanvasFactoryNative.Interface>.FromManaged(canvasDeviceActivationFactory));
|
||||
|
||||
hresult = canvasFactoryNativeUnknown.CopyTo(canvasFactoryNative.GetAddressOf());
|
||||
|
||||
ExceptionHelpers.ThrowExceptionForHR(hresult);
|
||||
canvasFactoryNative.Attach((ICanvasFactoryNative*)canvasDeviceActivationFactory.GetRef());
|
||||
}
|
||||
|
||||
// Create a Win2D wrapper for the swapchain
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<OutputType Condition="'$(CI_RUNNER_SAMPLES_INTEGRATION_TESTS)' == 'true'">Exe</OutputType>
|
||||
<OutputType Condition="'$(CI_RUNNER_SAMPLES_INTEGRATION_TESTS)' != 'true'">WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows10.0.22621</TargetFramework>
|
||||
<WindowsSdkPackageVersion>10.0.22621.35-preview</WindowsSdkPackageVersion>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<Platforms>x64;ARM64</Platforms>
|
||||
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
|
||||
@@ -12,14 +13,24 @@
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
<!--
|
||||
Generate a .pdb file to avoid IIDOptimizer build errors.
|
||||
See: https://github.com/microsoft/CsWinRT/issues/1478.
|
||||
-->
|
||||
<DebugType>full</DebugType>
|
||||
|
||||
<!-- Suppress warnings for using directives inside namespaces (needed to avoid some WinRT conflicts) -->
|
||||
<NoWarn>$(NoWarn);IDE0065</NoWarn>
|
||||
|
||||
<!-- Workaround for WinRT.TypeExtensions.GetAuthoringMetadataType(Type) trim warning (see https://github.com/microsoft/CsWinRT/issues/1319) -->
|
||||
<NoWarn>$(NoWarn);IL2104;IL2026</NoWarn>
|
||||
|
||||
<!-- Workaround for WinRT.Runtime and System.Linq.Expressions producing trim warnings -->
|
||||
<NoWarn>$(NoWarn);IL3053</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- CsWinRT size saving options (same as in ComputeSharp.NativeLibrary.WinRT) -->
|
||||
<PropertyGroup>
|
||||
<CsWinRTEnableDynamicObjectsSupport>false</CsWinRTEnableDynamicObjectsSupport>
|
||||
<CsWinRTUseExceptionResourceKeys>true</CsWinRTUseExceptionResourceKeys>
|
||||
<CsWinRTEnableDefaultCustomTypeMappings>false</CsWinRTEnableDefaultCustomTypeMappings>
|
||||
<CsWinRTEnableICustomPropertyProviderSupport>false</CsWinRTEnableICustomPropertyProviderSupport>
|
||||
<CsWinRTEnableIReferenceSupport>false</CsWinRTEnableIReferenceSupport>
|
||||
<CsWinRTEnableIDynamicInterfaceCastableSupport>false</CsWinRTEnableIDynamicInterfaceCastableSupport>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Options for R2R publishing -->
|
||||
@@ -42,13 +53,14 @@
|
||||
<OptimizationPreference>Speed</OptimizationPreference>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Also include the .rd.xml file to fix some NativeAOT issues with CsWinRT -->
|
||||
<ItemGroup Condition="'$(COMPUTESHARP_SWAPCHAIN_D2D1_PUBLISH_AOT)' == 'true'">
|
||||
<RdXmlFile Include="Properties\Default.rd.xml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="TerraFX.Interop.Windows" Version="10.0.22621.6" />
|
||||
|
||||
<!--
|
||||
Reference CsWinRT locally for the source generators (see comments in ComputeSharp.D2D1.WinUI).
|
||||
Note that this is an executable and not a library, so we must drop the 'PrivateAssets' here.
|
||||
-->
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.0-prerelease.240602.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Note: using SetPlatform="Platform=AnyCPU" for the analyzers to avoid issues (see https://github.com/dotnet/roslyn/issues/70148) -->
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Directives>
|
||||
<Application>
|
||||
<Assembly Name="WinRT.Runtime">
|
||||
<Type Name="WinRT.IObjectReference">
|
||||
<Method Name="As" Dynamic="Required All">
|
||||
<GenericArgument Name="ABI.Microsoft.Graphics.Canvas.ICanvasFactoryNative+Interface+Vftbl, ComputeSharp.D2D1.Cli" />
|
||||
</Method>
|
||||
<Method Name="As" Dynamic="Required All">
|
||||
<GenericArgument Name="ABI.Microsoft.Graphics.Canvas.ICanvasFactoryNative+Interface+Vftbl, ComputeSharp.D2D1.WinUI" />
|
||||
</Method>
|
||||
<Method Name="As" Dynamic="Required All">
|
||||
<GenericArgument Name="ABI.System.IDisposable+Vftbl, WinRT.Runtime" />
|
||||
</Method>
|
||||
</Type>
|
||||
</Assembly>
|
||||
</Application>
|
||||
</Directives>
|
||||
@@ -3,6 +3,7 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<WindowsSdkPackageVersion>10.0.22621.35-preview</WindowsSdkPackageVersion>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<Platforms>x64;arm64</Platforms>
|
||||
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
|
||||
|
||||
+100
-83
@@ -8,107 +8,124 @@ using IInspectable = ComputeSharp.Win32.IInspectable;
|
||||
|
||||
#pragma warning disable CS0649, IDE0055, IDE1006
|
||||
|
||||
namespace ABI.Microsoft.Graphics.Canvas;
|
||||
|
||||
/// <summary>
|
||||
/// The interop Win2D interface for factories of external effects.
|
||||
/// </summary>
|
||||
[NativeTypeName("class ICanvasEffectFactoryNative : IUnknown")]
|
||||
[NativeInheritance("IUnknown")]
|
||||
internal unsafe struct ICanvasEffectFactoryNative : IComObject
|
||||
namespace ABI.Microsoft.Graphics.Canvas
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
static Guid* IComObject.IID
|
||||
/// <summary>
|
||||
/// The interop Win2D interface for factories of external effects.
|
||||
/// </summary>
|
||||
[NativeTypeName("class ICanvasEffectFactoryNative : IUnknown")]
|
||||
[NativeInheritance("IUnknown")]
|
||||
internal unsafe struct ICanvasEffectFactoryNative : IComObject
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
/// <inheritdoc/>
|
||||
public static Guid* IID
|
||||
{
|
||||
ReadOnlySpan<byte> data =
|
||||
[
|
||||
0x1F, 0x1A, 0xBA, 0x29,
|
||||
0xFE, 0x1C,
|
||||
0xC3, 0x44,
|
||||
0x98, 0x4D,
|
||||
0x42,
|
||||
0x6D,
|
||||
0x61,
|
||||
0xB5,
|
||||
0x14,
|
||||
0x27
|
||||
];
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
ReadOnlySpan<byte> data =
|
||||
[
|
||||
0x1F, 0x1A, 0xBA, 0x29,
|
||||
0xFE, 0x1C,
|
||||
0xC3, 0x44,
|
||||
0x98, 0x4D,
|
||||
0x42,
|
||||
0x6D,
|
||||
0x61,
|
||||
0xB5,
|
||||
0x14,
|
||||
0x27
|
||||
];
|
||||
|
||||
return (Guid*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(data));
|
||||
return (Guid*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(data));
|
||||
}
|
||||
}
|
||||
|
||||
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[MemberFunction]<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[MemberFunction]<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[MemberFunction]<ICanvasEffectFactoryNative*, uint>)this.lpVtbl[2])((ICanvasEffectFactoryNative*)Unsafe.AsPointer(ref this));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new inspectable wrapper for an input 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[MemberFunction]<ICanvasEffectFactoryNative*, ICanvasDevice*, ID2D1Effect*, float, IInspectable**, int>)this.lpVtbl[3])(
|
||||
(ICanvasEffectFactoryNative*)Unsafe.AsPointer(ref this),
|
||||
device,
|
||||
resource,
|
||||
dpi,
|
||||
wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
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[MemberFunction]<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[MemberFunction]<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[MemberFunction]<ICanvasEffectFactoryNative*, uint>)this.lpVtbl[2])((ICanvasEffectFactoryNative*)Unsafe.AsPointer(ref this));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new inspectable wrapper for an input D2D effect previosly registered through <see cref="ICanvasFactoryNative.RegisterEffectFactory"/>.
|
||||
/// The ABI methods for <see cref="ICanvasEffectFactoryNative"/>.
|
||||
/// </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)
|
||||
internal static unsafe class ICanvasEffectFactoryNativeMethods
|
||||
{
|
||||
return ((delegate* unmanaged[MemberFunction]<ICanvasEffectFactoryNative*, ICanvasDevice*, ID2D1Effect*, float, IInspectable**, int>)this.lpVtbl[3])(
|
||||
(ICanvasEffectFactoryNative*)Unsafe.AsPointer(ref this),
|
||||
device,
|
||||
resource,
|
||||
dpi,
|
||||
wrapper);
|
||||
/// <inheritdoc cref="ICanvasEffectFactoryNative.IID"/>
|
||||
public static Guid IID => *ICanvasEffectFactoryNative.IID;
|
||||
|
||||
/// <inheritdoc cref="global::Microsoft.Graphics.Canvas.ICanvasEffectFactoryNative.Vftbl.AbiToProjectionVftablePtr"/>
|
||||
public static IntPtr AbiToProjectionVftablePtr => global::Microsoft.Graphics.Canvas.ICanvasEffectFactoryNative.Vftbl.AbiToProjectionVftablePtr;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Microsoft.Graphics.Canvas
|
||||
{
|
||||
using ABI.Microsoft.Graphics.Canvas;
|
||||
|
||||
/// <summary>
|
||||
/// The managed implementation of <see cref="ICanvasEffectFactoryNative"/>.
|
||||
/// The managed implementation of <see cref="ABI.Microsoft.Graphics.Canvas.ICanvasEffectFactoryNative"/>.
|
||||
/// </summary>
|
||||
[Guid("29BA1A1F-1CFE-44C3-984D-426D61B51427")]
|
||||
[WindowsRuntimeType]
|
||||
[WindowsRuntimeHelperType(typeof(Interface))]
|
||||
public interface Interface
|
||||
[WindowsRuntimeHelperType(typeof(ICanvasEffectFactoryNative))]
|
||||
internal unsafe interface ICanvasEffectFactoryNative
|
||||
{
|
||||
/// <inheritdoc cref="ICanvasEffectFactoryNative.CreateWrapper"/>
|
||||
/// <inheritdoc cref="ABI.Microsoft.Graphics.Canvas.ICanvasEffectFactoryNative.CreateWrapper"/>
|
||||
[return: NativeTypeName("HRESULT")]
|
||||
int CreateWrapper(ICanvasDevice* device, ID2D1Effect* resource, float dpi, IInspectable** wrapper);
|
||||
|
||||
/// <summary>
|
||||
/// The vtable type for <see cref="Interface"/>.
|
||||
/// The vtable type for <see cref="ICanvasEffectFactoryNative"/>.
|
||||
/// </summary>
|
||||
[Guid("29BA1A1F-1CFE-44C3-984D-426D61B51427")]
|
||||
public struct Vftbl
|
||||
{
|
||||
/// <summary>
|
||||
@@ -117,9 +134,9 @@ internal unsafe struct ICanvasEffectFactoryNative : IComObject
|
||||
public static readonly IntPtr AbiToProjectionVftablePtr = InitVtbl();
|
||||
|
||||
/// <summary>
|
||||
/// Builds the custom method table pointer for <see cref="Interface"/>.
|
||||
/// Builds the custom method table pointer for <see cref="ICanvasEffectFactoryNative"/>.
|
||||
/// </summary>
|
||||
/// <returns>The method table pointer for <see cref="Interface"/>.</returns>
|
||||
/// <returns>The method table pointer for <see cref="ICanvasEffectFactoryNative"/>.</returns>
|
||||
private static IntPtr InitVtbl()
|
||||
{
|
||||
Vftbl* lpVtbl = (Vftbl*)ComWrappersSupport.AllocateVtableMemory(typeof(Vftbl), sizeof(Vftbl));
|
||||
@@ -140,14 +157,14 @@ internal unsafe struct ICanvasEffectFactoryNative : IComObject
|
||||
/// </summary>
|
||||
private delegate* unmanaged[MemberFunction]<IntPtr, ICanvasDevice*, ID2D1Effect*, float, IInspectable**, int> CreateWrapper;
|
||||
|
||||
/// <inheritdoc cref="Interface.CreateWrapper"/>
|
||||
/// <inheritdoc cref="ICanvasEffectFactoryNative.CreateWrapper"/>
|
||||
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])]
|
||||
[return: NativeTypeName("HRESULT")]
|
||||
private static int CreateWrapperFromAbi(IntPtr thisPtr, ICanvasDevice* device, ID2D1Effect* resource, float dpi, IInspectable** wrapper)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ComWrappersSupport.FindObject<Interface>(thisPtr).CreateWrapper(device, resource, dpi, wrapper);
|
||||
return ComWrappersSupport.FindObject<ICanvasEffectFactoryNative>(thisPtr).CreateWrapper(device, resource, dpi, wrapper);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -2,11 +2,8 @@ using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.Win32;
|
||||
using WinRT;
|
||||
using WinRT.Interop;
|
||||
using IInspectable = ComputeSharp.Win32.IInspectable;
|
||||
|
||||
#pragma warning disable CS0649, IDE1006
|
||||
#pragma warning disable CS0649, IDE0055, IDE1006
|
||||
|
||||
namespace ABI.Microsoft.Graphics.Canvas;
|
||||
|
||||
@@ -15,8 +12,32 @@ namespace ABI.Microsoft.Graphics.Canvas;
|
||||
/// </summary>
|
||||
[NativeTypeName("class ICanvasFactoryNative : public IInspectable")]
|
||||
[NativeInheritance("IInspectable")]
|
||||
internal unsafe struct ICanvasFactoryNative
|
||||
internal unsafe struct ICanvasFactoryNative : IComObject
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public static Guid* IID
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
ReadOnlySpan<byte> data =
|
||||
[
|
||||
0x0D, 0x44, 0x5C, 0x69,
|
||||
0xB3, 0x04,
|
||||
0xDD, 0x4E,
|
||||
0xBF, 0xD9,
|
||||
0x63,
|
||||
0xE5,
|
||||
0x1E,
|
||||
0x9F,
|
||||
0x72,
|
||||
0x02
|
||||
];
|
||||
|
||||
return (Guid*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(data));
|
||||
}
|
||||
}
|
||||
|
||||
public void** lpVtbl;
|
||||
|
||||
/// <inheritdoc cref="IUnknown.QueryInterface"/>
|
||||
@@ -144,25 +165,4 @@ internal unsafe struct ICanvasFactoryNative
|
||||
(ICanvasFactoryNative*)Unsafe.AsPointer(ref this),
|
||||
effectId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The managed interface for <see cref="ICanvasFactoryNative"/>.
|
||||
/// </summary>
|
||||
[Guid("695C440D-04B3-4EDD-BFD9-63E51E9F7202")]
|
||||
[WindowsRuntimeType]
|
||||
[WindowsRuntimeHelperType(typeof(Interface))]
|
||||
public interface Interface
|
||||
{
|
||||
/// <summary>
|
||||
/// The vtable type for <see cref="Interface"/>.
|
||||
/// </summary>
|
||||
[Guid("695C440D-04B3-4EDD-BFD9-63E51E9F7202")]
|
||||
public readonly struct Vftbl
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows CsWinRT to retrieve a pointer to the projection vtable (the name is hardcoded by convention).
|
||||
/// </summary>
|
||||
public static readonly IntPtr AbiToProjectionVftablePtr = IUnknownVftbl.AbiToProjectionVftblPtr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.Win32;
|
||||
@@ -7,113 +8,137 @@ using WinRT.Interop;
|
||||
|
||||
#pragma warning disable CS0649, IDE0055, IDE1006
|
||||
|
||||
namespace ABI.Microsoft.Graphics.Canvas;
|
||||
|
||||
/// <summary>
|
||||
/// An interop Win2D interface for all images and effects that can be drawn.
|
||||
/// </summary>
|
||||
[NativeTypeName("class ICanvasImageInterop : IUnknown")]
|
||||
[NativeInheritance("IUnknown")]
|
||||
internal unsafe struct ICanvasImageInterop : IComObject
|
||||
namespace ABI.Microsoft.Graphics.Canvas
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
static Guid* IComObject.IID
|
||||
/// <summary>
|
||||
/// An interop Win2D interface for all images and effects that can be drawn.
|
||||
/// </summary>
|
||||
[NativeTypeName("class ICanvasImageInterop : IUnknown")]
|
||||
[NativeInheritance("IUnknown")]
|
||||
internal unsafe struct ICanvasImageInterop : IComObject
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
/// <inheritdoc/>
|
||||
public static Guid* IID
|
||||
{
|
||||
ReadOnlySpan<byte> data =
|
||||
[
|
||||
0xF7, 0xD1, 0x42, 0xE0,
|
||||
0xAD, 0xF9,
|
||||
0x79, 0x44,
|
||||
0xA7, 0x13,
|
||||
0x67,
|
||||
0x62,
|
||||
0x7E,
|
||||
0xA3,
|
||||
0x18,
|
||||
0x63
|
||||
];
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
ReadOnlySpan<byte> data =
|
||||
[
|
||||
0xF7, 0xD1, 0x42, 0xE0,
|
||||
0xAD, 0xF9,
|
||||
0x79, 0x44,
|
||||
0xA7, 0x13,
|
||||
0x67,
|
||||
0x62,
|
||||
0x7E,
|
||||
0xA3,
|
||||
0x18,
|
||||
0x63
|
||||
];
|
||||
|
||||
return (Guid*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(data));
|
||||
return (Guid*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(data));
|
||||
}
|
||||
}
|
||||
|
||||
public void** lpVtbl;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the device that the effect is currently realized on, if any.
|
||||
/// </summary>
|
||||
/// <param name="device">The resulting device, if available (as a marshalled <see cref="global::Microsoft.Graphics.Canvas.CanvasDevice"/>).</param>
|
||||
/// <param name="type">The <see cref="WIN2D_GET_DEVICE_ASSOCIATION_TYPE"/> value describing the returned instance.</param>
|
||||
/// <returns>The <see cref="HRESULT"/> for the operation.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(3)]
|
||||
public HRESULT GetDevice(ICanvasDevice** device, WIN2D_GET_DEVICE_ASSOCIATION_TYPE* type)
|
||||
{
|
||||
return ((delegate* unmanaged[MemberFunction]<ICanvasImageInterop*, ICanvasDevice**, WIN2D_GET_DEVICE_ASSOCIATION_TYPE*, int>)this.lpVtbl[3])((ICanvasImageInterop*)Unsafe.AsPointer(ref this), device, type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="ID2D1Image"/> from an <see cref="ICanvasImageInterop"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="device">The input canvas device (as a marshalled <see cref="global::Microsoft.Graphics.Canvas.CanvasDevice"/>).</param>
|
||||
/// <param name="deviceContext">
|
||||
/// The device context in use. This value is is optional (but recommended), except when the
|
||||
/// <see cref="WIN2D_GET_D2D_IMAGE_FLAGS.WIN2D_GET_D2D_IMAGE_FLAGS_READ_DPI_FROM_DEVICE_CONTEXT"/> flag is specified. This is because
|
||||
/// not all callers of <see cref="GetD2DImage"/> 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.
|
||||
/// </param>
|
||||
/// <param name="flags">The flags to use to get the image.</param>
|
||||
/// <param name="targetDpi">
|
||||
/// The DPI of the target device context. This is used to determine when a <c>D2D1DpiCompensation</c>
|
||||
/// effect needs to be inserted. Behavior of this parameter can be overridden by the flag values
|
||||
/// <see cref="WIN2D_GET_D2D_IMAGE_FLAGS.WIN2D_GET_D2D_IMAGE_FLAGS_READ_DPI_FROM_DEVICE_CONTEXT"/>,
|
||||
/// <see cref="WIN2D_GET_D2D_IMAGE_FLAGS.WIN2D_GET_D2D_IMAGE_FLAGS_ALWAYS_INSERT_DPI_COMPENSATION"/>
|
||||
/// or <see cref="WIN2D_GET_D2D_IMAGE_FLAGS.WIN2D_GET_D2D_IMAGE_FLAGS_NEVER_INSERT_DPI_COMPENSATION"/>
|
||||
/// </param>
|
||||
/// <param name="realizeDpi">
|
||||
/// The DPI of a source bitmap, or zero if the image does not have a fixed DPI. A <c>D2D1DpiCompensation</c> effect
|
||||
/// will be inserted if <paramref name="targetDpi"/> and <paramref name="realizeDpi"/> are different (flags permitting).
|
||||
/// </param>
|
||||
/// <param name="ppImage">The resulting <see cref="ID2D1Image"/> for the effect.</param>
|
||||
/// <returns>The <see cref="HRESULT"/> for the operation.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(4)]
|
||||
public HRESULT GetD2DImage(
|
||||
ICanvasDevice* device,
|
||||
ID2D1DeviceContext* deviceContext,
|
||||
WIN2D_GET_D2D_IMAGE_FLAGS flags,
|
||||
float targetDpi,
|
||||
float* realizeDpi,
|
||||
ID2D1Image** ppImage)
|
||||
{
|
||||
return ((delegate* unmanaged[MemberFunction]<ICanvasImageInterop*, ICanvasDevice*, ID2D1DeviceContext*, WIN2D_GET_D2D_IMAGE_FLAGS, float, float*, ID2D1Image**, int>)this.lpVtbl[4])(
|
||||
(ICanvasImageInterop*)Unsafe.AsPointer(ref this),
|
||||
device,
|
||||
deviceContext,
|
||||
flags,
|
||||
targetDpi,
|
||||
realizeDpi,
|
||||
ppImage);
|
||||
}
|
||||
}
|
||||
|
||||
public void** lpVtbl;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the device that the effect is currently realized on, if any.
|
||||
/// The ABI methods for <see cref="ICanvasImageInterop"/>.
|
||||
/// </summary>
|
||||
/// <param name="device">The resulting device, if available (as a marshalled <see cref="global::Microsoft.Graphics.Canvas.CanvasDevice"/>).</param>
|
||||
/// <param name="type">The <see cref="WIN2D_GET_DEVICE_ASSOCIATION_TYPE"/> value describing the returned instance.</param>
|
||||
/// <returns>The <see cref="HRESULT"/> for the operation.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(3)]
|
||||
public HRESULT GetDevice(ICanvasDevice** device, WIN2D_GET_DEVICE_ASSOCIATION_TYPE* type)
|
||||
/// <remarks>
|
||||
/// This type has public accessibility to allow the AOT generator in CsWinRT to reference
|
||||
/// the <see cref="IID"/> and <see cref="AbiToProjectionVftablePtr"/> properties to make
|
||||
/// marshalling of CCW types AOT-safe. It is not meant to be used directly by developers.
|
||||
/// </remarks>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static unsafe class ICanvasImageInteropMethods
|
||||
{
|
||||
return ((delegate* unmanaged[MemberFunction]<ICanvasImageInterop*, ICanvasDevice**, WIN2D_GET_DEVICE_ASSOCIATION_TYPE*, int>)this.lpVtbl[3])((ICanvasImageInterop*)Unsafe.AsPointer(ref this), device, type);
|
||||
/// <inheritdoc cref="ICanvasImageInterop.IID"/>
|
||||
public static Guid IID => *ICanvasImageInterop.IID;
|
||||
|
||||
/// <inheritdoc cref="global::Microsoft.Graphics.Canvas.ICanvasImageInterop.Vftbl.AbiToProjectionVftablePtr"/>
|
||||
public static IntPtr AbiToProjectionVftablePtr => global::Microsoft.Graphics.Canvas.ICanvasImageInterop.Vftbl.AbiToProjectionVftablePtr;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Microsoft.Graphics.Canvas
|
||||
{
|
||||
using ABI.Microsoft.Graphics.Canvas;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="ID2D1Image"/> from an <see cref="Interface"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="device">The input canvas device (as a marshalled <see cref="global::Microsoft.Graphics.Canvas.CanvasDevice"/>).</param>
|
||||
/// <param name="deviceContext">
|
||||
/// The device context in use. This value is is optional (but recommended), except when the
|
||||
/// <see cref="WIN2D_GET_D2D_IMAGE_FLAGS.WIN2D_GET_D2D_IMAGE_FLAGS_READ_DPI_FROM_DEVICE_CONTEXT"/> flag is specified. This is because
|
||||
/// not all callers of <see cref="GetD2DImage"/> 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.
|
||||
/// </param>
|
||||
/// <param name="flags">The flags to use to get the image.</param>
|
||||
/// <param name="targetDpi">
|
||||
/// The DPI of the target device context. This is used to determine when a <c>D2D1DpiCompensation</c>
|
||||
/// effect needs to be inserted. Behavior of this parameter can be overridden by the flag values
|
||||
/// <see cref="WIN2D_GET_D2D_IMAGE_FLAGS.WIN2D_GET_D2D_IMAGE_FLAGS_READ_DPI_FROM_DEVICE_CONTEXT"/>,
|
||||
/// <see cref="WIN2D_GET_D2D_IMAGE_FLAGS.WIN2D_GET_D2D_IMAGE_FLAGS_ALWAYS_INSERT_DPI_COMPENSATION"/>
|
||||
/// or <see cref="WIN2D_GET_D2D_IMAGE_FLAGS.WIN2D_GET_D2D_IMAGE_FLAGS_NEVER_INSERT_DPI_COMPENSATION"/>
|
||||
/// </param>
|
||||
/// <param name="realizeDpi">
|
||||
/// The DPI of a source bitmap, or zero if the image does not have a fixed DPI. A <c>D2D1DpiCompensation</c> effect
|
||||
/// will be inserted if <paramref name="targetDpi"/> and <paramref name="realizeDpi"/> are different (flags permitting).
|
||||
/// </param>
|
||||
/// <param name="ppImage">The resulting <see cref="ID2D1Image"/> for the effect.</param>
|
||||
/// <returns>The <see cref="HRESULT"/> for the operation.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(4)]
|
||||
public HRESULT GetD2DImage(
|
||||
ICanvasDevice* device,
|
||||
ID2D1DeviceContext* deviceContext,
|
||||
WIN2D_GET_D2D_IMAGE_FLAGS flags,
|
||||
float targetDpi,
|
||||
float* realizeDpi,
|
||||
ID2D1Image** ppImage)
|
||||
{
|
||||
return ((delegate* unmanaged[MemberFunction]<ICanvasImageInterop*, ICanvasDevice*, ID2D1DeviceContext*, WIN2D_GET_D2D_IMAGE_FLAGS, float, float*, ID2D1Image**, int>)this.lpVtbl[4])(
|
||||
(ICanvasImageInterop*)Unsafe.AsPointer(ref this),
|
||||
device,
|
||||
deviceContext,
|
||||
flags,
|
||||
targetDpi,
|
||||
realizeDpi,
|
||||
ppImage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The managed implementation of <see cref="ICanvasImageInterop"/>.
|
||||
/// The managed implementation of <see cref="ABI.Microsoft.Graphics.Canvas.ICanvasImageInterop"/>.
|
||||
/// </summary>
|
||||
[Guid("E042D1F7-F9AD-4479-A713-67627EA31863")]
|
||||
[WindowsRuntimeType]
|
||||
[WindowsRuntimeHelperType(typeof(Interface))]
|
||||
public interface Interface
|
||||
[WindowsRuntimeHelperType(typeof(ICanvasImageInterop))]
|
||||
internal unsafe interface ICanvasImageInterop
|
||||
{
|
||||
/// <inheritdoc cref="ICanvasImageInterop.GetDevice"/>
|
||||
/// <inheritdoc cref="ABI.Microsoft.Graphics.Canvas.ICanvasImageInterop.GetDevice"/>
|
||||
[return: NativeTypeName("HRESULT")]
|
||||
int GetDevice(ICanvasDevice** device, WIN2D_GET_DEVICE_ASSOCIATION_TYPE* type);
|
||||
|
||||
/// <inheritdoc cref="ICanvasImageInterop.GetD2DImage"/>
|
||||
/// <inheritdoc cref="ABI.Microsoft.Graphics.Canvas.ICanvasImageInterop.GetD2DImage"/>
|
||||
[return: NativeTypeName("HRESULT")]
|
||||
int GetD2DImage(
|
||||
ICanvasDevice* device,
|
||||
@@ -124,9 +149,8 @@ internal unsafe struct ICanvasImageInterop : IComObject
|
||||
ID2D1Image** ppImage);
|
||||
|
||||
/// <summary>
|
||||
/// The vtable type for <see cref="Interface"/>.
|
||||
/// The vtable type for <see cref="ICanvasImageInterop"/>.
|
||||
/// </summary>
|
||||
[Guid("E042D1F7-F9AD-4479-A713-67627EA31863")]
|
||||
public struct Vftbl
|
||||
{
|
||||
/// <summary>
|
||||
@@ -135,9 +159,9 @@ internal unsafe struct ICanvasImageInterop : IComObject
|
||||
public static readonly IntPtr AbiToProjectionVftablePtr = InitVtbl();
|
||||
|
||||
/// <summary>
|
||||
/// Builds the custom method table pointer for <see cref="Interface"/>.
|
||||
/// Builds the custom method table pointer for <see cref="ICanvasImageInterop"/>.
|
||||
/// </summary>
|
||||
/// <returns>The method table pointer for <see cref="Interface"/>.</returns>
|
||||
/// <returns>The method table pointer for <see cref="ICanvasImageInterop"/>.</returns>
|
||||
private static IntPtr InitVtbl()
|
||||
{
|
||||
Vftbl* lpVtbl = (Vftbl*)ComWrappersSupport.AllocateVtableMemory(typeof(Vftbl), sizeof(Vftbl));
|
||||
@@ -164,14 +188,14 @@ internal unsafe struct ICanvasImageInterop : IComObject
|
||||
/// </summary>
|
||||
private delegate* unmanaged[MemberFunction]<IntPtr, ICanvasDevice*, ID2D1DeviceContext*, WIN2D_GET_D2D_IMAGE_FLAGS, float, float*, ID2D1Image**, int> GetD2DImage;
|
||||
|
||||
/// <inheritdoc cref="Interface.GetDevice"/>
|
||||
/// <inheritdoc cref="ICanvasImageInterop.GetDevice"/>
|
||||
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])]
|
||||
[return: NativeTypeName("HRESULT")]
|
||||
private static int GetDeviceFromAbi(IntPtr thisPtr, ICanvasDevice** device, WIN2D_GET_DEVICE_ASSOCIATION_TYPE* type)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ComWrappersSupport.FindObject<Interface>(thisPtr).GetDevice(device, type);
|
||||
return ComWrappersSupport.FindObject<ICanvasImageInterop>(thisPtr).GetDevice(device, type);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -181,7 +205,7 @@ internal unsafe struct ICanvasImageInterop : IComObject
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Interface.GetDevice"/>
|
||||
/// <inheritdoc cref="ICanvasImageInterop.GetDevice"/>
|
||||
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])]
|
||||
[return: NativeTypeName("HRESULT")]
|
||||
private static int GetD2DImageFromAbi(
|
||||
@@ -195,7 +219,7 @@ internal unsafe struct ICanvasImageInterop : IComObject
|
||||
{
|
||||
try
|
||||
{
|
||||
return ComWrappersSupport.FindObject<Interface>(thisPtr).GetD2DImage(device, deviceContext, flags, targetDpi, realizeDpi, ppImage);
|
||||
return ComWrappersSupport.FindObject<ICanvasImageInterop>(thisPtr).GetD2DImage(device, deviceContext, flags, targetDpi, realizeDpi, ppImage);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ using System;
|
||||
namespace ABI.Microsoft.Graphics.Canvas;
|
||||
|
||||
/// <summary>
|
||||
/// Options for fine-tuning the behavior of <see cref="ICanvasImageInterop.Interface.GetD2DImage"/>.
|
||||
/// Options for fine-tuning the behavior of <see cref="ICanvasImageInterop.GetD2DImage"/>.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
internal enum WIN2D_GET_D2D_IMAGE_FLAGS : uint
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ using System;
|
||||
namespace ABI.Microsoft.Graphics.Canvas;
|
||||
|
||||
/// <summary>
|
||||
/// Options for fine-tuning the behavior of <see cref="ICanvasImageInterop.Interface.GetDevice"/>.
|
||||
/// Options for fine-tuning the behavior of <see cref="ICanvasImageInterop.GetDevice"/>.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
internal enum WIN2D_GET_DEVICE_ASSOCIATION_TYPE : uint
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace ComputeSharp.D2D1.WinUI.Buffers;
|
||||
internal unsafe struct SourceReference : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="ID2D1Image"/> produced by calling <see cref="ICanvasImageInterop.Interface.GetD2DImage"/>
|
||||
/// The <see cref="ID2D1Image"/> produced by calling <see cref="ICanvasImageInterop.GetD2DImage"/>
|
||||
/// on the input managed wrapper used as source for the effect (ie. <see cref="graphicsEffectSourceWrapper"/>).
|
||||
/// </summary>
|
||||
private ComPtr<ID2D1Image> d2D1ImageSource;
|
||||
|
||||
@@ -7,6 +7,7 @@ using ComputeSharp.D2D1.WinUI.Helpers;
|
||||
using ComputeSharp.Win32;
|
||||
using Microsoft.Graphics.Canvas;
|
||||
using Windows.Foundation;
|
||||
using ICanvasImageInterop = Microsoft.Graphics.Canvas.ICanvasImageInterop;
|
||||
using ICanvasResourceCreator = Microsoft.Graphics.Canvas.ICanvasResourceCreator;
|
||||
|
||||
namespace ComputeSharp.D2D1.WinUI;
|
||||
@@ -27,9 +28,9 @@ partial class CanvasEffect
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
unsafe int ICanvasImageInterop.Interface.GetDevice(ICanvasDevice** device, WIN2D_GET_DEVICE_ASSOCIATION_TYPE* type)
|
||||
unsafe int ICanvasImageInterop.GetDevice(ICanvasDevice** device, WIN2D_GET_DEVICE_ASSOCIATION_TYPE* type)
|
||||
{
|
||||
using ComPtr<ICanvasImageInterop> canvasImageInterop = default;
|
||||
using ComPtr<global::ABI.Microsoft.Graphics.Canvas.ICanvasImageInterop> canvasImageInterop = default;
|
||||
|
||||
RcwMarshaller.GetNativeInterface(GetCanvasImage(), canvasImageInterop.GetAddressOf()).Assert();
|
||||
|
||||
@@ -37,7 +38,7 @@ partial class CanvasEffect
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
unsafe int ICanvasImageInterop.Interface.GetD2DImage(
|
||||
unsafe int ICanvasImageInterop.GetD2DImage(
|
||||
ICanvasDevice* device,
|
||||
ID2D1DeviceContext* deviceContext,
|
||||
WIN2D_GET_D2D_IMAGE_FLAGS flags,
|
||||
@@ -45,7 +46,7 @@ partial class CanvasEffect
|
||||
float* realizeDpi,
|
||||
ID2D1Image** ppImage)
|
||||
{
|
||||
using ComPtr<ICanvasImageInterop> canvasImageInterop = default;
|
||||
using ComPtr<global::ABI.Microsoft.Graphics.Canvas.ICanvasImageInterop> canvasImageInterop = default;
|
||||
|
||||
RcwMarshaller.GetNativeInterface(GetCanvasImage(), canvasImageInterop.GetAddressOf()).Assert();
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ABI.Microsoft.Graphics.Canvas;
|
||||
using Microsoft.Graphics.Canvas;
|
||||
|
||||
namespace ComputeSharp.D2D1.WinUI;
|
||||
@@ -9,7 +8,7 @@ namespace ComputeSharp.D2D1.WinUI;
|
||||
/// <summary>
|
||||
/// A base type to implement packaged and easy to use <see cref="ICanvasImage"/>-based effects that can be used with Win2D.
|
||||
/// </summary>
|
||||
public abstract partial class CanvasEffect : ICanvasImage, ICanvasImageInterop.Interface
|
||||
public abstract partial class CanvasEffect : ICanvasImage, ICanvasImageInterop
|
||||
{
|
||||
/// <summary>
|
||||
/// The mapping of registered transform nodes for the current effect graph.
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace ComputeSharp.D2D1.WinUI.Collections;
|
||||
/// An interface for a list with a fixed collection.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of elements in the list.</typeparam>
|
||||
interface IFixedCountList<T>
|
||||
internal interface IFixedCountList<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the collection of valid indices for the current effect.
|
||||
|
||||
@@ -2,12 +2,20 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<WindowsSdkPackageVersion>10.0.22621.35-preview</WindowsSdkPackageVersion>
|
||||
<Platforms>x64;ARM64</Platforms>
|
||||
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
<!--
|
||||
Disable IIDOptimizer, as it's causing a build error when the debug mode is set to embedded.
|
||||
This is only needed when generating projections anyway, and not in normal C# class libraries.
|
||||
See: https://github.com/microsoft/CsWinRT/issues/1478.
|
||||
-->
|
||||
<CsWinRTIIDOptimizerOptOut>true</CsWinRTIIDOptimizerOptOut>
|
||||
|
||||
<!--
|
||||
Ignore some warnings about ambiguous cref attribute references. These are because the assembly defines
|
||||
blittable bindings for several ABI types from Win2D, in the same namespace as the ABI types from the
|
||||
@@ -25,7 +33,13 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.2.0" />
|
||||
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.2.1-experimental1" />
|
||||
|
||||
<!--
|
||||
We need the CsWinRT reference for the generator to kick in and generate all necessary supporting code
|
||||
to make the exposed types AOT compatible. Since we only need the generator, we can mark this as private.
|
||||
-->
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.0-prerelease.240602.1" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ComputeSharp.Win32;
|
||||
using WinRT;
|
||||
using IInspectable = ComputeSharp.Win32.IInspectable;
|
||||
@@ -31,7 +30,7 @@ internal static unsafe class RcwMarshaller
|
||||
/// <param name="managedObject">The input RCW instance to unwrap.</param>
|
||||
/// <param name="nativeObject">A pointer to the resulting native object to retrieve.</param>
|
||||
/// <remarks>This method should only be called with <typeparamref name="T"/> being a concrete projected type.</remarks>
|
||||
public static void GetNativeObject<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors | DynamicallyAccessedMemberTypes.Interfaces)] T>(T managedObject, IInspectable** nativeObject)
|
||||
public static void GetNativeObject<T>(T managedObject, IInspectable** nativeObject)
|
||||
where T : class
|
||||
{
|
||||
*nativeObject = (IInspectable*)MarshalInspectable<T>.FromManaged(managedObject);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ABI.Microsoft.Graphics.Canvas;
|
||||
using ComputeSharp.D2D1.Extensions;
|
||||
using ComputeSharp.Win32;
|
||||
@@ -9,6 +8,7 @@ using WinRT;
|
||||
namespace ComputeSharp.D2D1.WinUI.Helpers;
|
||||
|
||||
using CanvasDevice = Microsoft.Graphics.Canvas.CanvasDevice;
|
||||
using ICanvasEffectFactoryNative = Microsoft.Graphics.Canvas.ICanvasEffectFactoryNative;
|
||||
using IInspectable = Win32.IInspectable;
|
||||
|
||||
/// <summary>
|
||||
@@ -51,7 +51,7 @@ internal static unsafe class ResourceManager
|
||||
/// </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>
|
||||
public static void RegisterWrapper<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors | DynamicallyAccessedMemberTypes.Interfaces)] T>(IUnknown* resource, T wrapper)
|
||||
public static void RegisterWrapper<T>(IUnknown* resource, T wrapper)
|
||||
where T : class
|
||||
{
|
||||
using ComPtr<ICanvasFactoryNative> canvasFactoryNative = default;
|
||||
@@ -86,13 +86,13 @@ internal static unsafe class ResourceManager
|
||||
/// </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>
|
||||
public static void RegisterEffectFactory(Guid effectId, ICanvasEffectFactoryNative.Interface factory)
|
||||
public static void RegisterEffectFactory(Guid effectId, ICanvasEffectFactoryNative factory)
|
||||
{
|
||||
using ComPtr<ICanvasFactoryNative> canvasFactoryNative = default;
|
||||
|
||||
GetActivationFactory(canvasFactoryNative.GetAddressOf());
|
||||
|
||||
using ComPtr<ICanvasEffectFactoryNative> canvasEffectFactoryNative = default;
|
||||
using ComPtr<ABI.Microsoft.Graphics.Canvas.ICanvasEffectFactoryNative> canvasEffectFactoryNative = default;
|
||||
|
||||
RcwMarshaller.GetNativeInterface(factory, canvasEffectFactoryNative.GetAddressOf()).Assert();
|
||||
|
||||
@@ -106,12 +106,14 @@ internal static unsafe class ResourceManager
|
||||
/// <param name="factoryNative">A pointer to the resulting activation factory.</param>
|
||||
private static void GetActivationFactory(ICanvasFactoryNative** factoryNative)
|
||||
{
|
||||
// On WinUI 3, the types are not guaranteed to be registered for activation. Additionally,
|
||||
// for concistency with other types, we just use the built-in T.As<I>() method, which will
|
||||
const string ActivatableClassId = "Microsoft.Graphics.Canvas.CanvasDevice";
|
||||
|
||||
// On WinUI 3, the types are not guaranteed to be registered for activation. Additionally, for
|
||||
// concistency with other types, we just use the built-in ActivationFactory type, which will
|
||||
// automatically handle fallback logic to resolve types to activate if they're not registered.
|
||||
// For instance, this will ensure the following call will work fine in unpackaged apps.
|
||||
ICanvasFactoryNative.Interface canvasDeviceActivationFactory = CanvasDevice.As<ICanvasFactoryNative.Interface>();
|
||||
using IObjectReference canvasDeviceActivationFactory = ActivationFactory.Get(ActivatableClassId, *ICanvasFactoryNative.IID);
|
||||
|
||||
*factoryNative = (ICanvasFactoryNative*)MarshalInterface<ICanvasFactoryNative.Interface>.FromManaged(canvasDeviceActivationFactory);
|
||||
*factoryNative = (ICanvasFactoryNative*)canvasDeviceActivationFactory.GetRef();
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,12 @@ using ComputeSharp.D2D1.Extensions;
|
||||
using ComputeSharp.D2D1.WinUI.Extensions;
|
||||
using ComputeSharp.D2D1.WinUI.Helpers;
|
||||
using ComputeSharp.Win32;
|
||||
using ICanvasEffectFactoryNative = Microsoft.Graphics.Canvas.ICanvasEffectFactoryNative;
|
||||
|
||||
namespace ComputeSharp.D2D1.WinUI;
|
||||
|
||||
/// <inheritdoc/>
|
||||
unsafe partial class PixelShaderEffect<T>
|
||||
partial class PixelShaderEffect<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// A manager type to handle the effect factory registration logic for <see cref="ICanvasEffectFactoryNative"/>.
|
||||
@@ -74,10 +75,14 @@ unsafe partial class PixelShaderEffect<T>
|
||||
/// <summary>
|
||||
/// A managed implementation of <see cref="ICanvasEffectFactoryNative"/> for <see cref="PixelShaderEffect{T}"/>.
|
||||
/// </summary>
|
||||
private sealed class EffectFactory : ICanvasEffectFactoryNative.Interface
|
||||
/// <remarks>
|
||||
/// This type is partial even though there are no other explicit partial type declarations in the project, so the CsWinRT
|
||||
/// generator can generate one using <see cref="WinRT.WinRTExposedTypeAttribute"/> and the precomputed vtable entries.
|
||||
/// </remarks>
|
||||
internal sealed unsafe partial class EffectFactory : ICanvasEffectFactoryNative
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
int ICanvasEffectFactoryNative.Interface.CreateWrapper(ICanvasDevice* device, ID2D1Effect* resource, float dpi, IInspectable** wrapper)
|
||||
int ICanvasEffectFactoryNative.CreateWrapper(ICanvasDevice* device, ID2D1Effect* resource, float dpi, IInspectable** wrapper)
|
||||
{
|
||||
PixelShaderEffect<T> @this;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ using ComputeSharp.Win32;
|
||||
using Windows.Graphics.Effects;
|
||||
using static ABI.Microsoft.Graphics.Canvas.WIN2D_GET_D2D_IMAGE_FLAGS;
|
||||
using static ABI.Microsoft.Graphics.Canvas.WIN2D_GET_DEVICE_ASSOCIATION_TYPE;
|
||||
using ICanvasImageInterop = Microsoft.Graphics.Canvas.ICanvasImageInterop;
|
||||
|
||||
namespace ComputeSharp.D2D1.WinUI;
|
||||
|
||||
@@ -18,7 +19,7 @@ namespace ComputeSharp.D2D1.WinUI;
|
||||
unsafe partial class PixelShaderEffect<T>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
int ICanvasImageInterop.Interface.GetDevice(ICanvasDevice** device, WIN2D_GET_DEVICE_ASSOCIATION_TYPE* type)
|
||||
int ICanvasImageInterop.GetDevice(ICanvasDevice** device, WIN2D_GET_DEVICE_ASSOCIATION_TYPE* type)
|
||||
{
|
||||
// Validate all input parameters
|
||||
if (device is null || type is null)
|
||||
@@ -71,7 +72,7 @@ unsafe partial class PixelShaderEffect<T>
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
int ICanvasImageInterop.Interface.GetD2DImage(
|
||||
int ICanvasImageInterop.GetD2DImage(
|
||||
ICanvasDevice* device,
|
||||
ID2D1DeviceContext* deviceContext,
|
||||
WIN2D_GET_D2D_IMAGE_FLAGS flags,
|
||||
@@ -361,7 +362,7 @@ unsafe partial class PixelShaderEffect<T>
|
||||
}
|
||||
else
|
||||
{
|
||||
using ComPtr<ICanvasImageInterop> canvasImageInterop = default;
|
||||
using ComPtr<global::ABI.Microsoft.Graphics.Canvas.ICanvasImageInterop> canvasImageInterop = default;
|
||||
|
||||
// Convert to ICanvasImageInterop (this must always succeed, and throws if it doesn't)
|
||||
RcwMarshaller.GetNativeInterface(source, canvasImageInterop.GetAddressOf()).Assert();
|
||||
|
||||
+1
@@ -18,6 +18,7 @@ partial class PixelShaderEffect<T>
|
||||
/// <summary>
|
||||
/// Represents the collection of <see cref="D2D1ResourceTextureManager"/> objects in a <see cref="PixelShaderEffect{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <remarks><inheritdoc cref="EffectFactory" path="/remarks/node()"/></remarks>
|
||||
public sealed class ResourceTextureManagerCollection : IList<D2D1ResourceTextureManager?>, IReadOnlyList<D2D1ResourceTextureManager?>, IList, IFixedCountList<D2D1ResourceTextureManager?>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -16,6 +16,7 @@ partial class PixelShaderEffect<T>
|
||||
/// <summary>
|
||||
/// Represents the collection of <see cref="IGraphicsEffectSource"/> sources in a <see cref="PixelShaderEffect{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <remarks><inheritdoc cref="EffectFactory" path="/remarks/node()"/></remarks>
|
||||
public sealed class SourceCollection : IList<IGraphicsEffectSource?>, IReadOnlyList<IGraphicsEffectSource?>, IList, IFixedCountList<IGraphicsEffectSource?>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -43,7 +43,7 @@ partial class PixelShaderEffect<T>
|
||||
{
|
||||
// When the effect is disposed, we also unregister it from the resource manager cache. This
|
||||
// is analogous to what is done when manually unrealizing the effect (eg. when using a new
|
||||
// device. Without this call, the resource manager would keep registered effects alive for
|
||||
// device). Without this call, the resource manager would keep registered effects alive for
|
||||
// the entire process duration, even if their original wrappers are gone (ie. collected).
|
||||
if (this.d2D1Effect.Get() is not null)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ABI.Microsoft.Graphics.Canvas;
|
||||
using ComputeSharp.D2D1.Descriptors;
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
@@ -6,6 +5,7 @@ using ComputeSharp.Interop;
|
||||
using ComputeSharp.Win32;
|
||||
using Microsoft.Graphics.Canvas;
|
||||
using Microsoft.Graphics.Canvas.Effects;
|
||||
using ICanvasImageInterop = Microsoft.Graphics.Canvas.ICanvasImageInterop;
|
||||
|
||||
namespace ComputeSharp.D2D1.WinUI;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace ComputeSharp.D2D1.WinUI;
|
||||
/// A custom <see cref="ICanvasEffect"/> implementation powered by a supplied shader type.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of shader to use to render frames.</typeparam>
|
||||
public sealed partial class PixelShaderEffect<T> : IReferenceTrackedObject, ICanvasEffect, ICanvasImageInterop.Interface
|
||||
public sealed partial class PixelShaderEffect<T> : IReferenceTrackedObject, ICanvasEffect, ICanvasImageInterop
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
/// <summary>
|
||||
@@ -27,7 +27,7 @@ public sealed partial class PixelShaderEffect<T> : IReferenceTrackedObject, ICan
|
||||
private readonly object lockObject = new();
|
||||
|
||||
/// <summary>
|
||||
/// Flag to track whether a given call is recursively invoked by <see cref="ICanvasImageInterop.Interface.GetD2DImage"/>, to avoid graph cycles.
|
||||
/// Flag to track whether a given call is recursively invoked by <see cref="ICanvasImageInterop.GetD2DImage"/>, to avoid graph cycles.
|
||||
/// </summary>
|
||||
private volatile int isInsideGetD2DImage;
|
||||
|
||||
@@ -69,14 +69,6 @@ public sealed partial class PixelShaderEffect<T> : IReferenceTrackedObject, ICan
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PixelShaderEffect{T}"/> instance.
|
||||
/// </summary>
|
||||
// Workaround for trimming bug in custom COM/WinRT components with CsWinRT. Without manually preserving metadata for
|
||||
// these types, using them will throw an InvalidCastException (see https://github.com/microsoft/CsWinRT/issues/1319).
|
||||
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICanvasImageInterop.Interface))]
|
||||
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICanvasImageInterop.Interface.Vftbl))]
|
||||
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICanvasFactoryNative.Interface))]
|
||||
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICanvasFactoryNative.Interface.Vftbl))]
|
||||
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICanvasEffectFactoryNative.Interface))]
|
||||
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICanvasEffectFactoryNative.Interface.Vftbl))]
|
||||
public PixelShaderEffect()
|
||||
{
|
||||
using ReferenceTracker.Lease _0 = ReferenceTracker.Create(this, out this.referenceTracker);
|
||||
|
||||
@@ -2,12 +2,22 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<WindowsSdkPackageVersion>10.0.22621.35-preview</WindowsSdkPackageVersion>
|
||||
<Platforms>x64;ARM64</Platforms>
|
||||
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
<!-- Disable IIDOptimizer, as it's not needed (see comments in ComputeSharp.D2D1.WinUI)-->
|
||||
<CsWinRTIIDOptimizerOptOut>true</CsWinRTIIDOptimizerOptOut>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240428000" />
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240531000-experimental1" />
|
||||
|
||||
<!-- Reference CsWinRT locally for the source generators (see comments in ComputeSharp.D2D1.WinUI) -->
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.0-prerelease.240602.1" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<WindowsSdkPackageVersion>10.0.22621.35-preview</WindowsSdkPackageVersion>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<Platforms>x64;ARM64</Platforms>
|
||||
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
|
||||
|
||||
@@ -4,7 +4,6 @@ using Microsoft.Graphics.Canvas;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
using WinRT;
|
||||
using WinRT.Interop;
|
||||
|
||||
namespace ComputeSharp.D2D1.WinUI.Tests.Helpers;
|
||||
|
||||
@@ -21,20 +20,15 @@ internal static class Win2DHelper
|
||||
/// <returns>The resulting managed wrapper for <paramref name="d2D1Image"/>.</returns>
|
||||
public static unsafe object GetOrCreate(ID2D1Image* d2D1Image, CanvasDevice? canvasDevice = null)
|
||||
{
|
||||
using ComPtr<IUnknown> activationFactoryUnknown = default;
|
||||
|
||||
ICanvasFactoryNative activationFactory = CanvasDevice.As<ICanvasFactoryNative>();
|
||||
|
||||
activationFactoryUnknown.Attach((IUnknown*)MarshalInterface<ICanvasFactoryNative>.FromManaged(activationFactory));
|
||||
|
||||
using ComPtr<IUnknown> canvasFactoryNativeUnknown = default;
|
||||
|
||||
Guid uuidOfCanvasFactoryNativeUnknown = new("695C440D-04B3-4EDD-BFD9-63E51E9F7202");
|
||||
|
||||
//Get the ICanvasFactoryNative object
|
||||
int hresult = activationFactoryUnknown.CopyTo(&uuidOfCanvasFactoryNativeUnknown, (void**)canvasFactoryNativeUnknown.GetAddressOf());
|
||||
|
||||
Marshal.ThrowExceptionForHR(hresult);
|
||||
// Get the ICanvasFactoryNative object
|
||||
using (IObjectReference canvasDeviceActivationFactory = ActivationFactory.Get(
|
||||
typeName: "Microsoft.Graphics.Canvas.CanvasDevice",
|
||||
iid: new Guid("695C440D-04B3-4EDD-BFD9-63E51E9F7202")))
|
||||
{
|
||||
canvasFactoryNativeUnknown.Attach((IUnknown*)canvasDeviceActivationFactory.GetRef());
|
||||
}
|
||||
|
||||
using ComPtr<IUnknown> canvasDeviceUnknown = default;
|
||||
|
||||
@@ -43,6 +37,8 @@ internal static class Win2DHelper
|
||||
canvasDeviceUnknown.Attach((IUnknown*)MarshalInspectable<CanvasDevice>.FromManaged(canvasDevice));
|
||||
}
|
||||
|
||||
int hresult;
|
||||
|
||||
using ComPtr<IUnknown> canvasDeviceInterfaceUnknown = default;
|
||||
|
||||
if (canvasDevice is not null)
|
||||
@@ -51,6 +47,8 @@ internal static class Win2DHelper
|
||||
|
||||
// Get the ICanvasDevice object (as an IUnknown* as well)
|
||||
hresult = canvasDeviceUnknown.CopyTo(&uuidOfCanvasDeviceInterface, (void**)canvasDeviceInterfaceUnknown.GetAddressOf());
|
||||
|
||||
Marshal.ThrowExceptionForHR(hresult);
|
||||
}
|
||||
|
||||
using ComPtr<IUnknown> wrapperUnknown = default;
|
||||
@@ -115,25 +113,4 @@ internal static class Win2DHelper
|
||||
|
||||
Marshal.ThrowExceptionForHR(hresult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The managed interface for <see cref="ICanvasFactoryNative"/>.
|
||||
/// </summary>
|
||||
[Guid("695C440D-04B3-4EDD-BFD9-63E51E9F7202")]
|
||||
[WindowsRuntimeType]
|
||||
[WindowsRuntimeHelperType(typeof(ICanvasFactoryNative))]
|
||||
public interface ICanvasFactoryNative
|
||||
{
|
||||
/// <summary>
|
||||
/// The vtable type for <see cref="ICanvasFactoryNative"/>.
|
||||
/// </summary>
|
||||
[Guid("695C440D-04B3-4EDD-BFD9-63E51E9F7202")]
|
||||
public readonly struct Vftbl
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows CsWinRT to retrieve a pointer to the projection vtable (the name is hardcoded by convention).
|
||||
/// </summary>
|
||||
public static readonly IntPtr AbiToProjectionVftablePtr = IUnknownVftbl.AbiToProjectionVftblPtr;
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする