From 06bf8a589bcb8a9ae97979d42d226dc049bf94b7 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 19 Apr 2022 00:02:48 +0200 Subject: [PATCH] Minor code tweaks to D2D1 blob types --- .../Interop/D2D1EffectRegistrationData.cs | 41 +++++++++++-------- .../Interop/D2D1InteropServices.Effects.cs | 2 +- .../Shaders/Interop/D2D1PropertyBinding.cs | 22 +++++----- 3 files changed, 37 insertions(+), 28 deletions(-) diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1EffectRegistrationData.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1EffectRegistrationData.cs index e6187915..a68a3073 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1EffectRegistrationData.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1EffectRegistrationData.cs @@ -11,26 +11,35 @@ namespace ComputeSharp.D2D1.Interop; /// A helper type used to read and validate effect registration blobs produced by /// . /// +/// +/// +/// The values in a instance contain all necessary +/// information to register a new D2D1 effect by calling ID2D1Factory1::RegisterEffectFromString. +/// +/// +/// For more info, see . +/// +/// public unsafe readonly struct D2D1EffectRegistrationData { /// /// Creates a new instance with the specified parameters. /// - /// The effect id. + /// The effect class id. /// The number of inputs for the effect. - /// The XML text that can be used to register the effect. + /// The XML text that can be used to register the effect. /// The values for the effect. /// A pointer to the effect factory callback. 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 /// /// Gets the id to use to register the effect. /// - public Guid EffectId { get; } + public Guid ClassId { get; } /// /// Gets the number of inputs for the effect. @@ -48,7 +57,7 @@ public unsafe readonly struct D2D1EffectRegistrationData /// /// Gets the XML text with the effect description, that can be used to register it. /// - public string Xml { get; } + public string PropertyXml { get; } /// /// Gets the sequence of values for the effect. @@ -56,7 +65,7 @@ public unsafe readonly struct D2D1EffectRegistrationData public ReadOnlyMemory PropertyBindings { get; } /// - /// Gets a callback to an effect factory (a ). + /// Gets a callback to an effect factory (a ). /// public void* EffectFactory { get; } @@ -81,7 +90,7 @@ public unsafe readonly struct D2D1EffectRegistrationData ReadOnlySpan 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 diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1InteropServices.Effects.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1InteropServices.Effects.cs index 2ec05819..c60500ad 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1InteropServices.Effects.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1InteropServices.Effects.cs @@ -172,7 +172,7 @@ unsafe partial class D2D1InteropServices /// The property name (as null-terminated UTF8 text). /// The property getter (a ). /// The property setter (a ). - /// The effect factory (a ). + /// The effect factory (a ). /// /// The property name, getter and setter are grouped together after the number of bindings. /// diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PropertyBinding.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PropertyBinding.cs index 47334338..0b78e89f 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PropertyBinding.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PropertyBinding.cs @@ -9,27 +9,27 @@ public unsafe readonly struct D2D1PropertyBinding /// Creates a new instance with the specified parameters. /// /// The property name. - /// A pointer to the property getter callback - /// A pointer to the property setter callback - internal D2D1PropertyBinding(string name, void* getter, void* setter) + /// A pointer to the property get function callback + /// A pointer to the property set function callback + internal D2D1PropertyBinding(string name, void* getFunction, void* setFunction) { - Name = name; - Getter = getter; - Setter = setter; + PropertyName = name; + GetFunction = getFunction; + SetFunction = setFunction; } /// /// Gets the name of the property. /// - public string Name { get; } + public string PropertyName { get; } /// - /// Gets the property getter (a ). + /// Gets the property get function (a ). /// - public void* Getter { get; } + public void* GetFunction { get; } /// - /// Gets the property setter (a ). + /// Gets the property set function (a ). /// - public void* Setter { get; } + public void* SetFunction { get; } } \ No newline at end of file