From 053a25a088d4c194ef6354ea7e9636b1ff5e04b1 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 10 Oct 2023 21:13:14 +0200 Subject: [PATCH] Remove other WINDOWS_UWP leftover code paths --- .../ICanvasEffectFactoryNative.cs | 12 ------- .../ICanvasFactoryNative.cs | 6 ---- .../ICanvasImageInterop.cs | 15 -------- .../Buffers/GraphicsEffectSourceBuffer.cs | 4 --- .../Buffers/ResourceTextureManagerBuffer.cs | 4 --- .../Buffers/SourceReference.cs | 9 ----- .../CanvasEffect.EffectGraph.cs | 4 --- .../CanvasEffect.Interop.cs | 8 ----- src/ComputeSharp.D2D1.WinUI/CanvasEffect.cs | 4 --- .../Collections/FixedCountList{T}.cs | 4 --- .../Collections/IFixedCountList{T}.cs | 4 --- .../Extensions/ICanvasDeviceExtensions.cs | 4 --- .../ID2D1DeviceContextExtensions.cs | 4 --- .../Extensions/ID2D1EffectExtensions.cs | 4 --- .../Extensions/IUnknownExtensions.cs | 4 --- .../Helpers/RcwMarshaller.cs | 32 ----------------- .../Helpers/ResourceManager.cs | 36 ------------------- .../PixelShaderEffect{T}.ICanvasEffect.cs | 8 ----- ...derEffect{T}.ICanvasEffectFactoryNative.cs | 9 ----- .../PixelShaderEffect{T}.ICanvasImage.cs | 8 ----- ...ixelShaderEffect{T}.ICanvasImageInterop.cs | 9 ----- ...derEffect{T}.Properties.Interop.Sources.cs | 10 ------ ...PixelShaderEffect{T}.Properties.Interop.cs | 8 ----- ...erties.ResourceTextureManagerCollection.cs | 9 ----- ...erEffect{T}.Properties.SourceCollection.cs | 9 ----- .../PixelShaderEffect{T}.Properties.cs | 4 --- .../PixelShaderEffect{T}.ReferenceTracking.cs | 8 ----- .../PixelShaderEffect{T}.cs | 8 ----- .../TerraFX.Interop.Windows.D2D1.projitems | 2 -- .../WinRT/winrt/roapi/WinRT.cs | 16 --------- .../WinRT/winrt/winstring/WinRT.cs | 15 -------- .../Helpers/Win2DHelper.cs | 29 --------------- .../Tests/CanvasEffectTests.cs | 4 --- .../Tests/PixelShaderEffectTests.cs | 4 --- .../Tests/ShadersTests.cs | 4 --- 35 files changed, 322 deletions(-) delete mode 100644 src/TerraFX.Interop.Windows.D2D1/WinRT/winrt/roapi/WinRT.cs delete mode 100644 src/TerraFX.Interop.Windows.D2D1/WinRT/winrt/winstring/WinRT.cs diff --git a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasEffectFactoryNative.cs b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasEffectFactoryNative.cs index 95c3252b..9aecc008 100644 --- a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasEffectFactoryNative.cs +++ b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasEffectFactoryNative.cs @@ -4,10 +4,8 @@ using System.Runtime.InteropServices; using TerraFX.Interop; using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; -#if !WINDOWS_UWP using WinRT; using WinRT.Interop; -#endif using IInspectable = TerraFX.Interop.WinRT.IInspectable; #pragma warning disable CS0649, IDE1006 @@ -78,23 +76,14 @@ internal unsafe struct ICanvasEffectFactoryNative /// The managed implementation of . /// [Guid("29BA1A1F-1CFE-44C3-984D-426D61B51427")] -#if WINDOWS_UWP - [ComImport] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] -#else [WindowsRuntimeType] [WindowsRuntimeHelperType(typeof(Interface))] -#endif public interface Interface { /// -#if WINDOWS_UWP - [PreserveSig] -#endif [return: NativeTypeName("HRESULT")] int CreateWrapper(ICanvasDevice* device, ID2D1Effect* resource, float dpi, IInspectable** wrapper); -#if !WINDOWS_UWP /// /// The vtable type for . /// @@ -147,6 +136,5 @@ internal unsafe struct ICanvasEffectFactoryNative } } } -#endif } } \ No newline at end of file diff --git a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasFactoryNative.cs b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasFactoryNative.cs index c89c99b6..98d88e29 100644 --- a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasFactoryNative.cs +++ b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasFactoryNative.cs @@ -3,13 +3,9 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using TerraFX.Interop; using TerraFX.Interop.Windows; -#if WINDOWS_UWP -using TerraFX.Interop.WinRT; -#else using WinRT; using WinRT.Interop; using IInspectable = TerraFX.Interop.WinRT.IInspectable; -#endif #pragma warning disable CS0649, IDE1006 @@ -151,7 +147,6 @@ internal unsafe struct ICanvasFactoryNative effectId); } -#if !WINDOWS_UWP /// /// The managed interface for . /// @@ -172,5 +167,4 @@ internal unsafe struct ICanvasFactoryNative public static readonly IntPtr AbiToProjectionVftablePtr = IUnknownVftbl.AbiToProjectionVftblPtr; } } -#endif } \ No newline at end of file diff --git a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs index ac53ae5d..a8a143aa 100644 --- a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs +++ b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs @@ -4,10 +4,8 @@ using System.Runtime.InteropServices; using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; using TerraFX.Interop; -#if !WINDOWS_UWP using WinRT; using WinRT.Interop; -#endif #pragma warning disable CS0649, IDE1006 @@ -86,26 +84,15 @@ internal unsafe struct ICanvasImageInterop /// The managed implementation of . /// [Guid("E042D1F7-F9AD-4479-A713-67627EA31863")] -#if WINDOWS_UWP - [ComImport] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] -#else [WindowsRuntimeType] [WindowsRuntimeHelperType(typeof(Interface))] -#endif public interface Interface { /// -#if WINDOWS_UWP - [PreserveSig] -#endif [return: NativeTypeName("HRESULT")] int GetDevice(ICanvasDevice** device, WIN2D_GET_DEVICE_ASSOCIATION_TYPE* type); /// -#if WINDOWS_UWP - [PreserveSig] -#endif [return: NativeTypeName("HRESULT")] int GetD2DImage( ICanvasDevice* device, @@ -115,7 +102,6 @@ internal unsafe struct ICanvasImageInterop float* realizeDpi, ID2D1Image** ppImage); -#if !WINDOWS_UWP /// /// The vtable type for . /// @@ -198,6 +184,5 @@ internal unsafe struct ICanvasImageInterop } } } -#endif } } \ No newline at end of file diff --git a/src/ComputeSharp.D2D1.WinUI/Buffers/GraphicsEffectSourceBuffer.cs b/src/ComputeSharp.D2D1.WinUI/Buffers/GraphicsEffectSourceBuffer.cs index f689c6df..34502c69 100644 --- a/src/ComputeSharp.D2D1.WinUI/Buffers/GraphicsEffectSourceBuffer.cs +++ b/src/ComputeSharp.D2D1.WinUI/Buffers/GraphicsEffectSourceBuffer.cs @@ -3,11 +3,7 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using Windows.Graphics.Effects; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp.Buffers; -#else namespace ComputeSharp.D2D1.WinUI.Buffers; -#endif /// /// A fixed buffer type containing 16 fields. diff --git a/src/ComputeSharp.D2D1.WinUI/Buffers/ResourceTextureManagerBuffer.cs b/src/ComputeSharp.D2D1.WinUI/Buffers/ResourceTextureManagerBuffer.cs index 5efb789a..66744195 100644 --- a/src/ComputeSharp.D2D1.WinUI/Buffers/ResourceTextureManagerBuffer.cs +++ b/src/ComputeSharp.D2D1.WinUI/Buffers/ResourceTextureManagerBuffer.cs @@ -3,11 +3,7 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using ComputeSharp.D2D1.Interop; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp.Buffers; -#else namespace ComputeSharp.D2D1.WinUI.Buffers; -#endif /// /// A fixed buffer type containing 16 fields. diff --git a/src/ComputeSharp.D2D1.WinUI/Buffers/SourceReference.cs b/src/ComputeSharp.D2D1.WinUI/Buffers/SourceReference.cs index d9f917b2..e91c02ab 100644 --- a/src/ComputeSharp.D2D1.WinUI/Buffers/SourceReference.cs +++ b/src/ComputeSharp.D2D1.WinUI/Buffers/SourceReference.cs @@ -1,22 +1,13 @@ using System; using System.Runtime.CompilerServices; using ABI.Microsoft.Graphics.Canvas; -#if WINDOWS_UWP -using ComputeSharp.D2D1.Uwp.Extensions; -using ComputeSharp.D2D1.Uwp.Helpers; -#else using ComputeSharp.D2D1.WinUI.Extensions; using ComputeSharp.D2D1.WinUI.Helpers; -#endif using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; using Windows.Graphics.Effects; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp.Buffers; -#else namespace ComputeSharp.D2D1.WinUI.Buffers; -#endif /// /// A wrapper type for an input and its underlying native D2D images. diff --git a/src/ComputeSharp.D2D1.WinUI/CanvasEffect.EffectGraph.cs b/src/ComputeSharp.D2D1.WinUI/CanvasEffect.EffectGraph.cs index 9af0f2a7..2122aa51 100644 --- a/src/ComputeSharp.D2D1.WinUI/CanvasEffect.EffectGraph.cs +++ b/src/ComputeSharp.D2D1.WinUI/CanvasEffect.EffectGraph.cs @@ -2,11 +2,7 @@ using System; using System.Runtime.CompilerServices; using Microsoft.Graphics.Canvas; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp; -#else namespace ComputeSharp.D2D1.WinUI; -#endif /// partial class CanvasEffect diff --git a/src/ComputeSharp.D2D1.WinUI/CanvasEffect.Interop.cs b/src/ComputeSharp.D2D1.WinUI/CanvasEffect.Interop.cs index 3f46123e..b0f6fd7b 100644 --- a/src/ComputeSharp.D2D1.WinUI/CanvasEffect.Interop.cs +++ b/src/ComputeSharp.D2D1.WinUI/CanvasEffect.Interop.cs @@ -3,22 +3,14 @@ using System.Diagnostics.CodeAnalysis; using System.Numerics; using ABI.Microsoft.Graphics.Canvas; using ComputeSharp.D2D1.Extensions; -#if WINDOWS_UWP -using ComputeSharp.D2D1.Uwp.Helpers; -#else using ComputeSharp.D2D1.WinUI.Helpers; -#endif using Microsoft.Graphics.Canvas; using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; using Windows.Foundation; using ICanvasResourceCreator = Microsoft.Graphics.Canvas.ICanvasResourceCreator; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp; -#else namespace ComputeSharp.D2D1.WinUI; -#endif /// partial class CanvasEffect diff --git a/src/ComputeSharp.D2D1.WinUI/CanvasEffect.cs b/src/ComputeSharp.D2D1.WinUI/CanvasEffect.cs index c9cdbf63..b138a98d 100644 --- a/src/ComputeSharp.D2D1.WinUI/CanvasEffect.cs +++ b/src/ComputeSharp.D2D1.WinUI/CanvasEffect.cs @@ -4,11 +4,7 @@ using System.Diagnostics.CodeAnalysis; using ABI.Microsoft.Graphics.Canvas; using Microsoft.Graphics.Canvas; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp; -#else namespace ComputeSharp.D2D1.WinUI; -#endif /// /// A base type to implement packaged and easy to use -based effects that can be used with Win2D. diff --git a/src/ComputeSharp.D2D1.WinUI/Collections/FixedCountList{T}.cs b/src/ComputeSharp.D2D1.WinUI/Collections/FixedCountList{T}.cs index 8f93a9b0..d4c46083 100644 --- a/src/ComputeSharp.D2D1.WinUI/Collections/FixedCountList{T}.cs +++ b/src/ComputeSharp.D2D1.WinUI/Collections/FixedCountList{T}.cs @@ -1,11 +1,7 @@ using System; using System.Collections.Generic; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp.Collections; -#else namespace ComputeSharp.D2D1.WinUI.Collections; -#endif /// /// Shared helpers for all types implementing . diff --git a/src/ComputeSharp.D2D1.WinUI/Collections/IFixedCountList{T}.cs b/src/ComputeSharp.D2D1.WinUI/Collections/IFixedCountList{T}.cs index c3672855..6dcd595c 100644 --- a/src/ComputeSharp.D2D1.WinUI/Collections/IFixedCountList{T}.cs +++ b/src/ComputeSharp.D2D1.WinUI/Collections/IFixedCountList{T}.cs @@ -1,11 +1,7 @@ using System.Collections.Generic; using System.Collections.Immutable; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp.Collections; -#else namespace ComputeSharp.D2D1.WinUI.Collections; -#endif /// /// An interface for a list with a fixed collection. diff --git a/src/ComputeSharp.D2D1.WinUI/Extensions/ICanvasDeviceExtensions.cs b/src/ComputeSharp.D2D1.WinUI/Extensions/ICanvasDeviceExtensions.cs index ab5a75e4..cf59c1f5 100644 --- a/src/ComputeSharp.D2D1.WinUI/Extensions/ICanvasDeviceExtensions.cs +++ b/src/ComputeSharp.D2D1.WinUI/Extensions/ICanvasDeviceExtensions.cs @@ -4,11 +4,7 @@ using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; using Win32 = TerraFX.Interop.Windows.Windows; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp.Extensions; -#else namespace ComputeSharp.D2D1.WinUI.Extensions; -#endif /// /// A with extensions for the type. diff --git a/src/ComputeSharp.D2D1.WinUI/Extensions/ID2D1DeviceContextExtensions.cs b/src/ComputeSharp.D2D1.WinUI/Extensions/ID2D1DeviceContextExtensions.cs index 7a3b47db..c80b7afd 100644 --- a/src/ComputeSharp.D2D1.WinUI/Extensions/ID2D1DeviceContextExtensions.cs +++ b/src/ComputeSharp.D2D1.WinUI/Extensions/ID2D1DeviceContextExtensions.cs @@ -2,11 +2,7 @@ using ComputeSharp.D2D1.Extensions; using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp.Extensions; -#else namespace ComputeSharp.D2D1.WinUI.Extensions; -#endif /// /// A with extensions for the type. diff --git a/src/ComputeSharp.D2D1.WinUI/Extensions/ID2D1EffectExtensions.cs b/src/ComputeSharp.D2D1.WinUI/Extensions/ID2D1EffectExtensions.cs index 090d6c56..c7ed870e 100644 --- a/src/ComputeSharp.D2D1.WinUI/Extensions/ID2D1EffectExtensions.cs +++ b/src/ComputeSharp.D2D1.WinUI/Extensions/ID2D1EffectExtensions.cs @@ -10,11 +10,7 @@ using ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMappers; using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp.Extensions; -#else namespace ComputeSharp.D2D1.WinUI.Extensions; -#endif /// /// A with extensions for the type. diff --git a/src/ComputeSharp.D2D1.WinUI/Extensions/IUnknownExtensions.cs b/src/ComputeSharp.D2D1.WinUI/Extensions/IUnknownExtensions.cs index e8e06034..8166a47c 100644 --- a/src/ComputeSharp.D2D1.WinUI/Extensions/IUnknownExtensions.cs +++ b/src/ComputeSharp.D2D1.WinUI/Extensions/IUnknownExtensions.cs @@ -3,11 +3,7 @@ using ComputeSharp.D2D1.Extensions; using TerraFX.Interop.Windows; using Win32 = TerraFX.Interop.Windows.Windows; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp.Extensions; -#else namespace ComputeSharp.D2D1.WinUI.Extensions; -#endif /// /// Helper methods for working with the type. diff --git a/src/ComputeSharp.D2D1.WinUI/Helpers/RcwMarshaller.cs b/src/ComputeSharp.D2D1.WinUI/Helpers/RcwMarshaller.cs index 3adfae3c..07abf3bf 100644 --- a/src/ComputeSharp.D2D1.WinUI/Helpers/RcwMarshaller.cs +++ b/src/ComputeSharp.D2D1.WinUI/Helpers/RcwMarshaller.cs @@ -1,20 +1,10 @@ using System; using System.Diagnostics.CodeAnalysis; -#if WINDOWS_UWP -using System.Runtime.InteropServices; -using ComputeSharp.D2D1.Extensions; -#endif using TerraFX.Interop.Windows; -#if !WINDOWS_UWP using WinRT; -#endif using IInspectable = TerraFX.Interop.WinRT.IInspectable; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp.Helpers; -#else namespace ComputeSharp.D2D1.WinUI.Helpers; -#endif /// /// A helper type to handle marshalling of RCW instances. @@ -31,12 +21,7 @@ internal static unsafe class RcwMarshaller public static T GetOrCreateManagedInterface(IUnknown* nativeObject) where T : class { -#if WINDOWS_UWP - // On UWP, Marshal.GetObjectForIUnknown handles all the marshalling/wrapping logic - return (T)Marshal.GetObjectForIUnknown((IntPtr)nativeObject); -#else return MarshalInterface.FromAbi((IntPtr)nativeObject); -#endif } /// @@ -49,18 +34,7 @@ internal static unsafe class RcwMarshaller public static void GetNativeObject<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors | DynamicallyAccessedMemberTypes.Interfaces)] T>(T managedObject, IInspectable** nativeObject) where T : class { -#if WINDOWS_UWP - using ComPtr unknownObject = default; - - // On UWP, due to built-in COM/WinRT support, Marshal.GetIUnknownForObject can handle all the logic. - // We get back an IUnknown* pointer, so we need to QueryInterface for IInspectable* ourselves. - unknownObject.Attach((IUnknown*)Marshal.GetIUnknownForObject(managedObject)); - - unknownObject.CopyTo(nativeObject).Assert(); -#else - // On WinUI 3, delegate the RCW unwrapping or CCW creation logic to CsWinRT's APIs *nativeObject = (IInspectable*)MarshalInspectable.FromManaged(managedObject); -#endif } /// @@ -78,15 +52,9 @@ internal static unsafe class RcwMarshaller { using ComPtr unknownObject = default; -#if WINDOWS_UWP - unknownObject.Attach((IUnknown*)Marshal.GetIUnknownForObject(managedObject)); - - unknownObject.CopyTo(nativeObject).Assert(); -#else // Here we only want to get an IUnknown* pointer for a given interface, and then we'll do // QueryInterface ourselves to get the target COM type. So MarshalInterface is fine. unknownObject.Attach((IUnknown*)MarshalInterface.FromManaged(managedObject)); -#endif return unknownObject.CopyTo(nativeObject); } diff --git a/src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs b/src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs index f1990f56..97562833 100644 --- a/src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs +++ b/src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs @@ -3,22 +3,13 @@ using System.Diagnostics.CodeAnalysis; using ABI.Microsoft.Graphics.Canvas; using ComputeSharp.D2D1.Extensions; using TerraFX.Interop.Windows; -#if WINDOWS_UWP -using TerraFX.Interop.WinRT; -#endif using Windows.Graphics.Effects; -#if !WINDOWS_UWP using WinRT; -#endif -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp.Helpers; -#else namespace ComputeSharp.D2D1.WinUI.Helpers; using CanvasDevice = Microsoft.Graphics.Canvas.CanvasDevice; using IInspectable = TerraFX.Interop.WinRT.IInspectable; -#endif /// /// A helper type to replicate Win2D's ResourceManager type. @@ -115,32 +106,6 @@ internal static unsafe class ResourceManager /// A pointer to the resulting activation factory. private static void GetActivationFactory(ICanvasFactoryNative** factoryNative) { -#if WINDOWS_UWP - const string activatableClassId = "Microsoft.Graphics.Canvas.CanvasDevice"; - - // On UWP, the WinRT types from Win2D are automatically registered for activation. - // This means we can simply use RoGetActivationFactory to retrieve the factory. - fixed (char* pActivatableClassId = activatableClassId) - { - HSTRING_HEADER hStringHeaderActivatableClassId; - HSTRING hStringActivatableClass; - - // Create a fast-pass HSTRING for "Microsoft.Graphics.Canvas.CanvasDevice" - WinRT.WindowsCreateStringReference( - sourceString: (ushort*)pActivatableClassId, - length: (uint)activatableClassId.Length, - hstringHeader: &hStringHeaderActivatableClassId, - @string: &hStringActivatableClass).Assert(); - - Guid canvasFactoryNativeId = typeof(ICanvasFactoryNative).GUID; - - // Get the activation factory for CanvasDevice - WinRT.RoGetActivationFactory( - activatableClassId: hStringActivatableClass, - iid: &canvasFactoryNativeId, - factory: (void**)factoryNative).Assert(); - } -#else // 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() method, which will // automatically handle fallback logic to resolve types to activate if they're not registered. @@ -148,6 +113,5 @@ internal static unsafe class ResourceManager ICanvasFactoryNative.Interface canvasDeviceActivationFactory = CanvasDevice.As(); *factoryNative = (ICanvasFactoryNative*)MarshalInterface.FromManaged(canvasDeviceActivationFactory); -#endif } } diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasEffect.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasEffect.cs index a55b2506..467c1f5f 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasEffect.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasEffect.cs @@ -3,22 +3,14 @@ using System.Buffers; using System.Runtime.InteropServices; using ABI.Microsoft.Graphics.Canvas; using ComputeSharp.D2D1.Extensions; -#if WINDOWS_UWP -using ComputeSharp.D2D1.Uwp.Helpers; -#else using ComputeSharp.D2D1.WinUI.Helpers; -#endif using ComputeSharp.Interop; using TerraFX.Interop.Windows; using Windows.Foundation; using ICanvasEffect = Microsoft.Graphics.Canvas.Effects.ICanvasEffect; using ICanvasResourceCreatorWithDpi = Microsoft.Graphics.Canvas.ICanvasResourceCreatorWithDpi; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp; -#else namespace ComputeSharp.D2D1.WinUI; -#endif /// unsafe partial class PixelShaderEffect diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs index 0fcc7e0e..eefa430b 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs @@ -3,22 +3,13 @@ using System.Runtime.CompilerServices; using ABI.Microsoft.Graphics.Canvas; using ComputeSharp.D2D1.Extensions; using ComputeSharp.D2D1.Interop; -#if WINDOWS_UWP -using ComputeSharp.D2D1.Uwp.Extensions; -using ComputeSharp.D2D1.Uwp.Helpers; -#else using ComputeSharp.D2D1.WinUI.Extensions; using ComputeSharp.D2D1.WinUI.Helpers; -#endif using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; using TerraFX.Interop.WinRT; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp; -#else namespace ComputeSharp.D2D1.WinUI; -#endif /// unsafe partial class PixelShaderEffect diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasImage.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasImage.cs index 140d13eb..3a23f23d 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasImage.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasImage.cs @@ -1,21 +1,13 @@ using System.Numerics; using ABI.Microsoft.Graphics.Canvas; using ComputeSharp.D2D1.Extensions; -#if WINDOWS_UWP -using ComputeSharp.D2D1.Uwp.Helpers; -#else using ComputeSharp.D2D1.WinUI.Helpers; -#endif using ComputeSharp.Interop; using TerraFX.Interop.Windows; using Windows.Foundation; using ICanvasResourceCreator = Microsoft.Graphics.Canvas.ICanvasResourceCreator; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp; -#else namespace ComputeSharp.D2D1.WinUI; -#endif /// unsafe partial class PixelShaderEffect diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasImageInterop.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasImageInterop.cs index f63e388e..3a683c99 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasImageInterop.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasImageInterop.cs @@ -4,13 +4,8 @@ using System.Threading; using ABI.Microsoft.Graphics.Canvas; using ComputeSharp.D2D1.Extensions; using ComputeSharp.D2D1.Interop; -#if WINDOWS_UWP -using ComputeSharp.D2D1.Uwp.Extensions; -using ComputeSharp.D2D1.Uwp.Helpers; -#else using ComputeSharp.D2D1.WinUI.Extensions; using ComputeSharp.D2D1.WinUI.Helpers; -#endif using ComputeSharp.Interop; using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; @@ -19,11 +14,7 @@ using static ABI.Microsoft.Graphics.Canvas.WIN2D_GET_D2D_IMAGE_FLAGS; using static ABI.Microsoft.Graphics.Canvas.WIN2D_GET_DEVICE_ASSOCIATION_TYPE; using Win32 = TerraFX.Interop.Windows.Windows; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp; -#else namespace ComputeSharp.D2D1.WinUI; -#endif /// unsafe partial class PixelShaderEffect diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.Interop.Sources.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.Interop.Sources.cs index a24bdd4d..68b69134 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.Interop.Sources.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.Interop.Sources.cs @@ -3,15 +3,9 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using ABI.Microsoft.Graphics.Canvas; using ComputeSharp.D2D1.Extensions; -#if WINDOWS_UWP -using ComputeSharp.D2D1.Uwp.Buffers; -using ComputeSharp.D2D1.Uwp.Extensions; -using ComputeSharp.D2D1.Uwp.Helpers; -#else using ComputeSharp.D2D1.WinUI.Buffers; using ComputeSharp.D2D1.WinUI.Extensions; using ComputeSharp.D2D1.WinUI.Helpers; -#endif using ComputeSharp.Interop; using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; @@ -24,11 +18,7 @@ using static TerraFX.Interop.DirectX.D2D1_DPICOMPENSATION_PROP; using static TerraFX.Interop.DirectX.D2D1_PROPERTY_TYPE; using Win32 = TerraFX.Interop.Windows.Windows; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp; -#else namespace ComputeSharp.D2D1.WinUI; -#endif /// unsafe partial class PixelShaderEffect diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.Interop.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.Interop.cs index bc5e4f2f..afa2fa24 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.Interop.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.Interop.cs @@ -1,19 +1,11 @@ using System; using ComputeSharp.D2D1.Interop; -#if WINDOWS_UWP -using ComputeSharp.D2D1.Uwp.Extensions; -#else using ComputeSharp.D2D1.WinUI.Extensions; -#endif using ComputeSharp.Interop; using Microsoft.Graphics.Canvas; using TerraFX.Interop.DirectX; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp; -#else namespace ComputeSharp.D2D1.WinUI; -#endif /// unsafe partial class PixelShaderEffect diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.ResourceTextureManagerCollection.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.ResourceTextureManagerCollection.cs index 5b47ee1d..3cd6822c 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.ResourceTextureManagerCollection.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.ResourceTextureManagerCollection.cs @@ -5,21 +5,12 @@ using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using ComputeSharp.D2D1.Interop; -#if WINDOWS_UWP -using ComputeSharp.D2D1.Uwp.Buffers; -using ComputeSharp.D2D1.Uwp.Collections; -#else using ComputeSharp.D2D1.WinUI.Buffers; using ComputeSharp.D2D1.WinUI.Collections; -#endif #pragma warning disable CS8767 -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp; -#else namespace ComputeSharp.D2D1.WinUI; -#endif /// partial class PixelShaderEffect diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.SourceCollection.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.SourceCollection.cs index 69c3369d..2b063129 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.SourceCollection.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.SourceCollection.cs @@ -4,20 +4,11 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Runtime.CompilerServices; using ComputeSharp.D2D1.Interop; -#if WINDOWS_UWP -using ComputeSharp.D2D1.Uwp.Buffers; -using ComputeSharp.D2D1.Uwp.Collections; -#else using ComputeSharp.D2D1.WinUI.Buffers; using ComputeSharp.D2D1.WinUI.Collections; -#endif using Windows.Graphics.Effects; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp; -#else namespace ComputeSharp.D2D1.WinUI; -#endif /// partial class PixelShaderEffect diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.cs index d171e39f..eb0fb811 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.cs @@ -3,11 +3,7 @@ using System.Diagnostics.CodeAnalysis; using ComputeSharp.D2D1.Interop; using Microsoft.Graphics.Canvas; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp; -#else namespace ComputeSharp.D2D1.WinUI; -#endif /// partial class PixelShaderEffect diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ReferenceTracking.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ReferenceTracking.cs index 97ce8fa2..76865d69 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ReferenceTracking.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ReferenceTracking.cs @@ -1,18 +1,10 @@ using System; using ComputeSharp.Interop; using System.Runtime.CompilerServices; -#if WINDOWS_UWP -using ComputeSharp.D2D1.Uwp.Helpers; -#else using ComputeSharp.D2D1.WinUI.Helpers; -#endif using TerraFX.Interop.Windows; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp; -#else namespace ComputeSharp.D2D1.WinUI; -#endif /// partial class PixelShaderEffect diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.cs index 863d7176..7820cf68 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.cs @@ -1,6 +1,4 @@ -#if !WINDOWS_UWP using System.Diagnostics.CodeAnalysis; -#endif using ABI.Microsoft.Graphics.Canvas; using ComputeSharp.D2D1.Descriptors; using ComputeSharp.D2D1.Interop; @@ -10,11 +8,7 @@ using Microsoft.Graphics.Canvas.Effects; using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; -#if WINDOWS_UWP -namespace ComputeSharp.D2D1.Uwp; -#else namespace ComputeSharp.D2D1.WinUI; -#endif /// /// A custom implementation powered by a supplied shader type. @@ -76,7 +70,6 @@ public sealed partial class PixelShaderEffect : IReferenceTrackedObject, ICan /// /// Creates a new instance. /// -#if !WINDOWS_UWP // 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))] @@ -85,7 +78,6 @@ public sealed partial class PixelShaderEffect : IReferenceTrackedObject, ICan [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICanvasFactoryNative.Interface.Vftbl))] [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICanvasEffectFactoryNative.Interface))] [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICanvasEffectFactoryNative.Interface.Vftbl))] -#endif public PixelShaderEffect() { using ReferenceTracker.Lease _0 = ReferenceTracker.Create(this, out this.referenceTracker); diff --git a/src/TerraFX.Interop.Windows.D2D1/TerraFX.Interop.Windows.D2D1.projitems b/src/TerraFX.Interop.Windows.D2D1/TerraFX.Interop.Windows.D2D1.projitems index cfa82c7b..60f2591b 100644 --- a/src/TerraFX.Interop.Windows.D2D1/TerraFX.Interop.Windows.D2D1.projitems +++ b/src/TerraFX.Interop.Windows.D2D1/TerraFX.Interop.Windows.D2D1.projitems @@ -75,7 +75,5 @@ - - \ No newline at end of file diff --git a/src/TerraFX.Interop.Windows.D2D1/WinRT/winrt/roapi/WinRT.cs b/src/TerraFX.Interop.Windows.D2D1/WinRT/winrt/roapi/WinRT.cs deleted file mode 100644 index 0e955b67..00000000 --- a/src/TerraFX.Interop.Windows.D2D1/WinRT/winrt/roapi/WinRT.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -// Ported from winrt/roapi.h in the Windows SDK for Windows 10.0.22621.0 -// Original source is Copyright © Microsoft. All rights reserved. - -using System; -using System.Runtime.InteropServices; -using TerraFX.Interop.Windows; - -namespace TerraFX.Interop.WinRT; - -internal static unsafe partial class WinRT -{ - [DllImport("combase", ExactSpelling = true)] - public static extern HRESULT RoGetActivationFactory(HSTRING activatableClassId, [NativeTypeName("const IID &")] Guid* iid, void** factory); -} \ No newline at end of file diff --git a/src/TerraFX.Interop.Windows.D2D1/WinRT/winrt/winstring/WinRT.cs b/src/TerraFX.Interop.Windows.D2D1/WinRT/winrt/winstring/WinRT.cs deleted file mode 100644 index ef4c8562..00000000 --- a/src/TerraFX.Interop.Windows.D2D1/WinRT/winrt/winstring/WinRT.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -// Ported from winrt/winstring.h in the Windows SDK for Windows 10.0.22621.0 -// Original source is Copyright © Microsoft. All rights reserved. - -using System.Runtime.InteropServices; -using TerraFX.Interop.Windows; - -namespace TerraFX.Interop.WinRT; - -internal static unsafe partial class WinRT -{ - [DllImport("combase", ExactSpelling = true)] - public static extern HRESULT WindowsCreateStringReference([NativeTypeName("PCWSTR")] ushort* sourceString, [NativeTypeName("UINT32")] uint length, HSTRING_HEADER* hstringHeader, HSTRING* @string); -} \ No newline at end of file diff --git a/tests/ComputeSharp.D2D1.WinUI.Tests/Helpers/Win2DHelper.cs b/tests/ComputeSharp.D2D1.WinUI.Tests/Helpers/Win2DHelper.cs index de80e4a1..f073f88b 100644 --- a/tests/ComputeSharp.D2D1.WinUI.Tests/Helpers/Win2DHelper.cs +++ b/tests/ComputeSharp.D2D1.WinUI.Tests/Helpers/Win2DHelper.cs @@ -1,15 +1,10 @@ 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 @@ -30,15 +25,9 @@ internal static class Win2DHelper { using ComPtr activationFactoryUnknown = default; -#if WINDOWS_UWP - IActivationFactory activationFactory = WindowsRuntimeMarshal.GetActivationFactory(typeof(CanvasDevice)); - - activationFactoryUnknown.Attach((IUnknown*)Marshal.GetIUnknownForObject(activationFactory)); -#else ICanvasFactoryNative activationFactory = CanvasDevice.As(); activationFactoryUnknown.Attach((IUnknown*)MarshalInterface.FromManaged(activationFactory)); -#endif using ComPtr canvasFactoryNativeUnknown = default; @@ -53,11 +42,7 @@ internal static class Win2DHelper if (canvasDevice is not null) { -#if WINDOWS_UWP - canvasDeviceUnknown.Attach((IUnknown*)Marshal.GetIUnknownForObject(canvasDevice)); -#else canvasDeviceUnknown.Attach((IUnknown*)MarshalInspectable.FromManaged(canvasDevice)); -#endif } using ComPtr canvasDeviceInterfaceUnknown = default; @@ -83,11 +68,7 @@ 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.FromAbi((IntPtr)wrapperUnknown.Get()); -#endif } /// @@ -100,11 +81,7 @@ internal static class Win2DHelper { using ComPtr effectUnknown = default; -#if WINDOWS_UWP - effectUnknown.Attach((IUnknown*)Marshal.GetIUnknownForObject(canvasImage)); -#else effectUnknown.Attach((IUnknown*)MarshalInterface.FromManaged(canvasImage)); -#endif using ComPtr canvasImageInteropUnknown = default; @@ -117,11 +94,7 @@ internal static class Win2DHelper using ComPtr canvasDeviceUnknown = default; -#if WINDOWS_UWP - canvasDeviceUnknown.Attach((IUnknown*)Marshal.GetIUnknownForObject(canvasDevice)); -#else canvasDeviceUnknown.Attach((IUnknown*)MarshalInspectable.FromManaged(canvasDevice)); -#endif using ComPtr canvasDeviceInterfaceUnknown = default; @@ -145,7 +118,6 @@ internal static class Win2DHelper Marshal.ThrowExceptionForHR(hresult); } -#if !WINDOWS_UWP /// /// The managed interface for . /// @@ -166,5 +138,4 @@ internal static class Win2DHelper public static readonly IntPtr AbiToProjectionVftablePtr = IUnknownVftbl.AbiToProjectionVftblPtr; } } -#endif } \ No newline at end of file diff --git a/tests/ComputeSharp.D2D1.WinUI.Tests/Tests/CanvasEffectTests.cs b/tests/ComputeSharp.D2D1.WinUI.Tests/Tests/CanvasEffectTests.cs index dc5fccaf..b786e735 100644 --- a/tests/ComputeSharp.D2D1.WinUI.Tests/Tests/CanvasEffectTests.cs +++ b/tests/ComputeSharp.D2D1.WinUI.Tests/Tests/CanvasEffectTests.cs @@ -4,10 +4,6 @@ using System.IO; using System.Numerics; using System.Threading.Tasks; using ComputeSharp.D2D1.WinUI.Tests.Helpers; -#if WINDOWS_UWP -using ComputeSharp.D2D1.Uwp; -#else -#endif using ComputeSharp.SwapChain.Shaders.D2D1; using Microsoft.Graphics.Canvas; using Microsoft.Graphics.Canvas.Effects; diff --git a/tests/ComputeSharp.D2D1.WinUI.Tests/Tests/PixelShaderEffectTests.cs b/tests/ComputeSharp.D2D1.WinUI.Tests/Tests/PixelShaderEffectTests.cs index 1482eb63..f44b0b74 100644 --- a/tests/ComputeSharp.D2D1.WinUI.Tests/Tests/PixelShaderEffectTests.cs +++ b/tests/ComputeSharp.D2D1.WinUI.Tests/Tests/PixelShaderEffectTests.cs @@ -3,10 +3,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using ComputeSharp.D2D1.Interop; using ComputeSharp.D2D1.WinUI.Tests.Helpers; -#if WINDOWS_UWP -using ComputeSharp.D2D1.Uwp; -#else -#endif using Microsoft.Graphics.Canvas; using Microsoft.VisualStudio.TestTools.UnitTesting; using TerraFX.Interop.DirectX; diff --git a/tests/ComputeSharp.D2D1.WinUI.Tests/Tests/ShadersTests.cs b/tests/ComputeSharp.D2D1.WinUI.Tests/Tests/ShadersTests.cs index 7752916a..ed4eae97 100644 --- a/tests/ComputeSharp.D2D1.WinUI.Tests/Tests/ShadersTests.cs +++ b/tests/ComputeSharp.D2D1.WinUI.Tests/Tests/ShadersTests.cs @@ -4,10 +4,6 @@ using System.IO; using System.Threading.Tasks; using ComputeSharp.D2D1.Descriptors; using ComputeSharp.D2D1.WinUI.Tests.Helpers; -#if WINDOWS_UWP -using ComputeSharp.D2D1.Uwp; -#else -#endif using ComputeSharp.SwapChain.Shaders.D2D1; using Microsoft.Graphics.Canvas; using Microsoft.VisualStudio.TestTools.UnitTesting;