Minor code tweaks to D2D1 blob types
このコミットが含まれているのは:
1 親
a419d98678
コミット
06bf8a589b
3ファイル変更
+37
-28
検索条件に一致するファイルはありません
@@ -11,26 +11,35 @@ namespace ComputeSharp.D2D1.Interop;
|
||||
/// A helper type used to read and validate effect registration blobs produced by
|
||||
/// <see cref="D2D1InteropServices.GetPixelShaderEffectRegistrationBlob{T}(out Guid)"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The values in a <see cref="D2D1EffectRegistrationData"/> instance contain all necessary
|
||||
/// information to register a new D2D1 effect by calling <c>ID2D1Factory1::RegisterEffectFromString</c>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1_1/nf-d2d1_1-id2d1factory1-registereffectfromstring"/>.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public unsafe readonly struct D2D1EffectRegistrationData
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="D2D1EffectRegistrationData"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="effectId">The effect id.</param>
|
||||
/// <param name="classId">The effect class id.</param>
|
||||
/// <param name="numberOfInputs">The number of inputs for the effect.</param>
|
||||
/// <param name="xml">The XML text that can be used to register the effect.</param>
|
||||
/// <param name="propertyXml">The XML text that can be used to register the effect.</param>
|
||||
/// <param name="propertyBindings">The <see cref="D2D1PropertyBinding"/> values for the effect.</param>
|
||||
/// <param name="effectFactory">A pointer to the effect factory callback.</param>
|
||||
private D2D1EffectRegistrationData(
|
||||
Guid effectId,
|
||||
Guid classId,
|
||||
int numberOfInputs,
|
||||
string xml,
|
||||
string propertyXml,
|
||||
D2D1PropertyBinding[] propertyBindings,
|
||||
nint effectFactory)
|
||||
{
|
||||
EffectId = effectId;
|
||||
ClassId = classId;
|
||||
NumberOfInputs = numberOfInputs;
|
||||
Xml = xml;
|
||||
PropertyXml = propertyXml;
|
||||
PropertyBindings = propertyBindings;
|
||||
EffectFactory = (void*)effectFactory;
|
||||
}
|
||||
@@ -38,7 +47,7 @@ public unsafe readonly struct D2D1EffectRegistrationData
|
||||
/// <summary>
|
||||
/// Gets the id to use to register the effect.
|
||||
/// </summary>
|
||||
public Guid EffectId { get; }
|
||||
public Guid ClassId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of inputs for the effect.
|
||||
@@ -48,7 +57,7 @@ public unsafe readonly struct D2D1EffectRegistrationData
|
||||
/// <summary>
|
||||
/// Gets the XML text with the effect description, that can be used to register it.
|
||||
/// </summary>
|
||||
public string Xml { get; }
|
||||
public string PropertyXml { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sequence of <see cref="D2D1PropertyBinding"/> values for the effect.
|
||||
@@ -56,7 +65,7 @@ public unsafe readonly struct D2D1EffectRegistrationData
|
||||
public ReadOnlyMemory<D2D1PropertyBinding> PropertyBindings { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a callback to an effect factory (a <see langword="delegate* unmanaged[Stdcall]<IUnknown**, byte*, uint, HRESULT>"/>).
|
||||
/// Gets a callback to an effect factory (a <see langword="delegate* unmanaged[Stdcall]<IUnknown**, HRESULT>"/>).
|
||||
/// </summary>
|
||||
public void* EffectFactory { get; }
|
||||
|
||||
@@ -81,7 +90,7 @@ public unsafe readonly struct D2D1EffectRegistrationData
|
||||
|
||||
ReadOnlySpan<byte> span = blob.Span;
|
||||
|
||||
// Effect id
|
||||
// Effect class id
|
||||
if (!MemoryMarshal.TryRead(span, out Guid effectId))
|
||||
{
|
||||
return false;
|
||||
@@ -98,7 +107,7 @@ public unsafe readonly struct D2D1EffectRegistrationData
|
||||
|
||||
span = span.Slice(sizeof(int));
|
||||
|
||||
// Effect XML
|
||||
// Effect property XML
|
||||
int lengthOfXml = span.IndexOf((byte)'\0');
|
||||
|
||||
if (lengthOfXml == -1)
|
||||
@@ -136,23 +145,23 @@ public unsafe readonly struct D2D1EffectRegistrationData
|
||||
|
||||
span = span.Slice(lengthOfName + 1);
|
||||
|
||||
// Property getter
|
||||
if (!MemoryMarshal.TryRead(span, out nint getter))
|
||||
// Property get function
|
||||
if (!MemoryMarshal.TryRead(span, out nint getFunction))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
span = span.Slice(sizeof(nint));
|
||||
|
||||
// Property setter
|
||||
if (!MemoryMarshal.TryRead(span, out nint setter))
|
||||
// Property set function
|
||||
if (!MemoryMarshal.TryRead(span, out nint setFunction))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
span = span.Slice(sizeof(nint));
|
||||
|
||||
propertyBindings[i] = new D2D1PropertyBinding(name, (void*)getter, (void*)setter);
|
||||
propertyBindings[i] = new D2D1PropertyBinding(name, (void*)getFunction, (void*)setFunction);
|
||||
}
|
||||
|
||||
// Effect factory
|
||||
|
||||
@@ -172,7 +172,7 @@ unsafe partial class D2D1InteropServices
|
||||
/// <item>The property name (as null-terminated UTF8 text).</item>
|
||||
/// <item>The property getter (a <see langword="delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, uint*, HRESULT>"/>).</item>
|
||||
/// <item>The property setter (a <see langword="delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, HRESULT>"/>).</item>
|
||||
/// <item>The effect factory (a <see langword="delegate* unmanaged[Stdcall]<IUnknown**, byte*, uint, HRESULT>"/>).</item>
|
||||
/// <item>The effect factory (a <see langword="delegate* unmanaged[Stdcall]<IUnknown**, HRESULT>"/>).</item>
|
||||
/// </list>
|
||||
/// The property name, getter and setter are grouped together after the number of bindings.
|
||||
/// </para>
|
||||
|
||||
@@ -9,27 +9,27 @@ public unsafe readonly struct D2D1PropertyBinding
|
||||
/// Creates a new <see cref="D2D1PropertyBinding"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="name">The property name.</param>
|
||||
/// <param name="getter">A pointer to the property getter callback</param>
|
||||
/// <param name="setter">A pointer to the property setter callback</param>
|
||||
internal D2D1PropertyBinding(string name, void* getter, void* setter)
|
||||
/// <param name="getFunction">A pointer to the property get function callback</param>
|
||||
/// <param name="setFunction">A pointer to the property set function callback</param>
|
||||
internal D2D1PropertyBinding(string name, void* getFunction, void* setFunction)
|
||||
{
|
||||
Name = name;
|
||||
Getter = getter;
|
||||
Setter = setter;
|
||||
PropertyName = name;
|
||||
GetFunction = getFunction;
|
||||
SetFunction = setFunction;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the property.
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
public string PropertyName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the property getter (a <see langword="delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, uint*, HRESULT>"/>).
|
||||
/// Gets the property get function (a <see langword="delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, uint*, HRESULT>"/>).
|
||||
/// </summary>
|
||||
public void* Getter { get; }
|
||||
public void* GetFunction { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the property setter (a <see langword="delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, HRESULT>"/>).
|
||||
/// Gets the property set function (a <see langword="delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, HRESULT>"/>).
|
||||
/// </summary>
|
||||
public void* Setter { get; }
|
||||
public void* SetFunction { get; }
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする