Merge remote-tracking branch 'origin/development' into development

This commit is contained in:
Robert committed 2021-03-26 00:18:16 +01:00
commit cf25d9f146
15 files changed
+154 -72

No files matched your search

+6 -5
View File
@@ -4,7 +4,6 @@ using System.Linq;
using Artemis.Core.LayerEffects;
using Artemis.Storage.Entities.Profile;
using Artemis.Storage.Entities.Profile.Abstract;
using Newtonsoft.Json;
using SkiaSharp;
namespace Artemis.Core
@@ -153,8 +152,10 @@ namespace Artemis.Core
SKPath path = new() {FillType = SKPathFillType.Winding};
foreach (ProfileElement child in Children)
{
if (child is RenderProfileElement effectChild && effectChild.Path != null)
path.AddPath(effectChild.Path);
}
Path = path;
@@ -168,7 +169,7 @@ namespace Artemis.Core
#region Rendering
/// <inheritdoc />
public override void Render(SKCanvas canvas, SKPoint basePosition)
public override void Render(SKCanvas canvas, SKPointI basePosition)
{
if (Disposed)
throw new ObjectDisposedException("Folder");
@@ -192,12 +193,12 @@ namespace Artemis.Core
SKPaint layerPaint = new();
try
{
SKRect rendererBounds = SKRect.Create(0, 0, Path.Bounds.Width, Path.Bounds.Height);
SKRectI rendererBounds = SKRectI.Create(0, 0, Bounds.Width, Bounds.Height);
foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => e.Enabled))
baseLayerEffect.PreProcess(canvas, rendererBounds, layerPaint);
canvas.SaveLayer(layerPaint);
canvas.Translate(Path.Bounds.Left - basePosition.X, Path.Bounds.Top - basePosition.Y);
canvas.Translate(Bounds.Left - basePosition.X, Bounds.Top - basePosition.Y);
// If required, apply the opacity override of the module to the root folder
if (IsRootFolder && Profile.Module.OpacityOverride < 1)
@@ -212,7 +213,7 @@ namespace Artemis.Core
// Iterate the children in reverse because the first layer must be rendered last to end up on top
for (int index = Children.Count - 1; index > -1; index--)
Children[index].Render(canvas, new SKPoint(Path.Bounds.Left, Path.Bounds.Top));
Children[index].Render(canvas, new SKPointI(Bounds.Left, Bounds.Top));
foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => e.Enabled))
baseLayerEffect.PostProcess(canvas, rendererBounds, layerPaint);
+12 -13
View File
@@ -277,7 +277,7 @@ namespace Artemis.Core
}
/// <inheritdoc />
public override void Render(SKCanvas canvas, SKPoint basePosition)
public override void Render(SKCanvas canvas, SKPointI basePosition)
{
if (Disposed)
throw new ObjectDisposedException("Layer");
@@ -312,7 +312,7 @@ namespace Artemis.Core
}
}
private void RenderTimeline(Timeline timeline, SKCanvas canvas, SKPoint basePosition)
private void RenderTimeline(Timeline timeline, SKCanvas canvas, SKPointI basePosition)
{
if (Path == null || LayerBrush == null)
throw new ArtemisCoreException("The layer is not yet ready for rendering");
@@ -329,12 +329,11 @@ namespace Artemis.Core
try
{
canvas.Save();
canvas.Translate(Path.Bounds.Left - basePosition.X, Path.Bounds.Top - basePosition.Y);
canvas.Translate(Bounds.Left - basePosition.X, Bounds.Top - basePosition.Y);
using SKPath clipPath = new(Path);
clipPath.Transform(SKMatrix.CreateTranslation(Path.Bounds.Left * -1, Path.Bounds.Top * -1));
canvas.ClipPath(clipPath);
SKRect layerBounds = SKRect.Create(0, 0, Path.Bounds.Width, Path.Bounds.Height);
clipPath.Transform(SKMatrix.CreateTranslation(Bounds.Left * -1, Bounds.Top * -1));
canvas.ClipPath(clipPath, SKClipOperation.Intersect, true);
SKRectI layerBounds = SKRectI.Create(0, 0, Bounds.Width, Bounds.Height);
// Apply blend mode and color
layerPaint.BlendMode = General.BlendMode.CurrentValue;
@@ -435,7 +434,7 @@ namespace Artemis.Core
OnRenderPropertiesUpdated();
}
internal SKPoint GetLayerAnchorPosition(SKPath layerPath, bool applyTranslation, bool zeroBased)
internal SKPoint GetLayerAnchorPosition(bool applyTranslation, bool zeroBased)
{
if (Disposed)
throw new ObjectDisposedException("Layer");
@@ -444,14 +443,14 @@ namespace Artemis.Core
// Start at the center of the shape
SKPoint position = zeroBased
? new SKPoint(layerPath.Bounds.MidX - layerPath.Bounds.Left, layerPath.Bounds.MidY - layerPath.Bounds.Top)
: new SKPoint(layerPath.Bounds.MidX, layerPath.Bounds.MidY);
? new SKPointI(Bounds.MidX - Bounds.Left, Bounds.MidY - Bounds.Top)
: new SKPointI(Bounds.MidX, Bounds.MidY);
// Apply translation
if (applyTranslation)
{
position.X += positionProperty.X * layerPath.Bounds.Width;
position.Y += positionProperty.Y * layerPath.Bounds.Height;
position.X += positionProperty.X * Bounds.Width;
position.Y += positionProperty.Y * Bounds.Height;
}
return position;
@@ -479,7 +478,7 @@ namespace Artemis.Core
SKSize sizeProperty = Transform.Scale.CurrentValue;
float rotationProperty = Transform.Rotation.CurrentValue;
SKPoint anchorPosition = GetLayerAnchorPosition(Path, true, zeroBased);
SKPoint anchorPosition = GetLayerAnchorPosition(true, zeroBased);
SKPoint anchorProperty = Transform.AnchorPoint.CurrentValue;
// Translation originates from the unscaled center of the shape and is tied to the anchor
+1 -1
View File
@@ -81,7 +81,7 @@ namespace Artemis.Core
}
/// <inheritdoc />
public override void Render(SKCanvas canvas, SKPoint basePosition)
public override void Render(SKCanvas canvas, SKPointI basePosition)
{
lock (_lock)
{
@@ -104,7 +104,7 @@ namespace Artemis.Core
/// <summary>
/// Renders the element
/// </summary>
public abstract void Render(SKCanvas canvas, SKPoint basePosition);
public abstract void Render(SKCanvas canvas, SKPointI basePosition);
/// <summary>
/// Resets the internal state of the element
@@ -16,6 +16,9 @@ namespace Artemis.Core
/// </summary>
public abstract class RenderProfileElement : ProfileElement
{
private SKPath? _path;
private SKRectI _bounds;
internal RenderProfileElement(Profile profile) : base(profile)
{
Timeline = new Timeline();
@@ -113,7 +116,6 @@ namespace Artemis.Core
#region Properties
private SKPath? _path;
internal abstract RenderElementEntity RenderElementEntity { get; }
/// <summary>
@@ -141,14 +143,14 @@ namespace Artemis.Core
SetAndNotify(ref _path, value);
// I can't really be sure about the performance impact of calling Bounds often but
// SkiaSharp calls SkiaApi.sk_path_get_bounds (Handle, &rect); which sounds expensive
Bounds = value?.Bounds ?? SKRect.Empty;
Bounds = SKRectI.Round(value?.Bounds ?? SKRect.Empty);
}
}
/// <summary>
/// The bounds of this entity
/// </summary>
public SKRect Bounds
public SKRectI Bounds
{
get => _bounds;
private set => SetAndNotify(ref _bounds, value);
@@ -158,8 +160,7 @@ namespace Artemis.Core
#region Property group expansion
internal List<string> ExpandedPropertyGroups;
private SKRect _bounds;
/// <summary>
/// Determines whether the provided property group is expanded
/// </summary>
@@ -8,8 +8,8 @@ namespace Artemis.Core
/// </summary>
public class ArtemisLed : CorePropertyChanged
{
private SKRect _absoluteRectangle;
private SKRect _rectangle;
private SKRectI _absoluteRectangle;
private SKRectI _rectangle;
internal ArtemisLed(Led led, ArtemisDevice device)
{
@@ -31,7 +31,7 @@ namespace Artemis.Core
/// <summary>
/// Gets the rectangle covering the LED positioned relative to the<see cref="Device" />
/// </summary>
public SKRect Rectangle
public SKRectI Rectangle
{
get => _rectangle;
private set => SetAndNotify(ref _rectangle, value);
@@ -40,7 +40,7 @@ namespace Artemis.Core
/// <summary>
/// Gets the rectangle covering the LED
/// </summary>
public SKRect AbsoluteRectangle
public SKRectI AbsoluteRectangle
{
get => _absoluteRectangle;
private set => SetAndNotify(ref _absoluteRectangle, value);
@@ -59,8 +59,8 @@ namespace Artemis.Core
internal void CalculateRectangles()
{
Rectangle = RgbLed.Boundary.ToSKRect();
AbsoluteRectangle = RgbLed.AbsoluteBoundary.ToSKRect();
Rectangle = RgbLed.Boundary.ToSKRectI();
AbsoluteRectangle = RgbLed.AbsoluteBoundary.ToSKRectI();
}
}
}