From a419d98678fbee850f9d975bf500875c80bd2790 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 18 Apr 2022 02:08:50 +0200 Subject: [PATCH] Move PropertyBinding out from being nested, add D2D1 prefix --- .../Interop/D2D1EffectRegistrationData.cs | 46 +++---------------- .../Shaders/Interop/D2D1PropertyBinding.cs | 35 ++++++++++++++ 2 files changed, 41 insertions(+), 40 deletions(-) create mode 100644 src/ComputeSharp.D2D1/Shaders/Interop/D2D1PropertyBinding.cs diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1EffectRegistrationData.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1EffectRegistrationData.cs index ceebb020..e6187915 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1EffectRegistrationData.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1EffectRegistrationData.cs @@ -19,13 +19,13 @@ public unsafe readonly struct D2D1EffectRegistrationData /// The effect id. /// The number of inputs for the effect. /// The XML text that can be used to register the effect. - /// The values for the effect. + /// The values for the effect. /// A pointer to the effect factory callback. private D2D1EffectRegistrationData( Guid effectId, int numberOfInputs, string xml, - PropertyBinding[] propertyBindings, + D2D1PropertyBinding[] propertyBindings, nint effectFactory) { EffectId = effectId; @@ -51,9 +51,9 @@ public unsafe readonly struct D2D1EffectRegistrationData public string Xml { get; } /// - /// Gets the sequence of values for the effect. + /// Gets the sequence of values for the effect. /// - public ReadOnlyMemory PropertyBindings { get; } + public ReadOnlyMemory PropertyBindings { get; } /// /// Gets a callback to an effect factory (a ). @@ -119,7 +119,7 @@ public unsafe readonly struct D2D1EffectRegistrationData span = span.Slice(sizeof(int)); - PropertyBinding[] propertyBindings = new PropertyBinding[numberOfBindings]; + D2D1PropertyBinding[] propertyBindings = new D2D1PropertyBinding[numberOfBindings]; // Property bindings for (int i = 0; i < numberOfBindings; i++) @@ -152,7 +152,7 @@ public unsafe readonly struct D2D1EffectRegistrationData span = span.Slice(sizeof(nint)); - propertyBindings[i] = new PropertyBinding(name, getter, setter); + propertyBindings[i] = new D2D1PropertyBinding(name, (void*)getter, (void*)setter); } // Effect factory @@ -178,38 +178,4 @@ public unsafe readonly struct D2D1EffectRegistrationData return true; } - - /// - /// A model representing a property binding for an effect. - /// - public readonly struct PropertyBinding - { - /// - /// 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 PropertyBinding(string name, nint getter, nint setter) - { - Name = name; - Getter = (void*)getter; - Setter = (void*)setter; - } - - /// - /// Gets the name of the property. - /// - public string Name { get; } - - /// - /// Gets the property getter (a ). - /// - public void* Getter { get; } - - /// - /// Gets the property setter (a ). - /// - public void* Setter { get; } - } } diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PropertyBinding.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PropertyBinding.cs new file mode 100644 index 00000000..47334338 --- /dev/null +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PropertyBinding.cs @@ -0,0 +1,35 @@ +namespace ComputeSharp.D2D1.Interop; + +/// +/// A model representing a property binding for an effect. +/// +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) + { + Name = name; + Getter = getter; + Setter = setter; + } + + /// + /// Gets the name of the property. + /// + public string Name { get; } + + /// + /// Gets the property getter (a ). + /// + public void* Getter { get; } + + /// + /// Gets the property setter (a ). + /// + public void* Setter { get; } +} \ No newline at end of file