Add APIs for D2D1 resource manager interfaces

このコミットが含まれているのは:
Sergio Pedri committed 2022-08-15 15:01:15 +02:00
1 親 ef041a8fc2
コミット bb77049d10
1ファイル変更
+124
@@ -2,6 +2,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
#if NET6_0_OR_GREATER
using RuntimeHelpers = System.Runtime.CompilerServices.RuntimeHelpers;
@@ -193,6 +194,27 @@ internal unsafe struct D2D1ResourceTextureManager
private static class ID2D1ResourceTextureManagerMethods
{
#if !NET6_0_OR_GREATER
/// <inheritdoc cref="CreateResourceTexture"/>
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate int CreateResourceTextureDelegate(
D2D1ResourceTextureManager* @this,
Guid* resourceId,
D2D1_RESOURCE_TEXTURE_PROPERTIES* resourceTextureProperties,
byte* data,
uint* strides,
uint dataSize);
/// <inheritdoc cref="Update"/>
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate int UpdateDelegate(
D2D1ResourceTextureManager* @this,
uint* minimumExtents,
uint* maximumExtents,
uint* strides,
uint dimensions,
byte* data,
uint dataCount);
/// <summary>
/// A cached <see cref="QueryInterfaceDelegate"/> instance wrapping <see cref="QueryInterface"/>.
/// </summary>
@@ -207,6 +229,16 @@ internal unsafe struct D2D1ResourceTextureManager
/// A cached <see cref="ReleaseDelegate"/> instance wrapping <see cref="Release"/>.
/// </summary>
public static readonly ReleaseDelegate ReleaseWrapper = Release;
/// <summary>
/// A cached <see cref="CreateResourceTextureDelegate"/> instance wrapping <see cref="CreateResourceTexture"/>.
/// </summary>
public static readonly CreateResourceTextureDelegate CreateResourceTextureWrapper = CreateResourceTexture;
/// <summary>
/// A cached <see cref="UpdateDelegate"/> instance wrapping <see cref="Update"/>.
/// </summary>
public static readonly UpdateDelegate UpdateWrapper = Update;
#endif
/// <inheritdoc cref="D2D1ResourceTextureManager.QueryInterface"/>
@@ -229,6 +261,56 @@ internal unsafe struct D2D1ResourceTextureManager
{
return @this->Release();
}
/// <summary>
/// Creates or finds the given resource texture, depending on whether a resource id is specified.
/// It also optionally initializes the texture with the specified data.
/// </summary>
/// <param name="this">The current <c>ID2D1ResourceTextureManager</c> instance.</param>
/// <param name="resourceId">An optional pointer to the unique id that identifies the resource texture.</param>
/// <param name="resourceTextureProperties">The properties used to create the resource texture.</param>
/// <param name="data">The optional data to be loaded into the resource texture.</param>
/// <param name="strides">An optional pointer to the stride to advance through the resource texture, according to dimension.</param>
/// <param name="dataSize">The size, in bytes, of the data.</param>
/// <returns>An <see cref="HRESULT"/> for the operation.</returns>
private static int CreateResourceTexture(
D2D1ResourceTextureManager* @this,
Guid* resourceId,
D2D1_RESOURCE_TEXTURE_PROPERTIES* resourceTextureProperties,
byte* data,
uint* strides,
uint dataSize)
{
@this = (D2D1ResourceTextureManager*)&((void**)@this)[-1];
return 0;
}
/// <summary>
/// Updates the specific resource texture inside the specific range or box using the supplied data.
/// </summary>
/// <param name="this">The current <c>ID2D1ResourceTextureManager</c> instance.</param>
/// <param name="minimumExtents">The "left" extent of the updates if specified. If <see langword="null"/>, the entire texture is updated.</param>
/// <param name="maximumExtents">The "right" extent of the updates if specified. If <see langword="null"/>, the entire texture is updated.</param>
/// <param name="strides">The stride to advance through the input data, according to dimension.</param>
/// <param name="dimensions">The number of dimensions in the resource texture. This must match the number used to load the texture.</param>
/// <param name="data">The data to be placed into the resource texture.</param>
/// <param name="dataCount">The size of the data buffer to be used to update the resource texture.</param>
/// <returns>An <see cref="HRESULT"/> for the operation.</returns>
[UnmanagedCallersOnly]
private static int Update(
D2D1ResourceTextureManager* @this,
uint* minimumExtents,
uint* maximumExtents,
uint* strides,
uint dimensions,
byte* data,
uint dataCount)
{
@this = (D2D1ResourceTextureManager*)&((void**)@this)[-1];
return 0;
}
}
/// <summary>
@@ -237,6 +319,14 @@ internal unsafe struct D2D1ResourceTextureManager
private unsafe static class ID2D1ResourceTextureManagerInternalMethods
{
#if !NET6_0_OR_GREATER
/// <inheritdoc cref="Initialize"/>
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate int InitializeDelegate(D2D1ResourceTextureManager* @this, ID2D1EffectContext* effectContext);
/// <inheritdoc cref="GetResourceTexture"/>
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate int GetResourceTextureDelegate(D2D1ResourceTextureManager* @this, ID2D1ResourceTexture** resourceTexture);
/// <summary>
/// A cached <see cref="QueryInterfaceDelegate"/> instance wrapping <see cref="QueryInterface"/>.
/// </summary>
@@ -251,6 +341,16 @@ internal unsafe struct D2D1ResourceTextureManager
/// A cached <see cref="ReleaseDelegate"/> instance wrapping <see cref="Release"/>.
/// </summary>
public static readonly ReleaseDelegate ReleaseWrapper = Release;
/// <summary>
/// A cached <see cref="InitializeDelegate"/> instance wrapping <see cref="Initialize"/>.
/// </summary>
public static readonly InitializeDelegate InitializeWrapper = Initialize;
/// <summary>
/// A cached <see cref="GetResourceTextureDelegate"/> instance wrapping <see cref="GetResourceTexture"/>.
/// </summary>
public static readonly GetResourceTextureDelegate GetResourceTextureWrapper = GetResourceTexture;
#endif
/// <inheritdoc cref="D2D1ResourceTextureManager.QueryInterface"/>
@@ -279,5 +379,29 @@ internal unsafe struct D2D1ResourceTextureManager
return @this->Release();
}
/// <summary>
/// Initializes the current <c>ID2D1ResourceTextureManagerInternal</c> instance.
/// </summary>
/// <param name="this">The current <c>ID2D1ResourceTextureManagerInternal</c> instance.</param>
/// <param name="effectContext">The input <see cref="ID2D1EffectContext"/> for the manager.</param>
/// <returns>An <see cref="HRESULT"/> for the operation.</returns>
[UnmanagedCallersOnly]
private static int Initialize(D2D1ResourceTextureManager* @this, ID2D1EffectContext* effectContext)
{
return 0;
}
/// <summary>
/// Gets the <see cref="ID2D1ResourceTexture"/> instance held by the manager.
/// </summary>
/// <param name="this">The current <c>ID2D1ResourceTextureManagerInternal</c> instance.</param>
/// <param name="resourceTexture">The resulting <see cref="ID2D1ResourceTexture"/> instance.</param>
/// <returns>An <see cref="HRESULT"/> for the operation.</returns>
[UnmanagedCallersOnly]
private static int GetResourceTexture(D2D1ResourceTextureManager* @this, ID2D1ResourceTexture** resourceTexture)
{
return 0;
}
}
}