Add ID2D1TransformMapperInternal interface
このコミットが含まれているのは:
1 親
6f726a5951
コミット
9e95a1cb80
4ファイル変更
+367
-181
検索条件に一致するファイルはありません
+165
-102
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.CompilerServices;
|
||||
#if NET6_0_OR_GREATER
|
||||
using System.Runtime.InteropServices;
|
||||
#endif
|
||||
using ComputeSharp.D2D1.Extensions;
|
||||
using ComputeSharp.D2D1.Interop.Effects;
|
||||
using TerraFX.Interop.Windows;
|
||||
@@ -16,128 +14,193 @@ namespace ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMappers;
|
||||
/// <inheritdoc/>
|
||||
unsafe partial struct D2D1TransformMapperImpl
|
||||
{
|
||||
/// <inheritdoc cref="QueryInterface(Guid*, void**)"/>
|
||||
[UnmanagedCallersOnly]
|
||||
private static int QueryInterface(D2D1TransformMapperImpl* @this, Guid* riid, void** ppvObject)
|
||||
/// <summary>
|
||||
/// The implementation for <see cref="ID2D1TransformMapper"/>.
|
||||
/// </summary>
|
||||
private static class ID2D1TransformMapperMethods
|
||||
{
|
||||
return @this->QueryInterface(riid, ppvObject);
|
||||
}
|
||||
#if !NET6_0_OR_GREATER
|
||||
/// <inheritdoc cref="ID2D1TransformMapper.MapInputRectsToOutputRect"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
public delegate int MapInputRectsToOutputRectDelegate(
|
||||
D2D1TransformMapperImpl* @this,
|
||||
ID2D1DrawInfoUpdateContext* d2D1DrawInfoUpdateContext,
|
||||
RECT* inputRects,
|
||||
RECT* inputOpaqueSubRects,
|
||||
uint inputRectCount,
|
||||
RECT* outputRect,
|
||||
RECT* outputOpaqueSubRect);
|
||||
|
||||
/// <inheritdoc cref="AddRef()"/>
|
||||
[UnmanagedCallersOnly]
|
||||
private static uint AddRef(D2D1TransformMapperImpl* @this)
|
||||
{
|
||||
return @this->AddRef();
|
||||
}
|
||||
/// <inheritdoc cref="ID2D1TransformMapper.MapOutputRectToInputRects"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
public delegate int MapOutputRectToInputRectsDelegate(
|
||||
D2D1TransformMapperImpl* @this,
|
||||
RECT* outputRect,
|
||||
RECT* inputRects,
|
||||
uint inputRectsCount);
|
||||
|
||||
/// <inheritdoc cref="Release()"/>
|
||||
[UnmanagedCallersOnly]
|
||||
private static uint Release(D2D1TransformMapperImpl* @this)
|
||||
{
|
||||
return @this->Release();
|
||||
}
|
||||
/// <inheritdoc cref="ID2D1TransformMapper.MapInvalidRect"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
public delegate int MapInvalidRectDelegate(
|
||||
D2D1TransformMapperImpl* @this,
|
||||
uint inputIndex,
|
||||
RECT invalidInputRect,
|
||||
RECT* invalidOutputRect);
|
||||
|
||||
/// <inheritdoc cref="ID2D1TransformMapper.MapInputRectsToOutputRect"/>
|
||||
[UnmanagedCallersOnly]
|
||||
private static int MapInputRectsToOutputRect(
|
||||
D2D1TransformMapperImpl* @this,
|
||||
ID2D1DrawInfoUpdateContext* d2D1DrawInfoUpdateContext,
|
||||
RECT* inputRects,
|
||||
RECT* inputOpaqueSubRects,
|
||||
uint inputRectCount,
|
||||
RECT* outputRect,
|
||||
RECT* outputOpaqueSubRect)
|
||||
{
|
||||
Span<Rectangle> inputs = stackalloc Rectangle[8].Slice(0, (int)inputRectCount);
|
||||
Span<Rectangle> opaqueInputs = stackalloc Rectangle[8].Slice(0, (int)inputRectCount);
|
||||
/// <summary>
|
||||
/// A cached <see cref="QueryInterfaceDelegate"/> instance wrapping <see cref="QueryInterface"/>.
|
||||
/// </summary>
|
||||
public static readonly QueryInterfaceDelegate QueryInterfaceWrapper = QueryInterface;
|
||||
|
||||
for (int i = 0; i < (int)inputRectCount; i++)
|
||||
/// <summary>
|
||||
/// A cached <see cref="AddRefDelegate"/> instance wrapping <see cref="AddRef"/>.
|
||||
/// </summary>
|
||||
public static readonly AddRefDelegate AddRefWrapper = AddRef;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="ReleaseDelegate"/> instance wrapping <see cref="Release"/>.
|
||||
/// </summary>
|
||||
public static readonly ReleaseDelegate ReleaseWrapper = Release;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="MapInputRectsToOutputRectDelegate"/> instance wrapping <see cref="MapInputRectsToOutputRect"/>.
|
||||
/// </summary>
|
||||
public static readonly MapInputRectsToOutputRectDelegate MapInputRectsToOutputRectWrapper = MapInputRectsToOutputRect;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="MapOutputRectToInputRectsDelegate"/> instance wrapping <see cref="MapOutputRectToInputRects"/>.
|
||||
/// </summary>
|
||||
public static readonly MapOutputRectToInputRectsDelegate MapOutputRectToInputRectsWrapper = MapOutputRectToInputRects;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="MapInvalidRectDelegate"/> instance wrapping <see cref="MapInvalidRect"/>.
|
||||
/// </summary>
|
||||
public static readonly MapInvalidRectDelegate MapInvalidRectWrapper = MapInvalidRect;
|
||||
#endif
|
||||
|
||||
/// <inheritdoc cref="D2D1TransformMapperImpl.QueryInterface"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static int QueryInterface(D2D1TransformMapperImpl* @this, Guid* riid, void** ppvObject)
|
||||
{
|
||||
inputs[i] = inputRects[i].ToRectangle();
|
||||
opaqueInputs[i] = inputOpaqueSubRects[i].ToRectangle();
|
||||
return @this->QueryInterface(riid, ppvObject);
|
||||
}
|
||||
|
||||
Rectangle output;
|
||||
Rectangle opaqueOutput;
|
||||
|
||||
// Invoke MapInputsToOutput and handle exceptions so they don't cross the ABI boundary
|
||||
try
|
||||
/// <inheritdoc cref="D2D1TransformMapperImpl.AddRef"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static uint AddRef(D2D1TransformMapperImpl* @this)
|
||||
{
|
||||
Unsafe.As<ID2D1TransformMapperInterop>(@this->transformMapperHandle.Target!).MapInputsToOutput(
|
||||
d2D1DrawInfoUpdateContext,
|
||||
inputs,
|
||||
opaqueInputs,
|
||||
out output,
|
||||
out opaqueOutput);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return e.HResult;
|
||||
return @this->AddRef();
|
||||
}
|
||||
|
||||
*outputRect = output.ToRECT();
|
||||
*outputOpaqueSubRect = opaqueOutput.ToRECT();
|
||||
|
||||
return S.S_OK;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID2D1TransformMapper.MapOutputRectToInputRects"/>
|
||||
[UnmanagedCallersOnly]
|
||||
private static int MapOutputRectToInputRects(
|
||||
D2D1TransformMapperImpl* @this,
|
||||
RECT* outputRect,
|
||||
RECT* inputRects,
|
||||
uint inputRectsCount)
|
||||
{
|
||||
Rectangle output = outputRect->ToRectangle();
|
||||
Span<Rectangle> inputs = stackalloc Rectangle[8].Slice(0, (int)inputRectsCount);
|
||||
|
||||
for (int i = 0; i < (int)inputRectsCount; i++)
|
||||
/// <inheritdoc cref="D2D1TransformMapperImpl.Release"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static uint Release(D2D1TransformMapperImpl* @this)
|
||||
{
|
||||
inputs[i] = inputRects[i].ToRectangle();
|
||||
return @this->Release();
|
||||
}
|
||||
|
||||
// Handle exceptions, as mentioned above
|
||||
try
|
||||
/// <inheritdoc cref="ID2D1TransformMapper.MapInputRectsToOutputRect"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static int MapInputRectsToOutputRect(
|
||||
D2D1TransformMapperImpl* @this,
|
||||
ID2D1DrawInfoUpdateContext* d2D1DrawInfoUpdateContext,
|
||||
RECT* inputRects,
|
||||
RECT* inputOpaqueSubRects,
|
||||
uint inputRectCount,
|
||||
RECT* outputRect,
|
||||
RECT* outputOpaqueSubRect)
|
||||
{
|
||||
Unsafe.As<ID2D1TransformMapperInterop>(@this->transformMapperHandle.Target!).MapOutputToInputs(in output, inputs);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return e.HResult;
|
||||
Span<Rectangle> inputs = stackalloc Rectangle[8].Slice(0, (int)inputRectCount);
|
||||
Span<Rectangle> opaqueInputs = stackalloc Rectangle[8].Slice(0, (int)inputRectCount);
|
||||
|
||||
for (int i = 0; i < (int)inputRectCount; i++)
|
||||
{
|
||||
inputs[i] = inputRects[i].ToRectangle();
|
||||
opaqueInputs[i] = inputOpaqueSubRects[i].ToRectangle();
|
||||
}
|
||||
|
||||
Rectangle output;
|
||||
Rectangle opaqueOutput;
|
||||
|
||||
// Invoke MapInputsToOutput and handle exceptions so they don't cross the ABI boundary
|
||||
try
|
||||
{
|
||||
Unsafe.As<ID2D1TransformMapperInterop>(@this->transformMapperHandle.Target!).MapInputsToOutput(
|
||||
d2D1DrawInfoUpdateContext,
|
||||
inputs,
|
||||
opaqueInputs,
|
||||
out output,
|
||||
out opaqueOutput);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return e.HResult;
|
||||
}
|
||||
|
||||
*outputRect = output.ToRECT();
|
||||
*outputOpaqueSubRect = opaqueOutput.ToRECT();
|
||||
|
||||
return S.S_OK;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (int)inputRectsCount; i++)
|
||||
/// <inheritdoc cref="ID2D1TransformMapper.MapOutputRectToInputRects"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static int MapOutputRectToInputRects(
|
||||
D2D1TransformMapperImpl* @this,
|
||||
RECT* outputRect,
|
||||
RECT* inputRects,
|
||||
uint inputRectsCount)
|
||||
{
|
||||
inputRects[i] = inputs[i].ToRECT();
|
||||
Rectangle output = outputRect->ToRectangle();
|
||||
Span<Rectangle> inputs = stackalloc Rectangle[8].Slice(0, (int)inputRectsCount);
|
||||
|
||||
for (int i = 0; i < (int)inputRectsCount; i++)
|
||||
{
|
||||
inputs[i] = inputRects[i].ToRectangle();
|
||||
}
|
||||
|
||||
// Handle exceptions, as mentioned above
|
||||
try
|
||||
{
|
||||
Unsafe.As<ID2D1TransformMapperInterop>(@this->transformMapperHandle.Target!).MapOutputToInputs(in output, inputs);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return e.HResult;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (int)inputRectsCount; i++)
|
||||
{
|
||||
inputRects[i] = inputs[i].ToRECT();
|
||||
}
|
||||
|
||||
return S.S_OK;
|
||||
}
|
||||
|
||||
return S.S_OK;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID2D1TransformMapper.MapInvalidRect"/>
|
||||
[UnmanagedCallersOnly]
|
||||
private static int MapInvalidRect(
|
||||
D2D1TransformMapperImpl* @this,
|
||||
uint inputIndex,
|
||||
RECT invalidInputRect,
|
||||
RECT* invalidOutputRect)
|
||||
{
|
||||
Rectangle invalidInput = invalidInputRect.ToRectangle();
|
||||
Rectangle invalidOutput;
|
||||
|
||||
// Handle exceptions once again
|
||||
try
|
||||
/// <inheritdoc cref="ID2D1TransformMapper.MapInvalidRect"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static int MapInvalidRect(
|
||||
D2D1TransformMapperImpl* @this,
|
||||
uint inputIndex,
|
||||
RECT invalidInputRect,
|
||||
RECT* invalidOutputRect)
|
||||
{
|
||||
Unsafe.As<ID2D1TransformMapperInterop>(@this->transformMapperHandle.Target!).MapInvalidOutput((int)inputIndex, invalidInput, out invalidOutput);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return e.HResult;
|
||||
}
|
||||
Rectangle invalidInput = invalidInputRect.ToRectangle();
|
||||
Rectangle invalidOutput;
|
||||
|
||||
*invalidOutputRect = invalidOutput.ToRECT();
|
||||
// Handle exceptions once again
|
||||
try
|
||||
{
|
||||
Unsafe.As<ID2D1TransformMapperInterop>(@this->transformMapperHandle.Target!).MapInvalidOutput((int)inputIndex, invalidInput, out invalidOutput);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return e.HResult;
|
||||
}
|
||||
|
||||
return S.S_OK;
|
||||
*invalidOutputRect = invalidOutput.ToRECT();
|
||||
|
||||
return S.S_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using TerraFX.Interop.Windows;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using UnmanagedCallersOnlyAttribute = ComputeSharp.NetStandard.System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute;
|
||||
#endif
|
||||
|
||||
namespace ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMappers;
|
||||
|
||||
/// <inheritdoc/>
|
||||
unsafe partial struct D2D1TransformMapperImpl
|
||||
{
|
||||
/// <summary>
|
||||
/// The implementation for <see cref="ID2D1TransformMapperInternal"/>.
|
||||
/// </summary>
|
||||
private static class ID2D1TransformMapperInternalMethods
|
||||
{
|
||||
#if !NET6_0_OR_GREATER
|
||||
/// <inheritdoc cref="ID2D1TransformMapperInternal.GetManagedWrapperHandle"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
public delegate int GetManagedWrapperHandleDelegate(D2D1TransformMapperImpl* @this, void** ppvHandle);
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="QueryInterfaceDelegate"/> instance wrapping <see cref="QueryInterface"/>.
|
||||
/// </summary>
|
||||
public static readonly QueryInterfaceDelegate QueryInterfaceWrapper = QueryInterface;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="AddRefDelegate"/> instance wrapping <see cref="AddRef"/>.
|
||||
/// </summary>
|
||||
public static readonly AddRefDelegate AddRefWrapper = AddRef;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="ReleaseDelegate"/> instance wrapping <see cref="Release"/>.
|
||||
/// </summary>
|
||||
public static readonly ReleaseDelegate ReleaseWrapper = Release;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="GetManagedWrapperHandleDelegate"/> instance wrapping <see cref="GetManagedWrapperHandle"/>.
|
||||
/// </summary>
|
||||
public static readonly GetManagedWrapperHandleDelegate GetManagedWrapperHandleWrapper = GetManagedWrapperHandle;
|
||||
#endif
|
||||
|
||||
/// <inheritdoc cref="D2D1TransformMapperImpl.QueryInterface"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static int QueryInterface(D2D1TransformMapperImpl* @this, Guid* riid, void** ppvObject)
|
||||
{
|
||||
@this = (D2D1TransformMapperImpl*)&((void**)@this)[-1];
|
||||
|
||||
return @this->QueryInterface(riid, ppvObject);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="D2D1TransformMapperImpl.AddRef"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static uint AddRef(D2D1TransformMapperImpl* @this)
|
||||
{
|
||||
@this = (D2D1TransformMapperImpl*)&((void**)@this)[-1];
|
||||
|
||||
return @this->AddRef();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="D2D1TransformMapperImpl.Release"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static uint Release(D2D1TransformMapperImpl* @this)
|
||||
{
|
||||
@this = (D2D1TransformMapperImpl*)&((void**)@this)[-1];
|
||||
|
||||
return @this->Release();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID2D1TransformMapperInternal.GetManagedWrapperHandle"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static int GetManagedWrapperHandle(D2D1TransformMapperImpl* @this, void** ppvHandle)
|
||||
{
|
||||
@this = (D2D1TransformMapperImpl*)&((void**)@this)[-1];
|
||||
|
||||
if (ppvHandle is null)
|
||||
{
|
||||
return E.E_POINTER;
|
||||
}
|
||||
|
||||
*ppvHandle = (void*)GCHandle.ToIntPtr(@this->transformMapperHandle);
|
||||
|
||||
return S.S_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
+58
-79
@@ -30,101 +30,68 @@ internal unsafe partial struct D2D1TransformMapperImpl
|
||||
/// <inheritdoc cref="IUnknown.Release"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
private delegate uint ReleaseDelegate(D2D1TransformMapperImpl* @this);
|
||||
|
||||
/// <inheritdoc cref="ID2D1TransformMapper.MapInputRectsToOutputRect"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
private delegate int MapInputRectsToOutputRectDelegate(
|
||||
D2D1TransformMapperImpl* @this,
|
||||
ID2D1DrawInfoUpdateContext* d2D1DrawInfoUpdateContext,
|
||||
RECT* inputRects,
|
||||
RECT* inputOpaqueSubRects,
|
||||
uint inputRectCount,
|
||||
RECT* outputRect,
|
||||
RECT* outputOpaqueSubRect);
|
||||
|
||||
/// <inheritdoc cref="ID2D1TransformMapper.MapOutputRectToInputRects"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
private delegate int MapOutputRectToInputRectsDelegate(
|
||||
D2D1TransformMapperImpl* @this,
|
||||
RECT* outputRect,
|
||||
RECT* inputRects,
|
||||
uint inputRectsCount);
|
||||
|
||||
/// <inheritdoc cref="ID2D1TransformMapper.MapInvalidRect"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
private delegate int MapInvalidRectDelegate(
|
||||
D2D1TransformMapperImpl* @this,
|
||||
uint inputIndex,
|
||||
RECT invalidInputRect,
|
||||
RECT* invalidOutputRect);
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="QueryInterfaceDelegate"/> instance wrapping <see cref="QueryInterface(Guid*, void**)"/>.
|
||||
/// </summary>
|
||||
private static readonly QueryInterfaceDelegate QueryInterfaceWrapper = QueryInterface;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="AddRefDelegate"/> instance wrapping <see cref="AddRef()"/>.
|
||||
/// </summary>
|
||||
private static readonly AddRefDelegate AddRefWrapper = AddRef;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="ReleaseDelegate"/> instance wrapping <see cref="Release()"/>.
|
||||
/// </summary>
|
||||
private static readonly ReleaseDelegate ReleaseWrapper = Release;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="MapInputRectsToOutputRectDelegate"/> instance wrapping <see cref="MapInputRectsToOutputRect"/>.
|
||||
/// </summary>
|
||||
private static readonly MapInputRectsToOutputRectDelegate MapInputRectsToOutputRectWrapper = MapInputRectsToOutputRect;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="MapOutputRectToInputRectsDelegate"/> instance wrapping <see cref="MapOutputRectToInputRects"/>.
|
||||
/// </summary>
|
||||
private static readonly MapOutputRectToInputRectsDelegate MapOutputRectToInputRectsWrapper = MapOutputRectToInputRects;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="MapInvalidRectDelegate"/> instance wrapping <see cref="MapInvalidRect"/>.
|
||||
/// </summary>
|
||||
private static readonly MapInvalidRectDelegate MapInvalidRectWrapper = MapInvalidRect;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// The shared method table pointer for all <see cref="ID2D1TransformMapper"/> instances.
|
||||
/// The shared vtable pointer for <see cref="D2D1TransformMapperImpl"/> instance, for <see cref="ID2D1TransformMapper"/>.
|
||||
/// </summary>
|
||||
private static readonly void** Vtbl = InitVtbl();
|
||||
private static readonly void** VtblForID2D1TransformMapper = InitVtblForID2D1TransformMapperAndID2D1TransformMapperInternal();
|
||||
|
||||
/// <summary>
|
||||
/// Builds the custom method table pointer for <see cref="ID2D1TransformMapper"/>.
|
||||
/// The shared vtable pointer for <see cref="D2D1TransformMapperImpl"/> instance, for <see cref="ID2D1TransformMapperInternal"/>.
|
||||
/// </summary>
|
||||
/// <returns>The method table pointer for <see cref="ID2D1TransformMapper"/>.</returns>
|
||||
private static void** InitVtbl()
|
||||
{
|
||||
void** lpVtbl = (void**)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(D2D1TransformMapperImpl), sizeof(void*) * 6);
|
||||
private static readonly void** VtblForID2D1TransformMapperInternal = &VtblForID2D1TransformMapper[6];
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the combined vtable for <see cref="ID2D1TransformMapper"/> and <see cref="ID2D1TransformMapperInternal"/>.
|
||||
/// </summary>
|
||||
/// <returns>The combined vtable for <see cref="ID2D1TransformMapper"/> and <see cref="ID2D1TransformMapperInternal"/>.</returns>
|
||||
private static void** InitVtblForID2D1TransformMapperAndID2D1TransformMapperInternal()
|
||||
{
|
||||
void** lpVtbl = (void**)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(D2D1TransformMapperImpl), sizeof(void*) * 10);
|
||||
|
||||
// ID2D1ResourceTextureManager
|
||||
#if NET6_0_OR_GREATER
|
||||
lpVtbl[0] = (delegate* unmanaged<D2D1TransformMapperImpl*, Guid*, void**, int>)&QueryInterface;
|
||||
lpVtbl[1] = (delegate* unmanaged<D2D1TransformMapperImpl*, uint>)&AddRef;
|
||||
lpVtbl[2] = (delegate* unmanaged<D2D1TransformMapperImpl*, uint>)&Release;
|
||||
lpVtbl[3] = (delegate* unmanaged<D2D1TransformMapperImpl*, ID2D1DrawInfoUpdateContext*, RECT*, RECT*, uint, RECT*, RECT*, int>)&MapInputRectsToOutputRect;
|
||||
lpVtbl[4] = (delegate* unmanaged<D2D1TransformMapperImpl*, RECT*, RECT*, uint, int>)&MapOutputRectToInputRects;
|
||||
lpVtbl[5] = (delegate* unmanaged<D2D1TransformMapperImpl*, uint, RECT, RECT*, int>)&MapInvalidRect;
|
||||
lpVtbl[0] = (delegate* unmanaged<D2D1TransformMapperImpl*, Guid*, void**, int>)&ID2D1TransformMapperMethods.QueryInterface;
|
||||
lpVtbl[1] = (delegate* unmanaged<D2D1TransformMapperImpl*, uint>)&ID2D1TransformMapperMethods.AddRef;
|
||||
lpVtbl[2] = (delegate* unmanaged<D2D1TransformMapperImpl*, uint>)&ID2D1TransformMapperMethods.Release;
|
||||
lpVtbl[3] = (delegate* unmanaged<D2D1TransformMapperImpl*, ID2D1DrawInfoUpdateContext*, RECT*, RECT*, uint, RECT*, RECT*, int>)&ID2D1TransformMapperMethods.MapInputRectsToOutputRect;
|
||||
lpVtbl[4] = (delegate* unmanaged<D2D1TransformMapperImpl*, RECT*, RECT*, uint, int>)&ID2D1TransformMapperMethods.MapOutputRectToInputRects;
|
||||
lpVtbl[5] = (delegate* unmanaged<D2D1TransformMapperImpl*, uint, RECT, RECT*, int>)&ID2D1TransformMapperMethods.MapInvalidRect;
|
||||
#else
|
||||
lpVtbl[0] = (void*)Marshal.GetFunctionPointerForDelegate(QueryInterfaceWrapper);
|
||||
lpVtbl[1] = (void*)Marshal.GetFunctionPointerForDelegate(AddRefWrapper);
|
||||
lpVtbl[2] = (void*)Marshal.GetFunctionPointerForDelegate(ReleaseWrapper);
|
||||
lpVtbl[3] = (void*)Marshal.GetFunctionPointerForDelegate(MapInputRectsToOutputRectWrapper);
|
||||
lpVtbl[4] = (void*)Marshal.GetFunctionPointerForDelegate(MapOutputRectToInputRectsWrapper);
|
||||
lpVtbl[5] = (void*)Marshal.GetFunctionPointerForDelegate(MapInvalidRectWrapper);
|
||||
lpVtbl[0] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1TransformMapperMethods.QueryInterfaceWrapper);
|
||||
lpVtbl[1] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1TransformMapperMethods.AddRefWrapper);
|
||||
lpVtbl[2] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1TransformMapperMethods.ReleaseWrapper);
|
||||
lpVtbl[3] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1TransformMapperMethods.MapInputRectsToOutputRectWrapper);
|
||||
lpVtbl[4] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1TransformMapperMethods.MapOutputRectToInputRectsWrapper);
|
||||
lpVtbl[5] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1TransformMapperMethods.MapInvalidRectWrapper);
|
||||
#endif
|
||||
|
||||
// ID2D1TransformMapperInternal
|
||||
#if NET6_0_OR_GREATER
|
||||
lpVtbl[6 + 0] = (delegate* unmanaged<D2D1TransformMapperImpl*, Guid*, void**, int>)&ID2D1TransformMapperInternalMethods.QueryInterface;
|
||||
lpVtbl[6 + 1] = (delegate* unmanaged<D2D1TransformMapperImpl*, uint>)&ID2D1TransformMapperInternalMethods.AddRef;
|
||||
lpVtbl[6 + 2] = (delegate* unmanaged<D2D1TransformMapperImpl*, uint>)&ID2D1TransformMapperInternalMethods.Release;
|
||||
lpVtbl[6 + 3] = (delegate* unmanaged<D2D1TransformMapperImpl*, void**, int>)&ID2D1TransformMapperInternalMethods.GetManagedWrapperHandle;
|
||||
#else
|
||||
lpVtbl[6 + 0] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1TransformMapperInternalMethods.QueryInterfaceWrapper);
|
||||
lpVtbl[6 + 1] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1TransformMapperInternalMethods.AddRefWrapper);
|
||||
lpVtbl[6 + 2] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1TransformMapperInternalMethods.ReleaseWrapper);
|
||||
lpVtbl[6 + 3] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1TransformMapperInternalMethods.GetManagedWrapperHandleWrapper);
|
||||
#endif
|
||||
|
||||
return lpVtbl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The vtable pointer for the current instance.
|
||||
/// The vtable pointer for the current instance, for <see cref="ID2D1TransformMapper"/>.
|
||||
/// </summary>
|
||||
private void** lpVtbl;
|
||||
private void** lpVtblForID2D1TransformMapper;
|
||||
|
||||
/// <summary>
|
||||
/// The vtable pointer for the current instance, for <see cref="ID2D1TransformMapperInternal"/>.
|
||||
/// </summary>
|
||||
private void** lpVtblForID2D1TransformMapperInternal;
|
||||
|
||||
/// <summary>
|
||||
/// The current reference count for the object (from <see cref="IUnknown"/>).
|
||||
@@ -152,7 +119,8 @@ internal unsafe partial struct D2D1TransformMapperImpl
|
||||
{
|
||||
D2D1TransformMapperImpl* @this = (D2D1TransformMapperImpl*)NativeMemory.Alloc((nuint)sizeof(D2D1TransformMapperImpl));
|
||||
|
||||
@this->lpVtbl = Vtbl;
|
||||
@this->lpVtblForID2D1TransformMapper = VtblForID2D1TransformMapper;
|
||||
@this->lpVtblForID2D1TransformMapperInternal = VtblForID2D1TransformMapperInternal;
|
||||
@this->referenceCount = 1;
|
||||
@this->transformMapperHandle = GCHandle.Alloc(transformMapper);
|
||||
@this->spinLock = new SpinLock(enableThreadOwnerTracking: false);
|
||||
@@ -203,6 +171,7 @@ internal unsafe partial struct D2D1TransformMapperImpl
|
||||
return E.E_POINTER;
|
||||
}
|
||||
|
||||
// ID2D1TransformMapper
|
||||
if (riid->Equals(Windows.__uuidof<IUnknown>()) ||
|
||||
riid->Equals(ID2D1TransformMapper.Guid))
|
||||
{
|
||||
@@ -213,6 +182,16 @@ internal unsafe partial struct D2D1TransformMapperImpl
|
||||
return S.S_OK;
|
||||
}
|
||||
|
||||
// ID2D1TransformMapperInternal
|
||||
if (riid->Equals(ID2D1TransformMapperInternal.Guid))
|
||||
{
|
||||
this.referenceCount++;
|
||||
|
||||
*ppvObject = (void**)Unsafe.AsPointer(ref this) + 1;
|
||||
|
||||
return S.S_OK;
|
||||
}
|
||||
|
||||
*ppvObject = null;
|
||||
|
||||
return E.E_NOINTERFACE;
|
||||
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
namespace ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMappers;
|
||||
|
||||
/// <summary>
|
||||
/// The internal transform mapper manager interface.
|
||||
/// </summary>
|
||||
[Guid("C5D8FC65-FB86-4C2D-9EF5-95AEC639C952")]
|
||||
internal unsafe struct ID2D1TransformMapperInternal
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="System.Guid"/> for <see cref="ID2D1TransformMapper"/> (<c>C5D8FC65-FB86-4C2D-9EF5-95AEC639C952</c>).
|
||||
/// </summary>
|
||||
public static ref readonly Guid Guid
|
||||
{
|
||||
get
|
||||
{
|
||||
ReadOnlySpan<byte> data = new byte[] {
|
||||
0x65, 0xFC, 0xD8, 0xC5,
|
||||
0x86, 0xFB,
|
||||
0xF5, 0x9E,
|
||||
0x9E, 0xF5,
|
||||
0x95,
|
||||
0xAE,
|
||||
0xC6,
|
||||
0x39,
|
||||
0xC9,
|
||||
0x52
|
||||
};
|
||||
|
||||
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The vtable for the current instance.
|
||||
/// </summary>
|
||||
private readonly void** lpVtbl;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="GCHandle"/> value for the managed wrapper associated with this CCW.
|
||||
/// </summary>
|
||||
/// <param name="ppvHandle">The <see cref="GCHandle"/> value for the managed wrapper associated with this CCW.</param>
|
||||
/// <returns>An <see cref="HRESULT"/> for the operation.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public HRESULT GetManagedWrapperHandle(void** ppvHandle)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1TransformMapperInternal*, void**, int>)this.lpVtbl[3])(
|
||||
(ID2D1TransformMapperInternal*)Unsafe.AsPointer(ref this),
|
||||
ppvHandle);
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする