diff --git a/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/GetImageFlags.cs b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/GetImageFlags.cs new file mode 100644 index 00000000..af94310b --- /dev/null +++ b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/GetImageFlags.cs @@ -0,0 +1,45 @@ +using System; + +namespace ABI.Microsoft.Graphics.Canvas; + +/// +/// Options for fine-tuning the behavior of ICanvasImageInternal::GetD2DImage. +/// +[Flags] +internal enum GetImageFlags +{ + /// + /// No options specified. + /// + None = 0, + + /// + /// Ignore the targetDpi parameter, read DPI from deviceContext instead. + /// + ReadDpiFromDeviceContext = 1, + + /// + /// Ignore the targetDpi parameter, always insert DPI compensation. + /// + AlwaysInsertDpiCompensation = 2, + + /// + /// Ignore the targetDpi parameter, never insert DPI compensation. + /// + NeverInsertDpiCompensation = 4, + + /// + /// Do the bare minimum to get back an ID2D1Image, no validation or recursive realization. + /// + MinimalRealization = 8, + + /// + /// Allow partially configured effect graphs where some inputs are . + /// + AllowNullEffectInputs = 16, + + /// + /// If an input is invalid, unrealize the effect and return rather than throwing. + /// + UnrealizeOnFailure = 32 +} \ No newline at end of file diff --git a/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ICanvasImageInternal.cs b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ICanvasImageInternal.cs new file mode 100644 index 00000000..d9d5db96 --- /dev/null +++ b/src/ComputeSharp.D2D1.Uwp/ABI.Microsoft.Graphics.Canvas/ICanvasImageInternal.cs @@ -0,0 +1,50 @@ +using System.Runtime.InteropServices; +using System; +using TerraFX.Interop.DirectX; +using TerraFX.Interop.Windows; +using TerraFX.Interop; + +namespace ABI.Microsoft.Graphics.Canvas; + +/// +/// Internal Win2D interface for all images and effects that can be drawn. +/// +[ComImport] +[Guid("2F434224-053C-4978-87C4-CFAAFA2F4FAC")] +[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] +internal unsafe interface ICanvasImageInternal +{ + /// + /// Gets an from an instance. + /// + /// A pointer to the return buffer to write the result into (needed for ABI matching). + /// The input canvas device (as pointer to internal interface). + /// + /// The device context in use. This value is is optional (but recommended), except when the + /// 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 + /// to have the implementation do this lookup only if/when it turns out to be needed. + /// + /// The flags to use to get the image. + /// + /// 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 + /// + /// + /// The DPI of a source bitmap, or zero if the image does not have a fixed DPI. A D2D1DpiCompensation effect + /// will be inserted if and are different (flags permitting). + /// + /// A pointer to the resulting image (this value is the same as ). + [PreserveSig] + ID2D1Image** GetD2DImage( + ID2D1Image** retBuf, + [NativeTypeName("ICanvasDevice*")] IUnknown* device, + ID2D1DeviceContext* deviceContext, + GetImageFlags flags, + float targetDpi, + float* realizeDpi); +} \ No newline at end of file diff --git a/src/ComputeSharp.D2D1/ComputeSharp.D2D1.csproj b/src/ComputeSharp.D2D1/ComputeSharp.D2D1.csproj index d80e2324..7a528d56 100644 --- a/src/ComputeSharp.D2D1/ComputeSharp.D2D1.csproj +++ b/src/ComputeSharp.D2D1/ComputeSharp.D2D1.csproj @@ -6,6 +6,10 @@ windows6.1 + + + +