mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Implemented most of the rendering pipeline in SkiaSharp
This commit is contained in:
1 parent
b8a678c97f
commit
96a057df23
35 files changed
+234
-274
No files matched your search
@@ -8,6 +8,7 @@ using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Core.Services.Storage.Interfaces;
|
||||
using RGB.NET.Core;
|
||||
using Serilog;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Services
|
||||
{
|
||||
@@ -78,19 +79,24 @@ namespace Artemis.Core.Services
|
||||
}
|
||||
|
||||
// If there is no ready graphics decorator, skip the frame
|
||||
if (_rgbService.GraphicsDecorator?.Canvas == null)
|
||||
return;
|
||||
|
||||
// Render all active modules
|
||||
_rgbService.GraphicsDecorator.Canvas.Clear();
|
||||
lock (_modules)
|
||||
lock (_rgbService.GraphicsDecorator)
|
||||
{
|
||||
foreach (var module in _modules)
|
||||
module.Render(args.DeltaTime, _surfaceService.ActiveSurface, _rgbService.GraphicsDecorator.Canvas);
|
||||
if (_rgbService.GraphicsDecorator?.Bitmap == null)
|
||||
return;
|
||||
|
||||
// Render all active modules
|
||||
using (var canvas = new SKCanvas(_rgbService.GraphicsDecorator.Bitmap))
|
||||
{
|
||||
canvas.Clear(new SKColor(0, 0, 0));
|
||||
lock (_modules)
|
||||
{
|
||||
foreach (var module in _modules)
|
||||
module.Render(args.DeltaTime, _surfaceService.ActiveSurface, canvas);
|
||||
}
|
||||
|
||||
OnFrameRendering(new FrameRenderingEventArgs(_modules, canvas, args.DeltaTime, _rgbService.Surface));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
OnFrameRendering(new FrameRenderingEventArgs(_modules, _rgbService.GraphicsDecorator, args.DeltaTime, _rgbService.Surface));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Drawing;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Services
|
||||
{
|
||||
@@ -25,10 +25,7 @@ namespace Artemis.Core.Services
|
||||
// Draw a white overlay over the device
|
||||
void DrawOverlay(object sender, FrameRenderingEventArgs args)
|
||||
{
|
||||
using (var g = Graphics.FromImage(args.Bitmap))
|
||||
{
|
||||
g.FillPath(new SolidBrush(Color.White), device.RenderPath);
|
||||
}
|
||||
args.Canvas.DrawPath(device.RenderPath, new SKPaint {Color = new SKColor(255, 255, 255)});
|
||||
}
|
||||
|
||||
_coreService.FrameRendering += DrawOverlay;
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace Artemis.Core.Services
|
||||
_targetFrameRateSetting = settingsService.GetSetting("Core.TargetFrameRate", 25);
|
||||
|
||||
Surface = RGBSurface.Instance;
|
||||
GraphicsDecorator = new GraphicsDecorator(new ListLedGroup(), 1);
|
||||
|
||||
// Let's throw these for now
|
||||
Surface.Exception += SurfaceOnException;
|
||||
@@ -100,21 +101,22 @@ namespace Artemis.Core.Services
|
||||
|
||||
public void UpdateGraphicsDecorator()
|
||||
{
|
||||
// TODO: Create new one first, then clean up the old one for a smoother transition
|
||||
|
||||
// Clean up the old background if present
|
||||
if (_background != null)
|
||||
lock (GraphicsDecorator)
|
||||
{
|
||||
_background.Brush?.RemoveAllDecorators();
|
||||
_background.Detach();
|
||||
// Clean up the old background if present
|
||||
if (_background != null)
|
||||
{
|
||||
_background.Brush?.RemoveAllDecorators();
|
||||
_background.Detach();
|
||||
}
|
||||
|
||||
// Apply the application wide brush and decorator
|
||||
_background = new ListLedGroup(Surface.Leds) {Brush = new SolidColorBrush(new Color(255, 255, 255, 255))};
|
||||
GraphicsDecorator = new GraphicsDecorator(_background, _renderScaleSetting.Value);
|
||||
_background.Brush.RemoveAllDecorators();
|
||||
|
||||
_background.Brush.AddDecorator(GraphicsDecorator);
|
||||
}
|
||||
|
||||
// Apply the application wide brush and decorator
|
||||
_background = new ListLedGroup(Surface.Leds) {Brush = new SolidColorBrush(new Color(255, 255, 255, 255))};
|
||||
GraphicsDecorator = new GraphicsDecorator(_background, _renderScaleSetting.Value);
|
||||
_background.Brush.RemoveAllDecorators();
|
||||
|
||||
_background.Brush.AddDecorator(GraphicsDecorator);
|
||||
}
|
||||
|
||||
private void OnDeviceLoaded(DeviceEventArgs e)
|
||||
|
||||
Reference in new issue
Block a user