diff --git a/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs
index 3d6c8e3e..4de25009 100644
--- a/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs
+++ b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs
@@ -37,7 +37,7 @@ internal unsafe struct ICanvasImageInterop
/// The input canvas device (as a marshalled ).
///
/// The device context in use. This value is is optional (but recommended), except when the
- /// flag is specified. This is because
+ /// flag is specified. This is because
/// not all callers of 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
@@ -47,8 +47,9 @@ internal unsafe struct ICanvasImageInterop
///
/// The DPI of the target device context. This is used to determine when a D2D1DpiCompensation
/// effect needs to be inserted. Behavior of this parameter can be overridden by the flag values
- /// ,
- /// or
+ /// ,
+ ///
+ /// or
///
///
/// The DPI of a source bitmap, or zero if the image does not have a fixed DPI. A D2D1DpiCompensation effect
@@ -61,12 +62,12 @@ internal unsafe struct ICanvasImageInterop
public HRESULT GetD2DImage(
ICanvasDevice* device,
ID2D1DeviceContext* deviceContext,
- GetD2DImageFlags flags,
+ WIN2D_GET_D2D_IMAGE_FLAGS flags,
float targetDpi,
float* realizeDpi,
ID2D1Image** ppImage)
{
- return ((delegate* unmanaged[Stdcall])this.lpVtbl[4])(
+ return ((delegate* unmanaged[Stdcall])this.lpVtbl[4])(
(ICanvasImageInterop*)Unsafe.AsPointer(ref this),
device,
deviceContext,
@@ -95,7 +96,7 @@ internal unsafe struct ICanvasImageInterop
int GetD2DImage(
ICanvasDevice* device,
ID2D1DeviceContext* deviceContext,
- GetD2DImageFlags flags,
+ WIN2D_GET_D2D_IMAGE_FLAGS flags,
float targetDpi,
float* realizeDpi,
ID2D1Image** ppImage);
diff --git a/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/GetD2DImageFlags.cs b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/WIN2D_GET_D2D_IMAGE_FLAGS.cs
similarity index 64%
rename from src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/GetD2DImageFlags.cs
rename to src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/WIN2D_GET_D2D_IMAGE_FLAGS.cs
index 85af8c4c..a7697b7a 100644
--- a/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/GetD2DImageFlags.cs
+++ b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/WIN2D_GET_D2D_IMAGE_FLAGS.cs
@@ -6,40 +6,45 @@ namespace ABI.Microsoft.Graphics.Canvas;
/// Options for fine-tuning the behavior of .
///
[Flags]
-internal enum GetD2DImageFlags
+internal enum WIN2D_GET_D2D_IMAGE_FLAGS : uint
{
///
/// No options specified.
///
- None = 0,
+ WIN2D_GET_D2D_IMAGE_FLAGS_NONE = 0,
///
/// Ignore the targetDpi parameter, read DPI from deviceContext instead.
///
- ReadDpiFromDeviceContext = 1,
+ WIN2D_GET_D2D_IMAGE_FLAGS_READ_DPI_FROM_DEVICE_CONTEXT = 1,
///
/// Ignore the targetDpi parameter, always insert DPI compensation.
///
- AlwaysInsertDpiCompensation = 2,
+ WIN2D_GET_D2D_IMAGE_FLAGS_ALWAYS_INSERT_DPI_COMPENSATION = 2,
///
/// Ignore the targetDpi parameter, never insert DPI compensation.
///
- NeverInsertDpiCompensation = 4,
+ WIN2D_GET_D2D_IMAGE_FLAGS_NEVER_INSERT_DPI_COMPENSATION = 4,
///
/// Do the bare minimum to get back an ID2D1Image, no validation or recursive realization.
///
- MinimalRealization = 8,
+ WIN2D_GET_D2D_IMAGE_FLAGS_MINIMAL_REALIZATION = 8,
///
/// Allow partially configured effect graphs where some inputs are .
///
- AllowNullEffectInputs = 16,
+ WIN2D_GET_D2D_IMAGE_FLAGS_ALLOW_NULL_EFFECT_INPUTS = 16,
///
/// If an input is invalid, unrealize the effect and set the output image to .
///
- UnrealizeOnFailure = 32
+ WIN2D_GET_D2D_IMAGE_FLAGS_UNREALIZE_ON_FAILURE = 32,
+
+ ///
+ /// Ignored.
+ ///
+ WIN2D_GET_D2D_IMAGE_FLAGS_FORCE_DWORD = 0xffffffff
}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.Uwp/Extensions/ID2D1EffectExtensions.cs b/src/ComputeSharp.D2D1.Uwp/Extensions/ID2D1EffectExtensions.cs
index f1b9fe74..59f78ae1 100644
--- a/src/ComputeSharp.D2D1.Uwp/Extensions/ID2D1EffectExtensions.cs
+++ b/src/ComputeSharp.D2D1.Uwp/Extensions/ID2D1EffectExtensions.cs
@@ -12,6 +12,7 @@ using ComputeSharp.D2D1.Uwp.Buffers;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
using Windows.Graphics.Effects;
+using static ABI.Microsoft.Graphics.Canvas.WIN2D_GET_D2D_IMAGE_FLAGS;
using Win32 = TerraFX.Interop.Windows.Windows;
#pragma warning disable CS0618
@@ -148,7 +149,7 @@ internal static unsafe class ID2D1EffectExtensions
this ref ID2D1Effect d2D1Effect,
ICanvasDevice* canvasDevice,
ID2D1DeviceContext* deviceContext,
- GetD2DImageFlags flags,
+ WIN2D_GET_D2D_IMAGE_FLAGS flags,
float targetDpi,
IGraphicsEffectSource? value,
ref SourceReference source,
@@ -173,7 +174,7 @@ internal static unsafe class ID2D1EffectExtensions
if (!Win32.SUCCEEDED(hresult))
{
// If unrealization isn't requested for failures, just throw
- if ((flags & GetD2DImageFlags.UnrealizeOnFailure) == GetD2DImageFlags.None)
+ if ((flags & WIN2D_GET_D2D_IMAGE_FLAGS_UNREALIZE_ON_FAILURE) == WIN2D_GET_D2D_IMAGE_FLAGS_NONE)
{
ThrowHelper.ThrowArgumentException(nameof(value), "The effect source is not valid (it must implement ICanvasImageInterop).");
}
@@ -190,7 +191,7 @@ internal static unsafe class ID2D1EffectExtensions
// that is fine, as it just means that its underlying D2D image has not been realized yet.
if (sourceCanvasDevice.Get() is not null && !canvasDevice->IsSameInstance(sourceCanvasDevice.Get()))
{
- if ((flags & GetD2DImageFlags.UnrealizeOnFailure) == GetD2DImageFlags.None)
+ if ((flags & WIN2D_GET_D2D_IMAGE_FLAGS_UNREALIZE_ON_FAILURE) == WIN2D_GET_D2D_IMAGE_FLAGS_NONE)
{
ThrowHelper.ThrowArgumentException(nameof(value), "The effect source is realized on a different canvas device.");
}
@@ -208,12 +209,12 @@ internal static unsafe class ID2D1EffectExtensions
ppImage: d2D1Image.GetAddressOf());
// Unless requested, a failure to retrieve the image should just bubble up the HRESULT in an exception
- if ((flags & GetD2DImageFlags.UnrealizeOnFailure) == GetD2DImageFlags.None)
+ if ((flags & WIN2D_GET_D2D_IMAGE_FLAGS_UNREALIZE_ON_FAILURE) == WIN2D_GET_D2D_IMAGE_FLAGS_NONE)
{
hresult.Assert();
}
}
- else if ((flags & GetD2DImageFlags.AllowNullEffectInputs) == GetD2DImageFlags.None)
+ else if ((flags & WIN2D_GET_D2D_IMAGE_FLAGS_ALLOW_NULL_EFFECT_INPUTS) == WIN2D_GET_D2D_IMAGE_FLAGS_NONE)
{
// If the source is null and this is not explicitly allowed, the invocation is not valid
ThrowHelper.ThrowArgumentNullException(nameof(value), "The effect source cannot be null.");
diff --git a/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.ICanvasImageInterop.cs b/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.ICanvasImageInterop.cs
index e227672a..e2afddb4 100644
--- a/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.ICanvasImageInterop.cs
+++ b/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.ICanvasImageInterop.cs
@@ -8,6 +8,7 @@ using ComputeSharp.D2D1.Uwp.Extensions;
using ComputeSharp.Interop;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
+using static ABI.Microsoft.Graphics.Canvas.WIN2D_GET_D2D_IMAGE_FLAGS;
using Win32 = TerraFX.Interop.Windows.Windows;
namespace ComputeSharp.D2D1.Uwp;
@@ -52,7 +53,7 @@ unsafe partial class PixelShaderEffect
int ICanvasImageInterop.Interface.GetD2DImage(
ICanvasDevice* device,
ID2D1DeviceContext* deviceContext,
- GetD2DImageFlags flags,
+ WIN2D_GET_D2D_IMAGE_FLAGS flags,
float targetDpi,
float* realizeDpi,
ID2D1Image** ppImage)
@@ -77,7 +78,7 @@ unsafe partial class PixelShaderEffect
lock (this.lockObject)
{
// Process the ReadDpiFromDeviceContext flag (same logic as CanvasEffect::GetD2DImage)
- if ((flags & GetD2DImageFlags.ReadDpiFromDeviceContext) != GetD2DImageFlags.None)
+ if ((flags & WIN2D_GET_D2D_IMAGE_FLAGS_READ_DPI_FROM_DEVICE_CONTEXT) != WIN2D_GET_D2D_IMAGE_FLAGS_NONE)
{
// If ReadDpiFromDeviceContext is used, the context cannot be null
if (deviceContext is null)
@@ -88,7 +89,7 @@ unsafe partial class PixelShaderEffect
if (deviceContext->HasCommandListTarget())
{
// Command lists are DPI dependent, so DPI compensation effects are always needed
- flags |= GetD2DImageFlags.AlwaysInsertDpiCompensation;
+ flags |= WIN2D_GET_D2D_IMAGE_FLAGS_ALWAYS_INSERT_DPI_COMPENSATION;
}
else
{
@@ -97,7 +98,7 @@ unsafe partial class PixelShaderEffect
}
// ReadDpiFromDeviceContext has been processed, so it can be removed now
- flags &= ~GetD2DImageFlags.ReadDpiFromDeviceContext;
+ flags &= ~WIN2D_GET_D2D_IMAGE_FLAGS_READ_DPI_FROM_DEVICE_CONTEXT;
}
using ComPtr d2D1Device1 = default;
@@ -125,7 +126,7 @@ unsafe partial class PixelShaderEffect
{
Realize(flags, targetDpi, deviceContext);
}
- else if (!flags.HasFlag(GetD2DImageFlags.MinimalRealization))
+ else if (!flags.HasFlag(WIN2D_GET_D2D_IMAGE_FLAGS_MINIMAL_REALIZATION))
{
// Recurse through the effect graph and ensure all nodes are initialized
RefreshInputs(flags, targetDpi, deviceContext);
@@ -187,7 +188,7 @@ unsafe partial class PixelShaderEffect
/// The current flags in use.
/// The target DPI in use.
/// The instance in use.
- private void Realize(GetD2DImageFlags flags, float targetDpi, ID2D1DeviceContext* deviceContext)
+ private void Realize(WIN2D_GET_D2D_IMAGE_FLAGS flags, float targetDpi, ID2D1DeviceContext* deviceContext)
{
using ComPtr d2D1Factory = default;
@@ -263,7 +264,7 @@ unsafe partial class PixelShaderEffect
/// The current flags in use.
/// The target DPI in use.
/// The instance in use.
- private void RefreshInputs(GetD2DImageFlags flags, float targetDpi, ID2D1DeviceContext* deviceContext)
+ private void RefreshInputs(WIN2D_GET_D2D_IMAGE_FLAGS flags, float targetDpi, ID2D1DeviceContext* deviceContext)
{
// TODO
}
diff --git a/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.Properties.Interop.cs b/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.Properties.Interop.cs
index 54a6ce52..3b1f8569 100644
--- a/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.Properties.Interop.cs
+++ b/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.Properties.Interop.cs
@@ -6,6 +6,7 @@ using ComputeSharp.Interop;
using Microsoft.Graphics.Canvas;
using TerraFX.Interop.DirectX;
using Windows.Graphics.Effects;
+using static ABI.Microsoft.Graphics.Canvas.WIN2D_GET_D2D_IMAGE_FLAGS;
namespace ComputeSharp.D2D1.Uwp;
@@ -128,10 +129,10 @@ unsafe partial class PixelShaderEffect
if (this.d2D1Effect.Get() is not null)
{
- const GetD2DImageFlags sourceFlags =
- GetD2DImageFlags.MinimalRealization |
- GetD2DImageFlags.AllowNullEffectInputs |
- GetD2DImageFlags.UnrealizeOnFailure;
+ const WIN2D_GET_D2D_IMAGE_FLAGS sourceFlags =
+ WIN2D_GET_D2D_IMAGE_FLAGS_MINIMAL_REALIZATION |
+ WIN2D_GET_D2D_IMAGE_FLAGS_ALLOW_NULL_EFFECT_INPUTS |
+ WIN2D_GET_D2D_IMAGE_FLAGS_UNREALIZE_ON_FAILURE;
// Try to set the source, and unrealize if the operation failed
if (!this.d2D1Effect.Get()->TrySetSource(