Rename GetD2DImageFlags to follow Win2D changes
このコミットが含まれているのは:
1 親
91ef70907b
コミット
eacda866a2
5ファイル変更
+39
-30
検索条件に一致するファイルはありません
@@ -37,7 +37,7 @@ internal unsafe struct ICanvasImageInterop
|
||||
/// <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="GetD2DImageFlags.ReadDpiFromDeviceContext"/> flag is specified. This is because
|
||||
/// <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
|
||||
@@ -47,8 +47,9 @@ internal unsafe struct ICanvasImageInterop
|
||||
/// <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="GetD2DImageFlags.ReadDpiFromDeviceContext"/>, <see cref="GetD2DImageFlags.AlwaysInsertDpiCompensation"/>
|
||||
/// or <see cref="GetD2DImageFlags.NeverInsertDpiCompensation"/>
|
||||
/// <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
|
||||
@@ -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]<ICanvasImageInterop*, ICanvasDevice*, ID2D1DeviceContext*, GetD2DImageFlags, float, float*, ID2D1Image**, int>)this.lpVtbl[4])(
|
||||
return ((delegate* unmanaged[Stdcall]<ICanvasImageInterop*, ICanvasDevice*, ID2D1DeviceContext*, WIN2D_GET_D2D_IMAGE_FLAGS, float, float*, ID2D1Image**, int>)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);
|
||||
|
||||
+13
-8
@@ -6,40 +6,45 @@ namespace ABI.Microsoft.Graphics.Canvas;
|
||||
/// Options for fine-tuning the behavior of <see cref="ICanvasImageInterop.Interface.GetD2DImage"/>.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
internal enum GetD2DImageFlags
|
||||
internal enum WIN2D_GET_D2D_IMAGE_FLAGS : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// No options specified.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
WIN2D_GET_D2D_IMAGE_FLAGS_NONE = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Ignore the <c>targetDpi</c> parameter, read DPI from <c>deviceContext</c> instead.
|
||||
/// </summary>
|
||||
ReadDpiFromDeviceContext = 1,
|
||||
WIN2D_GET_D2D_IMAGE_FLAGS_READ_DPI_FROM_DEVICE_CONTEXT = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Ignore the <c>targetDpi</c> parameter, always insert DPI compensation.
|
||||
/// </summary>
|
||||
AlwaysInsertDpiCompensation = 2,
|
||||
WIN2D_GET_D2D_IMAGE_FLAGS_ALWAYS_INSERT_DPI_COMPENSATION = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Ignore the <c>targetDpi</c> parameter, never insert DPI compensation.
|
||||
/// </summary>
|
||||
NeverInsertDpiCompensation = 4,
|
||||
WIN2D_GET_D2D_IMAGE_FLAGS_NEVER_INSERT_DPI_COMPENSATION = 4,
|
||||
|
||||
/// <summary>
|
||||
/// Do the bare minimum to get back an <c>ID2D1Image</c>, no validation or recursive realization.
|
||||
/// </summary>
|
||||
MinimalRealization = 8,
|
||||
WIN2D_GET_D2D_IMAGE_FLAGS_MINIMAL_REALIZATION = 8,
|
||||
|
||||
/// <summary>
|
||||
/// Allow partially configured effect graphs where some inputs are <see langword="null"/>.
|
||||
/// </summary>
|
||||
AllowNullEffectInputs = 16,
|
||||
WIN2D_GET_D2D_IMAGE_FLAGS_ALLOW_NULL_EFFECT_INPUTS = 16,
|
||||
|
||||
/// <summary>
|
||||
/// If an input is invalid, unrealize the effect and set the output image to <see langword="null"/>.
|
||||
/// </summary>
|
||||
UnrealizeOnFailure = 32
|
||||
WIN2D_GET_D2D_IMAGE_FLAGS_UNREALIZE_ON_FAILURE = 32,
|
||||
|
||||
/// <summary>
|
||||
/// Ignored.
|
||||
/// </summary>
|
||||
WIN2D_GET_D2D_IMAGE_FLAGS_FORCE_DWORD = 0xffffffff
|
||||
}
|
||||
@@ -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.");
|
||||
|
||||
@@ -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<T>
|
||||
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<T>
|
||||
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<T>
|
||||
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<T>
|
||||
}
|
||||
|
||||
// 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<ID2D1Device1> d2D1Device1 = default;
|
||||
@@ -125,7 +126,7 @@ unsafe partial class PixelShaderEffect<T>
|
||||
{
|
||||
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<T>
|
||||
/// <param name="flags">The current flags in use.</param>
|
||||
/// <param name="targetDpi">The target DPI in use.</param>
|
||||
/// <param name="deviceContext">The <see cref="ID2D1DeviceContext"/> instance in use.</param>
|
||||
private void Realize(GetD2DImageFlags flags, float targetDpi, ID2D1DeviceContext* deviceContext)
|
||||
private void Realize(WIN2D_GET_D2D_IMAGE_FLAGS flags, float targetDpi, ID2D1DeviceContext* deviceContext)
|
||||
{
|
||||
using ComPtr<ID2D1Factory> d2D1Factory = default;
|
||||
|
||||
@@ -263,7 +264,7 @@ unsafe partial class PixelShaderEffect<T>
|
||||
/// <param name="flags">The current flags in use.</param>
|
||||
/// <param name="targetDpi">The target DPI in use.</param>
|
||||
/// <param name="deviceContext">The <see cref="ID2D1DeviceContext"/> instance in use.</param>
|
||||
private void RefreshInputs(GetD2DImageFlags flags, float targetDpi, ID2D1DeviceContext* deviceContext)
|
||||
private void RefreshInputs(WIN2D_GET_D2D_IMAGE_FLAGS flags, float targetDpi, ID2D1DeviceContext* deviceContext)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
@@ -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<T>
|
||||
|
||||
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(
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする