diff --git a/src/Artemis.Core/RGB.NET/BitmapBrush.cs b/src/Artemis.Core/RGB.NET/BitmapBrush.cs index 7f8f3945f..720533da0 100644 --- a/src/Artemis.Core/RGB.NET/BitmapBrush.cs +++ b/src/Artemis.Core/RGB.NET/BitmapBrush.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Runtime.CompilerServices; using Artemis.Core.Extensions; using RGB.NET.Core; @@ -55,13 +54,6 @@ namespace Artemis.Core.RGB.NET if (RenderedRectangle != rectangle || RenderedScale != Scale) Bitmap = null; - if (renderTargets.Any()) - { - var test = RGBSurface.Instance.SurfaceRectangle; - var width = renderTargets.Max(l => l.Led.AbsoluteLedRectangle.Location.X + l.Led.AbsoluteLedRectangle.Size.Width); - var height = renderTargets.Max(l => l.Led.AbsoluteLedRectangle.Location.Y + l.Led.AbsoluteLedRectangle.Size.Height); - } - RenderedRectangle = rectangle; RenderedScale = Scale; RenderedTargets.Clear(); @@ -71,11 +63,10 @@ namespace Artemis.Core.RGB.NET foreach (var renderTarget in renderTargets) { + // TODO: Right now the sample size is 1, make this configurable to something higher and average the samples out var scaledLocation = renderTarget.Point * Scale; if (scaledLocation.X < Bitmap.Width && scaledLocation.Y < Bitmap.Height) - { RenderedTargets[renderTarget] = Bitmap.GetPixel(RoundToInt(scaledLocation.X), RoundToInt(scaledLocation.Y)).ToRgbColor(); - } } } @@ -83,6 +74,7 @@ namespace Artemis.Core.RGB.NET private void CreateBitmap(Rectangle rectangle) { + // TODO: Test this max size, it applied to System.Drawing.Bitmap but SKBitmap might scale better or worse var width = Math.Min((rectangle.Location.X + rectangle.Size.Width) * Scale.Horizontal, 4096); var height = Math.Min((rectangle.Location.Y + rectangle.Size.Height) * Scale.Vertical, 4096); Bitmap = new SKBitmap(new SKImageInfo(width.RoundToInt(), height.RoundToInt())); diff --git a/src/Artemis.Plugins.LayerElements.Noise/OpenSimplexNoise.cs b/src/Artemis.Plugins.LayerElements.Noise/OpenSimplexNoise.cs index ddbeb5e9f..0bcbdfad7 100644 --- a/src/Artemis.Plugins.LayerElements.Noise/OpenSimplexNoise.cs +++ b/src/Artemis.Plugins.LayerElements.Noise/OpenSimplexNoise.cs @@ -268,6 +268,7 @@ namespace Artemis.Plugins.LayerElements.Noise return value * NORM_2D; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public double Evaluate(double x, double y, double z) { var stretchOffset = (x + y + z) * STRETCH_3D; diff --git a/src/Artemis.UI/Screens/Settings/Debug/DebugViewModel.cs b/src/Artemis.UI/Screens/Settings/Debug/DebugViewModel.cs index 7063d8888..41ae2b6d7 100644 --- a/src/Artemis.UI/Screens/Settings/Debug/DebugViewModel.cs +++ b/src/Artemis.UI/Screens/Settings/Debug/DebugViewModel.cs @@ -49,17 +49,24 @@ namespace Artemis.UI.Screens.Settings.Debug return; } - using (var skiaImage = SKImage.FromPixels(e.BitmapBrush.Bitmap.PeekPixels())) + try { - var info = new SKImageInfo(skiaImage.Width, skiaImage.Height); - writeableBitmap.Lock(); - using (var pixmap = new SKPixmap(info, writeableBitmap.BackBuffer, writeableBitmap.BackBufferStride)) + using (var skiaImage = SKImage.FromPixels(e.BitmapBrush.Bitmap.PeekPixels())) { - skiaImage.ReadPixels(pixmap, 0, 0); - } + var info = new SKImageInfo(skiaImage.Width, skiaImage.Height); + writeableBitmap.Lock(); + using (var pixmap = new SKPixmap(info, writeableBitmap.BackBuffer, writeableBitmap.BackBufferStride)) + { + skiaImage.ReadPixels(pixmap, 0, 0); + } - writeableBitmap.AddDirtyRect(new Int32Rect(0, 0, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight)); - writeableBitmap.Unlock(); + writeableBitmap.AddDirtyRect(new Int32Rect(0, 0, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight)); + writeableBitmap.Unlock(); + } + } + catch (AccessViolationException) + { + // oops } }); }