mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
UI - Large amount of memory improvements in the VMs
Core - Minor memory improvements
This commit is contained in:
1 parent
63cb6d211e
commit
24afb6b0f5
26 files changed
+243
-191
No files matched your search
@@ -80,7 +80,7 @@ namespace Artemis.Core.Models.Profile
|
||||
{
|
||||
if (!Enabled || Path == null || !Children.Any(c => c.Enabled))
|
||||
return;
|
||||
|
||||
|
||||
if (_folderBitmap == null)
|
||||
_folderBitmap = new SKBitmap(new SKImageInfo((int) Path.Bounds.Width, (int) Path.Bounds.Height));
|
||||
else if (_folderBitmap.Info.Width != (int) Path.Bounds.Width || _folderBitmap.Info.Height != (int) Path.Bounds.Height)
|
||||
@@ -89,11 +89,11 @@ namespace Artemis.Core.Models.Profile
|
||||
_folderBitmap = new SKBitmap(new SKImageInfo((int) Path.Bounds.Width, (int) Path.Bounds.Height));
|
||||
}
|
||||
|
||||
using var folderPath = new SKPath(Path);
|
||||
using var folderCanvas = new SKCanvas(_folderBitmap);
|
||||
using var folderPaint = new SKPaint();
|
||||
folderCanvas.Clear();
|
||||
|
||||
var folderPath = new SKPath(Path);
|
||||
folderPath.Transform(SKMatrix.MakeTranslation(folderPath.Bounds.Left * -1, folderPath.Bounds.Top * -1));
|
||||
|
||||
foreach (var baseLayerEffect in LayerEffects.Where(e => e.Enabled))
|
||||
@@ -112,7 +112,7 @@ namespace Artemis.Core.Models.Profile
|
||||
|
||||
canvas.Save();
|
||||
|
||||
var clipPath = new SKPath(folderPath);
|
||||
using var clipPath = new SKPath(folderPath);
|
||||
clipPath.Transform(SKMatrix.MakeTranslation(targetLocation.X, targetLocation.Y));
|
||||
canvas.ClipPath(clipPath);
|
||||
|
||||
|
||||
@@ -246,6 +246,7 @@ namespace Artemis.Core.Models.Profile
|
||||
_layerBitmap = new SKBitmap(new SKImageInfo((int)Path.Bounds.Width, (int)Path.Bounds.Height));
|
||||
}
|
||||
|
||||
using var layerPath = new SKPath(Path);
|
||||
using var layerCanvas = new SKCanvas(_layerBitmap);
|
||||
using var layerPaint = new SKPaint
|
||||
{
|
||||
@@ -254,8 +255,7 @@ namespace Artemis.Core.Models.Profile
|
||||
Color = new SKColor(0, 0, 0, (byte) (Transform.Opacity.CurrentValue * 2.55f))
|
||||
};
|
||||
layerCanvas.Clear();
|
||||
|
||||
var layerPath = new SKPath(Path);
|
||||
|
||||
layerPath.Transform(SKMatrix.MakeTranslation(layerPath.Bounds.Left * -1, layerPath.Bounds.Top * -1));
|
||||
|
||||
foreach (var baseLayerEffect in LayerEffects.Where(e => e.Enabled))
|
||||
@@ -278,11 +278,13 @@ namespace Artemis.Core.Models.Profile
|
||||
targetLocation = Path.Bounds.Location - parentFolder.Path.Bounds.Location;
|
||||
|
||||
canvas.DrawBitmap(_layerBitmap, targetLocation, layerPaint);
|
||||
|
||||
}
|
||||
|
||||
private void SimpleRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPaint paint, SKPath layerPath)
|
||||
{
|
||||
LayerBrush.InternalRender(canvas, canvasInfo, new SKPath(LayerShape.Path), paint);
|
||||
using var renderPath = new SKPath(LayerShape.Path);
|
||||
LayerBrush.InternalRender(canvas, canvasInfo, renderPath, paint);
|
||||
}
|
||||
|
||||
private void StretchRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPaint paint, SKPath layerPath)
|
||||
@@ -302,8 +304,9 @@ namespace Artemis.Core.Models.Profile
|
||||
canvas.RotateDegrees(rotationProperty, anchorPosition.X, anchorPosition.Y);
|
||||
canvas.Scale(sizeProperty.Width / 100f, sizeProperty.Height / 100f, anchorPosition.X, anchorPosition.Y);
|
||||
canvas.Translate(x, y);
|
||||
|
||||
LayerBrush.InternalRender(canvas, canvasInfo, new SKPath(LayerShape.Path), paint);
|
||||
|
||||
using var renderPath = new SKPath(LayerShape.Path);
|
||||
LayerBrush.InternalRender(canvas, canvasInfo, renderPath, paint);
|
||||
}
|
||||
|
||||
private void ClipRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPaint paint, SKPath layerPath)
|
||||
@@ -319,7 +322,7 @@ namespace Artemis.Core.Models.Profile
|
||||
var x = anchorPosition.X - layerPath.Bounds.MidX - anchorProperty.X * layerPath.Bounds.Width;
|
||||
var y = anchorPosition.Y - layerPath.Bounds.MidY - anchorProperty.Y * layerPath.Bounds.Height;
|
||||
|
||||
var clipPath = new SKPath(LayerShape.Path);
|
||||
using var clipPath = new SKPath(LayerShape.Path);
|
||||
clipPath.Transform(SKMatrix.MakeTranslation(x, y));
|
||||
clipPath.Transform(SKMatrix.MakeScale(sizeProperty.Width / 100f, sizeProperty.Height / 100f, anchorPosition.X, anchorPosition.Y));
|
||||
clipPath.Transform(SKMatrix.MakeRotationDegrees(rotationProperty, anchorPosition.X, anchorPosition.Y));
|
||||
@@ -336,7 +339,7 @@ namespace Artemis.Core.Models.Profile
|
||||
Math.Max(clipPath.Bounds.Right - x, Bounds.Right - x),
|
||||
Math.Max(clipPath.Bounds.Bottom - y, Bounds.Bottom - y)
|
||||
);
|
||||
var renderPath = new SKPath();
|
||||
using var renderPath = new SKPath();
|
||||
renderPath.AddRect(boundsRect);
|
||||
|
||||
LayerBrush.InternalRender(canvas, canvasInfo, renderPath, paint);
|
||||
|
||||
@@ -4,8 +4,6 @@ namespace Artemis.Core.Models.Profile.LayerShapes
|
||||
{
|
||||
public abstract class LayerShape
|
||||
{
|
||||
private SKPath _path;
|
||||
|
||||
protected LayerShape(Layer layer)
|
||||
{
|
||||
Layer = layer;
|
||||
@@ -17,13 +15,9 @@ namespace Artemis.Core.Models.Profile.LayerShapes
|
||||
public Layer Layer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a copy of the path outlining the shape
|
||||
/// Gets a the path outlining the shape
|
||||
/// </summary>
|
||||
public SKPath Path
|
||||
{
|
||||
get => _path != null ? new SKPath(_path) : null;
|
||||
protected set => _path = value;
|
||||
}
|
||||
public SKPath Path { get; protected set; }
|
||||
|
||||
public abstract void CalculateRenderProperties();
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@ namespace Artemis.Core.Models.Profile
|
||||
private SKPath _path;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a copy of the path containing all the LEDs this entity is applied to, any rendering outside the entity Path is
|
||||
/// Gets the path containing all the LEDs this entity is applied to, any rendering outside the entity Path is
|
||||
/// clipped.
|
||||
/// </summary>
|
||||
public SKPath Path
|
||||
{
|
||||
get => _path != null ? new SKPath(_path) : null;
|
||||
get => _path;
|
||||
protected set
|
||||
{
|
||||
_path = value;
|
||||
|
||||
Reference in new issue
Block a user