mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Core - Simplified and improved render scaling
This commit is contained in:
1 parent
18359c443f
commit
186d012087
10 files changed
+63
-99
No files matched your search
@@ -27,13 +27,14 @@ namespace Artemis.Core.Services
|
||||
private readonly Stopwatch _frameStopWatch;
|
||||
private readonly ILogger _logger;
|
||||
private readonly PluginSetting<LogEventLevel> _loggingLevel;
|
||||
private readonly PluginSetting<double> _renderScale;
|
||||
private readonly IPluginManagementService _pluginManagementService;
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly IRgbService _rgbService;
|
||||
private readonly ISurfaceService _surfaceService;
|
||||
private List<BaseDataModelExpansion> _dataModelExpansions = new List<BaseDataModelExpansion>();
|
||||
private List<Module> _modules = new List<Module>();
|
||||
|
||||
|
||||
// ReSharper disable UnusedParameter.Local - Storage migration and module service are injected early to ensure it runs before anything else
|
||||
public CoreService(IKernel kernel, ILogger logger, StorageMigrationService _, ISettingsService settingsService, IPluginManagementService pluginManagementService,
|
||||
IRgbService rgbService, ISurfaceService surfaceService, IProfileService profileService, IModuleService moduleService)
|
||||
@@ -47,6 +48,7 @@ namespace Artemis.Core.Services
|
||||
_surfaceService = surfaceService;
|
||||
_profileService = profileService;
|
||||
_loggingLevel = settingsService.GetSetting("Core.LoggingLevel", LogEventLevel.Debug);
|
||||
_renderScale = settingsService.GetSetting("Core.RenderScale", 0.5);
|
||||
_frameStopWatch = new Stopwatch();
|
||||
|
||||
UpdatePluginCache();
|
||||
@@ -185,6 +187,7 @@ namespace Artemis.Core.Services
|
||||
|
||||
// Render all active modules
|
||||
using SKCanvas canvas = new SKCanvas(_rgbService.BitmapBrush.Bitmap);
|
||||
canvas.Scale((float) _renderScale.Value);
|
||||
canvas.Clear(new SKColor(0, 0, 0));
|
||||
if (!ModuleRenderingDisabled)
|
||||
// While non-activated modules may be updated above if they expand the main data model, they may never render
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace Artemis.Core.Services.Models
|
||||
MarginTop = margin;
|
||||
MarginRight = margin;
|
||||
MarginBottom = margin;
|
||||
|
||||
SurfaceArrangement = null!;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,26 +15,23 @@ namespace Artemis.Core.Services
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IPluginManagementService _pluginManagementService;
|
||||
private readonly PluginSetting<double> _renderScaleSetting;
|
||||
private readonly IRgbService _rgbService;
|
||||
private readonly List<ArtemisSurface> _surfaceConfigurations;
|
||||
private readonly ISurfaceRepository _surfaceRepository;
|
||||
|
||||
public SurfaceService(ILogger logger, ISurfaceRepository surfaceRepository, IRgbService rgbService, IPluginManagementService pluginManagementService, ISettingsService settingsService)
|
||||
public SurfaceService(ILogger logger, ISurfaceRepository surfaceRepository, IRgbService rgbService, IPluginManagementService pluginManagementService)
|
||||
{
|
||||
_logger = logger;
|
||||
_surfaceRepository = surfaceRepository;
|
||||
_rgbService = rgbService;
|
||||
_pluginManagementService = pluginManagementService;
|
||||
_surfaceConfigurations = new List<ArtemisSurface>();
|
||||
_renderScaleSetting = settingsService.GetSetting("Core.RenderScale", 0.5);
|
||||
|
||||
// LoadFromRepository is guaranteed to set the ActiveSurface
|
||||
ActiveSurface = null!;
|
||||
LoadFromRepository();
|
||||
|
||||
_rgbService.DeviceLoaded += RgbServiceOnDeviceLoaded;
|
||||
_renderScaleSetting.SettingChanged += RenderScaleSettingOnSettingChanged;
|
||||
}
|
||||
|
||||
public ArtemisSurface ActiveSurface { get; private set; }
|
||||
@@ -43,7 +40,7 @@ namespace Artemis.Core.Services
|
||||
public ArtemisSurface CreateSurfaceConfiguration(string name)
|
||||
{
|
||||
// Create a blank config
|
||||
ArtemisSurface configuration = new ArtemisSurface(_rgbService.Surface, name, _renderScaleSetting.Value);
|
||||
ArtemisSurface configuration = new ArtemisSurface(_rgbService.Surface, name);
|
||||
|
||||
// Add all current devices
|
||||
foreach (IRGBDevice rgbDevice in _rgbService.LoadedDevices)
|
||||
@@ -133,7 +130,7 @@ namespace Artemis.Core.Services
|
||||
foreach (SurfaceEntity surfaceEntity in configs)
|
||||
{
|
||||
// Create the surface entity
|
||||
ArtemisSurface surfaceConfiguration = new ArtemisSurface(_rgbService.Surface, surfaceEntity, _renderScaleSetting.Value);
|
||||
ArtemisSurface surfaceConfiguration = new ArtemisSurface(_rgbService.Surface, surfaceEntity);
|
||||
foreach (DeviceEntity position in surfaceEntity.DeviceEntities)
|
||||
{
|
||||
IRGBDevice? device = _rgbService.Surface.Devices.FirstOrDefault(d => d.GetDeviceIdentifier() == position.DeviceIdentifier);
|
||||
@@ -225,15 +222,6 @@ namespace Artemis.Core.Services
|
||||
UpdateSurfaceConfiguration(ActiveSurface, true);
|
||||
}
|
||||
|
||||
private void RenderScaleSettingOnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
foreach (ArtemisSurface surfaceConfiguration in SurfaceConfigurations)
|
||||
{
|
||||
surfaceConfiguration.UpdateScale(_renderScaleSetting.Value);
|
||||
OnSurfaceConfigurationUpdated(new SurfaceConfigurationEventArgs(surfaceConfiguration));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
Reference in new issue
Block a user