mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 20:06:33 +00:00
Implemented most of the rendering pipeline in SkiaSharp
This commit is contained in:
1 parent
0e3afef6ca
commit
07b2ad87c4
35 files changed
+234
-274
No files matched your search
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Extensions;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
@@ -8,7 +7,6 @@ using Artemis.Storage.Entities.Surface;
|
||||
using RGB.NET.Core;
|
||||
using SkiaSharp;
|
||||
using Stylet;
|
||||
using Rectangle = System.Drawing.Rectangle;
|
||||
|
||||
namespace Artemis.Core.Models.Surface
|
||||
{
|
||||
@@ -99,14 +97,8 @@ namespace Artemis.Core.Models.Surface
|
||||
RenderRectangle = SKRect.Create(
|
||||
(RgbDevice.Location.X * Surface.Scale).RoundToInt(),
|
||||
(RgbDevice.Location.Y * Surface.Scale).RoundToInt(),
|
||||
(RgbDevice.Location.X * Surface.Scale).RoundToInt(),
|
||||
(RgbDevice.Location.X * Surface.Scale).RoundToInt()
|
||||
);
|
||||
RenderRectangle = new Rectangle(
|
||||
(int) Math.Round(RgbDevice.Location.X * Surface.Scale, MidpointRounding.AwayFromZero),
|
||||
(int) Math.Round(RgbDevice.Location.Y * Surface.Scale, MidpointRounding.AwayFromZero),
|
||||
(int) Math.Round(RgbDevice.DeviceRectangle.Size.Width * Surface.Scale, MidpointRounding.AwayFromZero),
|
||||
(int) Math.Round(RgbDevice.DeviceRectangle.Size.Height * Surface.Scale, MidpointRounding.AwayFromZero)
|
||||
(RgbDevice.DeviceRectangle.Size.Width * Surface.Scale).RoundToInt(),
|
||||
(RgbDevice.DeviceRectangle.Size.Height * Surface.Scale).RoundToInt()
|
||||
);
|
||||
|
||||
if (!Leds.Any())
|
||||
@@ -115,9 +107,10 @@ namespace Artemis.Core.Models.Surface
|
||||
foreach (var led in Leds)
|
||||
led.CalculateRenderRectangle();
|
||||
|
||||
var path = new GraphicsPath();
|
||||
path.AddRectangles(Leds.Select(l => l.AbsoluteRenderRectangle).ToArray());
|
||||
path.FillMode = FillMode.Winding;
|
||||
var path = new SKPath {FillType = SKPathFillType.Winding};
|
||||
foreach (var artemisLed in Leds)
|
||||
path.AddRect(artemisLed.AbsoluteRenderRectangle);
|
||||
|
||||
RenderPath = path;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using Artemis.Core.Extensions;
|
||||
using RGB.NET.Core;
|
||||
using SkiaSharp;
|
||||
using Stylet;
|
||||
using Rectangle = System.Drawing.Rectangle;
|
||||
|
||||
namespace Artemis.Core.Models.Surface
|
||||
{
|
||||
@@ -17,22 +17,22 @@ namespace Artemis.Core.Models.Surface
|
||||
public Led RgbLed { get; }
|
||||
public ArtemisDevice Device { get; }
|
||||
|
||||
public Rectangle RenderRectangle { get; private set; }
|
||||
public Rectangle AbsoluteRenderRectangle { get; private set; }
|
||||
public SKRect RenderRectangle { get; private set; }
|
||||
public SKRect AbsoluteRenderRectangle { get; private set; }
|
||||
|
||||
public void CalculateRenderRectangle()
|
||||
{
|
||||
RenderRectangle = new Rectangle(
|
||||
(int) Math.Round(RgbLed.LedRectangle.Location.X * Device.Surface.Scale, MidpointRounding.AwayFromZero),
|
||||
(int) Math.Round(RgbLed.LedRectangle.Location.Y * Device.Surface.Scale, MidpointRounding.AwayFromZero),
|
||||
(int) Math.Round(RgbLed.LedRectangle.Size.Width * Device.Surface.Scale, MidpointRounding.AwayFromZero),
|
||||
(int) Math.Round(RgbLed.LedRectangle.Size.Height * Device.Surface.Scale, MidpointRounding.AwayFromZero)
|
||||
RenderRectangle = SKRect.Create(
|
||||
(RgbLed.LedRectangle.Location.X * Device.Surface.Scale).RoundToInt(),
|
||||
(RgbLed.LedRectangle.Location.Y * Device.Surface.Scale).RoundToInt(),
|
||||
(RgbLed.LedRectangle.Size.Width * Device.Surface.Scale).RoundToInt(),
|
||||
(RgbLed.LedRectangle.Size.Height * Device.Surface.Scale).RoundToInt()
|
||||
);
|
||||
AbsoluteRenderRectangle = new Rectangle(
|
||||
(int) Math.Round(RgbLed.AbsoluteLedRectangle.Location.X * Device.Surface.Scale, MidpointRounding.AwayFromZero),
|
||||
(int) Math.Round(RgbLed.AbsoluteLedRectangle.Location.Y * Device.Surface.Scale, MidpointRounding.AwayFromZero),
|
||||
(int) Math.Round(RgbLed.AbsoluteLedRectangle.Size.Width * Device.Surface.Scale, MidpointRounding.AwayFromZero),
|
||||
(int) Math.Round(RgbLed.AbsoluteLedRectangle.Size.Height * Device.Surface.Scale, MidpointRounding.AwayFromZero)
|
||||
AbsoluteRenderRectangle = SKRect.Create(
|
||||
(RgbLed.AbsoluteLedRectangle.Location.X * Device.Surface.Scale).RoundToInt(),
|
||||
(RgbLed.AbsoluteLedRectangle.Location.Y * Device.Surface.Scale).RoundToInt(),
|
||||
(RgbLed.AbsoluteLedRectangle.Size.Width * Device.Surface.Scale).RoundToInt(),
|
||||
(RgbLed.AbsoluteLedRectangle.Size.Height * Device.Surface.Scale).RoundToInt()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user