From b857fb2c81c6784835b331cb5cafea4fe74cba6c Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Tue, 23 Feb 2021 23:01:04 +0100 Subject: [PATCH] Changed Data-Spans in texture to be readonly --- RGB.NET.Core/Rendering/Textures/PixelTexture.cs | 4 ++-- RGB.NET.Presets/Textures/BytePixelTexture.cs | 4 ++-- RGB.NET.Presets/Textures/FloatPixelTexture.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs index 7193e52..f6525cf 100644 --- a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs +++ b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs @@ -119,10 +119,10 @@ namespace RGB.NET.Core protected override void GetRegionData(int x, int y, int width, int height, in Span buffer) { - Span data = Data.AsSpan(); + ReadOnlySpan data = Data.AsSpan(); for (int i = 0; i < height; i++) { - Span dataSlice = data.Slice(((y + i) * _stride) + x, width); + ReadOnlySpan dataSlice = data.Slice(((y + i) * _stride) + x, width); Span destination = buffer.Slice(i * width, width); dataSlice.CopyTo(destination); } diff --git a/RGB.NET.Presets/Textures/BytePixelTexture.cs b/RGB.NET.Presets/Textures/BytePixelTexture.cs index d83398a..c1ed31c 100644 --- a/RGB.NET.Presets/Textures/BytePixelTexture.cs +++ b/RGB.NET.Presets/Textures/BytePixelTexture.cs @@ -58,10 +58,10 @@ namespace RGB.NET.Presets.Textures protected override void GetRegionData(int x, int y, int width, int height, in Span buffer) { int width3 = width * 3; - Span data = Data.AsSpan(); + ReadOnlySpan data = Data.AsSpan(); for (int i = 0; i < height; i++) { - Span dataSlice = data.Slice((((y + i) * _stride) + x) * 3, width3); + ReadOnlySpan dataSlice = data.Slice((((y + i) * _stride) + x) * 3, width3); Span destination = buffer.Slice(i * width3, width3); dataSlice.CopyTo(destination); } diff --git a/RGB.NET.Presets/Textures/FloatPixelTexture.cs b/RGB.NET.Presets/Textures/FloatPixelTexture.cs index 410f9c9..aa8bd77 100644 --- a/RGB.NET.Presets/Textures/FloatPixelTexture.cs +++ b/RGB.NET.Presets/Textures/FloatPixelTexture.cs @@ -58,10 +58,10 @@ namespace RGB.NET.Presets.Textures protected override void GetRegionData(int x, int y, int width, int height, in Span buffer) { int width3 = width * 3; - Span data = Data.AsSpan(); + ReadOnlySpan data = Data.AsSpan(); for (int i = 0; i < height; i++) { - Span dataSlice = data.Slice((((y + i) * _stride) + x) * 3, width3); + ReadOnlySpan dataSlice = data.Slice((((y + i) * _stride) + x) * 3, width3); Span destination = buffer.Slice(i * width3, width3); dataSlice.CopyTo(destination); }