mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Rendering - Improved sampling performance
Plugins - Added update/render time measuring
Settings - Added a way to enable 60/144 FPS 🕵🏻♂️
This commit is contained in:
1 parent
fc9476247f
commit
97668ee932
8 files changed
+141
-75
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Artemis.Core.DataModelExpansions;
|
||||
using Artemis.Storage.Entities.Module;
|
||||
@@ -186,13 +187,17 @@ namespace Artemis.Core.Modules
|
||||
|
||||
internal virtual void InternalUpdate(double deltaTime)
|
||||
{
|
||||
StartUpdateMeasure();
|
||||
if (IsUpdateAllowed)
|
||||
Update(deltaTime);
|
||||
StopUpdateMeasure();
|
||||
}
|
||||
|
||||
internal virtual void InternalRender(double deltaTime, SKCanvas canvas, SKImageInfo canvasInfo)
|
||||
{
|
||||
StartRenderMeasure();
|
||||
Render(deltaTime, canvas, canvasInfo);
|
||||
StopRenderMeasure();
|
||||
}
|
||||
|
||||
internal virtual void Activate(bool isOverride)
|
||||
|
||||
@@ -150,6 +150,7 @@ namespace Artemis.Core.Modules
|
||||
|
||||
internal override void InternalUpdate(double deltaTime)
|
||||
{
|
||||
StartUpdateMeasure();
|
||||
if (IsUpdateAllowed)
|
||||
Update(deltaTime);
|
||||
|
||||
@@ -165,10 +166,12 @@ namespace Artemis.Core.Modules
|
||||
}
|
||||
|
||||
ProfileUpdated(deltaTime);
|
||||
StopUpdateMeasure();
|
||||
}
|
||||
|
||||
internal override void InternalRender(double deltaTime, SKCanvas canvas, SKImageInfo canvasInfo)
|
||||
{
|
||||
StartRenderMeasure();
|
||||
Render(deltaTime, canvas, canvasInfo);
|
||||
|
||||
lock (_lock)
|
||||
@@ -178,6 +181,7 @@ namespace Artemis.Core.Modules
|
||||
}
|
||||
|
||||
ProfileRendered(deltaTime, canvas, canvasInfo);
|
||||
StopRenderMeasure();
|
||||
}
|
||||
|
||||
internal async Task ChangeActiveProfileAnimated(Profile? profile, IEnumerable<ArtemisDevice> devices)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Storage.Entities.Plugins;
|
||||
@@ -10,9 +11,11 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public abstract class PluginFeature : CorePropertyChanged, IDisposable
|
||||
{
|
||||
private readonly Stopwatch _renderStopwatch = new();
|
||||
private readonly Stopwatch _updateStopwatch = new();
|
||||
private bool _isEnabled;
|
||||
private Exception? _loadException;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin feature info related to this feature
|
||||
/// </summary>
|
||||
@@ -46,6 +49,16 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public string Id => $"{GetType().FullName}-{Plugin.Guid.ToString().Substring(0, 8)}"; // Not as unique as a GUID but good enough and stays readable
|
||||
|
||||
/// <summary>
|
||||
/// Gets the last measured update time of the feature
|
||||
/// </summary>
|
||||
public TimeSpan UpdateTime { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the last measured render time of the feature
|
||||
/// </summary>
|
||||
public TimeSpan RenderTime { get; private set; }
|
||||
|
||||
internal PluginFeatureEntity Entity { get; set; } = null!; // Will be set right after construction
|
||||
|
||||
/// <summary>
|
||||
@@ -58,6 +71,66 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public abstract void Disable();
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the feature is enabled
|
||||
/// </summary>
|
||||
public event EventHandler? Enabled;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the feature is disabled
|
||||
/// </summary>
|
||||
public event EventHandler? Disabled;
|
||||
|
||||
/// <summary>
|
||||
/// Releases the unmanaged resources used by the plugin feature and optionally releases the managed resources.
|
||||
/// </summary>
|
||||
/// <param name="disposing">
|
||||
/// <see langword="true" /> to release both managed and unmanaged resources;
|
||||
/// <see langword="false" /> to release only unmanaged resources.
|
||||
/// </param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing) InternalDisable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggers the Enabled event
|
||||
/// </summary>
|
||||
protected virtual void OnEnabled()
|
||||
{
|
||||
Enabled?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggers the Disabled event
|
||||
/// </summary>
|
||||
protected virtual void OnDisabled()
|
||||
{
|
||||
Disabled?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
internal void StartUpdateMeasure()
|
||||
{
|
||||
_updateStopwatch.Start();
|
||||
}
|
||||
|
||||
internal void StopUpdateMeasure()
|
||||
{
|
||||
UpdateTime = _updateStopwatch.Elapsed;
|
||||
_updateStopwatch.Reset();
|
||||
}
|
||||
|
||||
internal void StartRenderMeasure()
|
||||
{
|
||||
_renderStopwatch.Start();
|
||||
}
|
||||
|
||||
internal void StopRenderMeasure()
|
||||
{
|
||||
RenderTime = _renderStopwatch.Elapsed;
|
||||
_renderStopwatch.Reset();
|
||||
}
|
||||
|
||||
internal void SetEnabled(bool enable, bool isAutoEnable = false)
|
||||
{
|
||||
if (enable == IsEnabled)
|
||||
@@ -133,25 +206,6 @@ namespace Artemis.Core
|
||||
Disable();
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Releases the unmanaged resources used by the plugin feature and optionally releases the managed resources.
|
||||
/// </summary>
|
||||
/// <param name="disposing">
|
||||
/// <see langword="true" /> to release both managed and unmanaged resources;
|
||||
/// <see langword="false" /> to release only unmanaged resources.
|
||||
/// </param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
InternalDisable();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
@@ -187,35 +241,5 @@ namespace Artemis.Core
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the feature is enabled
|
||||
/// </summary>
|
||||
public event EventHandler? Enabled;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the feature is disabled
|
||||
/// </summary>
|
||||
public event EventHandler? Disabled;
|
||||
|
||||
/// <summary>
|
||||
/// Triggers the Enabled event
|
||||
/// </summary>
|
||||
protected virtual void OnEnabled()
|
||||
{
|
||||
Enabled?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggers the Disabled event
|
||||
/// </summary>
|
||||
protected virtual void OnDisabled()
|
||||
{
|
||||
Disabled?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user