Add WASDK test project

このコミットが含まれているのは:
Sergio Pedri committed 2023-04-27 03:36:50 +02:00
1 親 50c60ec544
コミット b8aab80dbd
8ファイル変更
+115 -3

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

+4
ファイルの表示
@@ -1,4 +1,8 @@
#if WINDOWS_UWP
using ComputeSharp.D2D1.Uwp;
#else
using ComputeSharp.D2D1.WinUI;
#endif
using Microsoft.Graphics.Canvas;
using Microsoft.VisualStudio.TestTools.UnitTesting;
+53 -2
ファイルの表示
@@ -1,9 +1,15 @@
using System;
using System.Runtime.InteropServices;
#if WINDOWS_UWP
using System.Runtime.InteropServices.WindowsRuntime;
#endif
using Microsoft.Graphics.Canvas;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
#if !WINDOWS_UWP
using WinRT;
using WinRT.Interop;
#endif
#nullable enable
@@ -22,11 +28,17 @@ internal static class Win2DHelper
/// <returns>The resulting managed wrapper for <paramref name="d2D1Image"/>.</returns>
public static unsafe object GetOrCreate(ID2D1Image* d2D1Image, CanvasDevice? canvasDevice = null)
{
IActivationFactory activationFactory = WindowsRuntimeMarshal.GetActivationFactory(typeof(CanvasDevice));
using ComPtr<IUnknown> activationFactoryUnknown = default;
#if WINDOWS_UWP
IActivationFactory activationFactory = WindowsRuntimeMarshal.GetActivationFactory(typeof(CanvasDevice));
activationFactoryUnknown.Attach((IUnknown*)Marshal.GetIUnknownForObject(activationFactory));
#else
ICanvasFactoryNative activationFactory = CanvasDevice.As<ICanvasFactoryNative>();
activationFactoryUnknown.Attach((IUnknown*)MarshalInterface<ICanvasFactoryNative>.FromManaged(activationFactory));
#endif
using ComPtr<IUnknown> canvasFactoryNativeUnknown = default;
@@ -41,7 +53,11 @@ internal static class Win2DHelper
if (canvasDevice is not null)
{
#if WINDOWS_UWP
canvasDeviceUnknown.Attach((IUnknown*)Marshal.GetIUnknownForObject(canvasDevice));
#else
canvasDeviceUnknown.Attach((IUnknown*)MarshalInspectable<CanvasDevice>.FromManaged(canvasDevice));
#endif
}
using ComPtr<IUnknown> canvasDeviceInterfaceUnknown = default;
@@ -67,7 +83,11 @@ internal static class Win2DHelper
Marshal.ThrowExceptionForHR(hresult);
// Get or create a managed object for the native object
#if WINDOWS_UWP
return Marshal.GetObjectForIUnknown((IntPtr)wrapperUnknown.Get());
#else
return MarshalInspectable<object>.FromAbi((IntPtr)wrapperUnknown.Get());
#endif
}
/// <summary>
@@ -80,7 +100,11 @@ internal static class Win2DHelper
{
using ComPtr<IUnknown> effectUnknown = default;
#if WINDOWS_UWP
effectUnknown.Attach((IUnknown*)Marshal.GetIUnknownForObject(canvasImage));
#else
effectUnknown.Attach((IUnknown*)MarshalInterface<ICanvasImage>.FromManaged(canvasImage));
#endif
using ComPtr<IUnknown> canvasImageInteropUnknown = default;
@@ -93,7 +117,11 @@ internal static class Win2DHelper
using ComPtr<IUnknown> canvasDeviceUnknown = default;
#if WINDOWS_UWP
canvasDeviceUnknown.Attach((IUnknown*)Marshal.GetIUnknownForObject(canvasDevice));
#else
canvasDeviceUnknown.Attach((IUnknown*)MarshalInspectable<CanvasDevice>.FromManaged(canvasDevice));
#endif
using ComPtr<IUnknown> canvasDeviceInterfaceUnknown = default;
@@ -116,4 +144,27 @@ internal static class Win2DHelper
Marshal.ThrowExceptionForHR(hresult);
}
#if !WINDOWS_UWP
/// <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="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;
}
}
#endif
}
+4
ファイルの表示
@@ -3,7 +3,11 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ComputeSharp.D2D1.Interop;
using ComputeSharp.D2D1.UI.Tests.Helpers;
#if WINDOWS_UWP
using ComputeSharp.D2D1.Uwp;
#else
using ComputeSharp.D2D1.WinUI;
#endif
using Microsoft.Graphics.Canvas;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TerraFX.Interop.DirectX;
+13 -1
ファイルの表示
@@ -1,8 +1,13 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading.Tasks;
using ComputeSharp.D2D1.UI.Tests.Helpers;
#if WINDOWS_UWP
using ComputeSharp.D2D1.Uwp;
#else
using ComputeSharp.D2D1.WinUI;
#endif
using ComputeSharp.SwapChain.Shaders.D2D1;
using Microsoft.Graphics.Canvas;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -73,7 +78,7 @@ public class ShadersTests
await RunTestAsync<TerracedHills>(wrapperType, 0.000026f);
}
private static async Task RunTestAsync<T>(WrapperType wrapperType, float threshold = 0.00001f)
private static async Task RunTestAsync<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>(WrapperType wrapperType, float threshold = 0.00001f)
where T : unmanaged, ID2D1PixelShader
{
T shader = (T)Activator.CreateInstance(typeof(T), 0f, new int2(1280, 720))!;
@@ -134,6 +139,13 @@ public class ShadersTests
{
this.effect!.ConstantBuffer = this.constantBuffer;
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
this.effect?.Dispose();
}
}
public enum WrapperType