mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Debugger - Fixed current renderer always showing as Software
Render service - Log which renderer is used Updating - Fixed release not loading when viewing it from the desktop notification Core - Removed old unused code Data model event cycle node - Fixed crash on shutdown
This commit is contained in:
1 parent
6364ce3fc4
commit
3952a268d1
8 files changed
+23
-134
No files matched your search
@@ -155,10 +155,4 @@ public static class Constants
|
||||
/// Gets the startup arguments provided to the application
|
||||
/// </summary>
|
||||
public static ReadOnlyCollection<string> StartupArguments { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the graphics context to be used for rendering by SkiaSharp.
|
||||
/// </summary>
|
||||
public static IManagedGraphicsContext? ManagedGraphicsContext { get; internal set; }
|
||||
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
using System;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core;
|
||||
|
||||
internal class Renderer : IDisposable
|
||||
{
|
||||
private bool _disposed;
|
||||
private SKRect _lastBounds;
|
||||
private GRContext? _lastGraphicsContext;
|
||||
private SKRect _lastParentBounds;
|
||||
private bool _valid;
|
||||
public SKSurface? Surface { get; private set; }
|
||||
public SKPaint? Paint { get; private set; }
|
||||
public SKPath? Path { get; private set; }
|
||||
public SKPoint TargetLocation { get; private set; }
|
||||
|
||||
public bool IsOpen { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Opens the render context using the dimensions of the provided path
|
||||
/// </summary>
|
||||
public void Open(SKPath path, Folder? parent)
|
||||
{
|
||||
if (_disposed)
|
||||
throw new ObjectDisposedException("Renderer");
|
||||
|
||||
if (IsOpen)
|
||||
throw new ArtemisCoreException("Cannot open render context because it is already open");
|
||||
|
||||
if (path.Bounds != _lastBounds || (parent != null && parent.Bounds != _lastParentBounds) || _lastGraphicsContext != Constants.ManagedGraphicsContext?.GraphicsContext)
|
||||
Invalidate();
|
||||
|
||||
if (!_valid || Surface == null)
|
||||
{
|
||||
SKRect pathBounds = path.Bounds;
|
||||
int width = (int) pathBounds.Width;
|
||||
int height = (int) pathBounds.Height;
|
||||
|
||||
SKImageInfo imageInfo = new(width, height);
|
||||
if (Constants.ManagedGraphicsContext?.GraphicsContext == null)
|
||||
Surface = SKSurface.Create(imageInfo);
|
||||
else
|
||||
Surface = SKSurface.Create(Constants.ManagedGraphicsContext.GraphicsContext, true, imageInfo);
|
||||
|
||||
Path = new SKPath(path);
|
||||
Path.Transform(SKMatrix.CreateTranslation(pathBounds.Left * -1, pathBounds.Top * -1));
|
||||
|
||||
TargetLocation = new SKPoint(pathBounds.Location.X, pathBounds.Location.Y);
|
||||
if (parent != null)
|
||||
TargetLocation -= parent.Bounds.Location;
|
||||
|
||||
Surface.Canvas.ClipPath(Path);
|
||||
|
||||
_lastParentBounds = parent?.Bounds ?? new SKRect();
|
||||
_lastBounds = path.Bounds;
|
||||
_lastGraphicsContext = Constants.ManagedGraphicsContext?.GraphicsContext;
|
||||
_valid = true;
|
||||
}
|
||||
|
||||
Paint = new SKPaint();
|
||||
|
||||
Surface.Canvas.Clear();
|
||||
Surface.Canvas.Save();
|
||||
|
||||
IsOpen = true;
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
if (_disposed)
|
||||
throw new ObjectDisposedException("Renderer");
|
||||
|
||||
Surface?.Canvas.Restore();
|
||||
|
||||
// Looks like every part of the paint needs to be disposed :(
|
||||
Paint?.ColorFilter?.Dispose();
|
||||
Paint?.ImageFilter?.Dispose();
|
||||
Paint?.MaskFilter?.Dispose();
|
||||
Paint?.PathEffect?.Dispose();
|
||||
Paint?.Dispose();
|
||||
|
||||
Paint = null;
|
||||
|
||||
IsOpen = false;
|
||||
}
|
||||
|
||||
public void Invalidate()
|
||||
{
|
||||
if (_disposed)
|
||||
throw new ObjectDisposedException("Renderer");
|
||||
|
||||
_valid = false;
|
||||
}
|
||||
|
||||
~Renderer()
|
||||
{
|
||||
if (IsOpen)
|
||||
Close();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (IsOpen)
|
||||
Close();
|
||||
|
||||
Surface?.Dispose();
|
||||
Paint?.Dispose();
|
||||
Path?.Dispose();
|
||||
|
||||
Surface = null;
|
||||
Paint = null;
|
||||
Path = null;
|
||||
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
@@ -123,6 +123,7 @@ internal class RenderService : IRenderService, IRenderer, IDisposable
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.Information("Applying {Name} graphics context", _preferredGraphicsContext.Value);
|
||||
if (_preferredGraphicsContext.Value == "Software")
|
||||
{
|
||||
GraphicsContext = null;
|
||||
|
||||
Reference in new issue
Block a user