mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 13:28:33 +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:
parent
6364ce3fc4
commit
3952a268d1
@ -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;
|
||||
|
||||
@ -60,10 +60,10 @@ public class WindowsUpdateNotificationProvider : IUpdateNotificationProvider
|
||||
Dispatcher.UIThread.Invoke(async () =>
|
||||
{
|
||||
_mainWindowService.OpenMainWindow();
|
||||
if (releaseId != null)
|
||||
if (releaseId != null && releaseId.Value != Guid.Empty)
|
||||
await _router.Navigate($"settings/releases/{releaseId}");
|
||||
else
|
||||
await _router.Navigate($"settings/releases");
|
||||
await _router.Navigate("settings/releases");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ public partial class PerformanceDebugViewModel : ActivatableViewModelBase
|
||||
|
||||
private void HandleActivation()
|
||||
{
|
||||
Renderer = Constants.ManagedGraphicsContext != null ? Constants.ManagedGraphicsContext.GetType().Name : "Software";
|
||||
Renderer = _renderService.GraphicsContext?.GetType().Name ?? "Software";
|
||||
_renderService.FrameRendered += RenderServiceOnFrameRendered;
|
||||
}
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ public partial class RenderDebugViewModel : ActivatableViewModelBase
|
||||
|
||||
private void HandleActivation()
|
||||
{
|
||||
Renderer = Constants.ManagedGraphicsContext != null ? Constants.ManagedGraphicsContext.GetType().Name : "Software";
|
||||
Renderer = _renderService.GraphicsContext?.GetType().Name ?? "Software";
|
||||
_renderService.FrameRendered += RenderServiceOnFrameRendered;
|
||||
}
|
||||
|
||||
|
||||
@ -82,8 +82,8 @@ public partial class UploadStepViewModel : SubmissionViewModel
|
||||
FailureMessage = e.Message;
|
||||
Failed = true;
|
||||
|
||||
// If something went wrong halfway through, delete the entry
|
||||
if (_entryId != null)
|
||||
// If something went wrong halfway through, delete the entry if it was new
|
||||
if (State.EntryId == null && _entryId != null)
|
||||
await _workshopClient.RemoveEntry.ExecuteAsync(_entryId.Value, CancellationToken.None);
|
||||
}
|
||||
finally
|
||||
|
||||
@ -11,6 +11,7 @@ public class DataModelEventCycleNode : Node<DataModelPathEntity, DataModelEventC
|
||||
private int _currentIndex;
|
||||
private Type _currentType;
|
||||
private DataModelPath? _dataModelPath;
|
||||
private IDataModelEvent? _subscribedEvent;
|
||||
private object? _lastPathValue;
|
||||
private bool _updating;
|
||||
|
||||
@ -76,13 +77,19 @@ public class DataModelEventCycleNode : Node<DataModelPathEntity, DataModelEventC
|
||||
{
|
||||
DataModelPath? old = _dataModelPath;
|
||||
|
||||
if (old?.GetValue() is IDataModelEvent oldEvent)
|
||||
oldEvent.EventTriggered -= OnEventTriggered;
|
||||
if (_subscribedEvent != null)
|
||||
{
|
||||
_subscribedEvent.EventTriggered -= OnEventTriggered;
|
||||
_subscribedEvent = null;
|
||||
}
|
||||
|
||||
_dataModelPath = Storage != null ? new DataModelPath(Storage) : null;
|
||||
|
||||
if (_dataModelPath?.GetValue() is IDataModelEvent newEvent)
|
||||
newEvent.EventTriggered += OnEventTriggered;
|
||||
{
|
||||
_subscribedEvent = newEvent;
|
||||
_subscribedEvent.EventTriggered += OnEventTriggered;
|
||||
}
|
||||
|
||||
old?.Dispose();
|
||||
}
|
||||
@ -153,8 +160,12 @@ public class DataModelEventCycleNode : Node<DataModelPathEntity, DataModelEventC
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
if (_dataModelPath?.GetValue() is IDataModelEvent newEvent)
|
||||
newEvent.EventTriggered -= OnEventTriggered;
|
||||
if (_subscribedEvent != null)
|
||||
{
|
||||
_subscribedEvent.EventTriggered -= OnEventTriggered;
|
||||
_subscribedEvent = null;
|
||||
}
|
||||
|
||||
_dataModelPath?.Dispose();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user