diff --git a/RGB.NET.Core/MVVM/AbstractBindable.cs b/RGB.NET.Core/MVVM/AbstractBindable.cs
index b12f302..26ac0b5 100644
--- a/RGB.NET.Core/MVVM/AbstractBindable.cs
+++ b/RGB.NET.Core/MVVM/AbstractBindable.cs
@@ -27,9 +27,9 @@ public abstract class AbstractBindable : IBindable
/// Type of the property.
/// Reference to the backing-filed.
/// Value to apply.
- /// true if the value needs to be updated; otherweise false.
+ /// true if the value needs to be updated; otherwise false.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- protected virtual bool RequiresUpdate(ref T storage, T value) => !EqualityComparer.Default.Equals(storage, value);
+ protected bool RequiresUpdate(ref T storage, T value) => !EqualityComparer.Default.Equals(storage, value);
///
/// Checks if the property already matches the desired value and updates it if not.
@@ -40,7 +40,7 @@ public abstract class AbstractBindable : IBindable
/// Name of the property used to notify listeners. This value is optional
/// and can be provided automatically when invoked from compilers that support .
/// true if the value was changed, false if the existing value matched the desired value.
- protected virtual bool SetProperty(ref T storage, T value, [CallerMemberName] string? propertyName = null)
+ protected bool SetProperty(ref T storage, T value, [CallerMemberName] string? propertyName = null)
{
if (!RequiresUpdate(ref storage, value)) return false;
@@ -55,7 +55,7 @@ public abstract class AbstractBindable : IBindable
///
/// Name of the property used to notify listeners. This value is optional
/// and can be provided automatically when invoked from compilers that support .
- protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
+ protected void OnPropertyChanged([CallerMemberName] string? propertyName = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
#endregion
diff --git a/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs b/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs
index 553e53b..bc39b5d 100644
--- a/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs
+++ b/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs
@@ -74,9 +74,13 @@ public abstract class AbstractBrush : AbstractDecoratable, IBru
if (Decorators.Count == 0) return;
lock (Decorators)
- foreach (IBrushDecorator decorator in Decorators)
+ // ReSharper disable once ForCanBeConvertedToForeach - Sadly this does not get optimized reliably and causes allocations if foreached
+ for (int i = 0; i < Decorators.Count; i++)
+ {
+ IBrushDecorator decorator = Decorators[i];
if (decorator.IsEnabled)
decorator.ManipulateColor(rectangle, renderTarget, ref color);
+ }
}
///
diff --git a/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs b/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs
index 158705c..02f8e2d 100644
--- a/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs
+++ b/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs
@@ -32,6 +32,8 @@ public sealed class SolidColorBrush : AbstractBrush
public SolidColorBrush(Color color)
{
this.Color = color;
+
+ CalculationMode = RenderMode.Absolute;
}
#endregion
diff --git a/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs b/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs
index a9a7b86..9ba2cb0 100644
--- a/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs
+++ b/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs
@@ -1,6 +1,5 @@
using System;
using System.Numerics;
-using System.Runtime.InteropServices;
namespace RGB.NET.Core;
@@ -41,7 +40,7 @@ public sealed class AverageColorSampler : ISampler
{
ReadOnlySpan data = info[y];
- fixed (Color* colorPtr = &MemoryMarshal.GetReference(data))
+ fixed (Color* colorPtr = data)
{
Color* current = colorPtr;
for (int i = 0; i < chunks; i++)
diff --git a/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs b/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs
index 00abcc7..a45ae6c 100644
--- a/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs
+++ b/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs
@@ -133,7 +133,7 @@ public class DeviceUpdateTrigger : AbstractUpdateTrigger, IDeviceUpdateTrigger
///
/// Stops the trigger.
///
- public async void Stop()
+ public virtual async void Stop()
{
if (!IsRunning) return;
@@ -141,7 +141,9 @@ public class DeviceUpdateTrigger : AbstractUpdateTrigger, IDeviceUpdateTrigger
UpdateTokenSource?.Cancel();
if (UpdateTask != null)
- await UpdateTask;
+ try { await UpdateTask.ConfigureAwait(false); }
+ catch (TaskCanceledException) { }
+ catch (OperationCanceledException) { }
UpdateTask?.Dispose();
UpdateTask = null;
diff --git a/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs b/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs
index 1cfbdf8..bf5d7c6 100644
--- a/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs
+++ b/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs
@@ -1,6 +1,5 @@
using System;
using System.Numerics;
-using System.Runtime.InteropServices;
using RGB.NET.Core;
namespace RGB.NET.Presets.Textures.Sampler;
@@ -42,7 +41,7 @@ public sealed class AverageByteSampler : ISampler
{
ReadOnlySpan data = info[y];
- fixed (byte* colorPtr = &MemoryMarshal.GetReference(data))
+ fixed (byte* colorPtr = data)
{
byte* current = colorPtr;
for (int i = 0; i < chunks; i++)
diff --git a/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs b/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs
index dfa3f17..cea8f45 100644
--- a/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs
+++ b/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs
@@ -1,6 +1,5 @@
using System;
using System.Numerics;
-using System.Runtime.InteropServices;
using RGB.NET.Core;
namespace RGB.NET.Presets.Textures.Sampler;
@@ -33,7 +32,7 @@ public sealed class AverageFloatSampler : ISampler
{
ReadOnlySpan data = info[y];
- fixed (float* colorPtr = &MemoryMarshal.GetReference(data))
+ fixed (float* colorPtr = data)
{
float* current = colorPtr;
for (int i = 0; i < chunks; i++)