mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Core - Added better way to flush LEDs
UI - Fixed a freeze when opening the device properties window of a device Core - Updated RGB.NET sampler call for API changes
This commit is contained in:
parent
9179010e12
commit
aace06b6cc
@ -107,7 +107,7 @@ namespace Artemis.Core
|
|||||||
GetRegionData(skRectI.Left, skRectI.Top, skRectI.Width, skRectI.Height, buffer);
|
GetRegionData(skRectI.Left, skRectI.Top, skRectI.Width, skRectI.Height, buffer);
|
||||||
|
|
||||||
Span<byte> pixelData = stackalloc byte[DATA_PER_PIXEL];
|
Span<byte> pixelData = stackalloc byte[DATA_PER_PIXEL];
|
||||||
Sampler.SampleColor(new SamplerInfo<byte>(skRectI.Width, skRectI.Height, buffer), pixelData);
|
Sampler.Sample(new SamplerInfo<byte>(skRectI.Width, skRectI.Height, buffer), pixelData);
|
||||||
|
|
||||||
return GetColor(pixelData);
|
return GetColor(pixelData);
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ namespace Artemis.Core
|
|||||||
GetRegionData(skRectI.Left, skRectI.Top, skRectI.Width, skRectI.Height, buffer);
|
GetRegionData(skRectI.Left, skRectI.Top, skRectI.Width, skRectI.Height, buffer);
|
||||||
|
|
||||||
Span<byte> pixelData = stackalloc byte[DATA_PER_PIXEL];
|
Span<byte> pixelData = stackalloc byte[DATA_PER_PIXEL];
|
||||||
Sampler.SampleColor(new SamplerInfo<byte>(skRectI.Width, skRectI.Height, buffer), pixelData);
|
Sampler.Sample(new SamplerInfo<byte>(skRectI.Width, skRectI.Height, buffer), pixelData);
|
||||||
|
|
||||||
ArrayPool<byte>.Shared.Return(rent);
|
ArrayPool<byte>.Shared.Return(rent);
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,6 @@ using RGB.NET.Core;
|
|||||||
using Serilog;
|
using Serilog;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
using Module = Artemis.Core.Modules.Module;
|
|
||||||
|
|
||||||
namespace Artemis.Core.Services
|
namespace Artemis.Core.Services
|
||||||
{
|
{
|
||||||
@ -107,6 +106,13 @@ namespace Artemis.Core.Services
|
|||||||
if (_rgbService.IsRenderPaused)
|
if (_rgbService.IsRenderPaused)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_rgbService.FlushLeds)
|
||||||
|
{
|
||||||
|
_rgbService.FlushLeds = false;
|
||||||
|
_rgbService.Surface.Update(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_frameStopWatch.Restart();
|
_frameStopWatch.Restart();
|
||||||
|
|||||||
@ -41,6 +41,11 @@ namespace Artemis.Core.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
bool RenderOpen { get; }
|
bool RenderOpen { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a boolean indicating whether to flush the RGB.NET LEDs during next update
|
||||||
|
/// </summary>
|
||||||
|
bool FlushLeds { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opens the render pipeline
|
/// Opens the render pipeline
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -137,8 +137,14 @@ namespace Artemis.Core.Services
|
|||||||
public bool IsRenderPaused { get; set; }
|
public bool IsRenderPaused { get; set; }
|
||||||
public bool RenderOpen { get; private set; }
|
public bool RenderOpen { get; private set; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public bool FlushLeds { get; set; }
|
||||||
|
|
||||||
public void AddDeviceProvider(IRGBDeviceProvider deviceProvider)
|
public void AddDeviceProvider(IRGBDeviceProvider deviceProvider)
|
||||||
{
|
{
|
||||||
|
if (RenderOpen)
|
||||||
|
throw new ArtemisCoreException("Cannot add a device provider while rendering");
|
||||||
|
|
||||||
lock (_devices)
|
lock (_devices)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -199,6 +205,9 @@ namespace Artemis.Core.Services
|
|||||||
|
|
||||||
public void RemoveDeviceProvider(IRGBDeviceProvider deviceProvider)
|
public void RemoveDeviceProvider(IRGBDeviceProvider deviceProvider)
|
||||||
{
|
{
|
||||||
|
if (RenderOpen)
|
||||||
|
throw new ArtemisCoreException("Cannot update the remove device provider while rendering");
|
||||||
|
|
||||||
lock (_devices)
|
lock (_devices)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -267,36 +276,39 @@ namespace Artemis.Core.Services
|
|||||||
if (RenderOpen)
|
if (RenderOpen)
|
||||||
throw new ArtemisCoreException("Cannot update the texture while rendering");
|
throw new ArtemisCoreException("Cannot update the texture while rendering");
|
||||||
|
|
||||||
IManagedGraphicsContext? graphicsContext = Constants.ManagedGraphicsContext = _newGraphicsContext;
|
lock (_devices)
|
||||||
if (!ReferenceEquals(graphicsContext, _newGraphicsContext))
|
|
||||||
graphicsContext = _newGraphicsContext;
|
|
||||||
|
|
||||||
if (graphicsContext != null)
|
|
||||||
_logger.Debug("Creating SKTexture with graphics context {graphicsContext}", graphicsContext.GetType().Name);
|
|
||||||
else
|
|
||||||
_logger.Debug("Creating SKTexture with software-based graphics context");
|
|
||||||
|
|
||||||
float evenWidth = Surface.Boundary.Size.Width;
|
|
||||||
if (evenWidth % 2 != 0)
|
|
||||||
evenWidth++;
|
|
||||||
float evenHeight = Surface.Boundary.Size.Height;
|
|
||||||
if (evenHeight % 2 != 0)
|
|
||||||
evenHeight++;
|
|
||||||
|
|
||||||
float renderScale = (float) _renderScaleSetting.Value;
|
|
||||||
int width = Math.Max(1, MathF.Min(evenWidth * renderScale, 4096).RoundToInt());
|
|
||||||
int height = Math.Max(1, MathF.Min(evenHeight * renderScale, 4096).RoundToInt());
|
|
||||||
|
|
||||||
_texture?.Dispose();
|
|
||||||
_texture = new SKTexture(graphicsContext, width, height, renderScale);
|
|
||||||
_textureBrush.Texture = _texture;
|
|
||||||
|
|
||||||
|
|
||||||
if (!ReferenceEquals(_newGraphicsContext, Constants.ManagedGraphicsContext = _newGraphicsContext))
|
|
||||||
{
|
{
|
||||||
Constants.ManagedGraphicsContext?.Dispose();
|
IManagedGraphicsContext? graphicsContext = Constants.ManagedGraphicsContext = _newGraphicsContext;
|
||||||
Constants.ManagedGraphicsContext = _newGraphicsContext;
|
if (!ReferenceEquals(graphicsContext, _newGraphicsContext))
|
||||||
_newGraphicsContext = null;
|
graphicsContext = _newGraphicsContext;
|
||||||
|
|
||||||
|
if (graphicsContext != null)
|
||||||
|
_logger.Debug("Creating SKTexture with graphics context {graphicsContext}", graphicsContext.GetType().Name);
|
||||||
|
else
|
||||||
|
_logger.Debug("Creating SKTexture with software-based graphics context");
|
||||||
|
|
||||||
|
float evenWidth = Surface.Boundary.Size.Width;
|
||||||
|
if (evenWidth % 2 != 0)
|
||||||
|
evenWidth++;
|
||||||
|
float evenHeight = Surface.Boundary.Size.Height;
|
||||||
|
if (evenHeight % 2 != 0)
|
||||||
|
evenHeight++;
|
||||||
|
|
||||||
|
float renderScale = (float) _renderScaleSetting.Value;
|
||||||
|
int width = Math.Max(1, MathF.Min(evenWidth * renderScale, 4096).RoundToInt());
|
||||||
|
int height = Math.Max(1, MathF.Min(evenHeight * renderScale, 4096).RoundToInt());
|
||||||
|
|
||||||
|
_texture?.Dispose();
|
||||||
|
_texture = new SKTexture(graphicsContext, width, height, renderScale);
|
||||||
|
_textureBrush.Texture = _texture;
|
||||||
|
|
||||||
|
|
||||||
|
if (!ReferenceEquals(_newGraphicsContext, Constants.ManagedGraphicsContext = _newGraphicsContext))
|
||||||
|
{
|
||||||
|
Constants.ManagedGraphicsContext?.Dispose();
|
||||||
|
Constants.ManagedGraphicsContext = _newGraphicsContext;
|
||||||
|
_newGraphicsContext = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -140,7 +140,7 @@ namespace Artemis.UI.Screens.Settings.Device.Tabs
|
|||||||
Device.GreenScale = GreenScale / 100f;
|
Device.GreenScale = GreenScale / 100f;
|
||||||
Device.BlueScale = BlueScale / 100f;
|
Device.BlueScale = BlueScale / 100f;
|
||||||
|
|
||||||
_rgbService.Surface.Update(true);
|
_rgbService.FlushLeds = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BrowseCustomLayout(object sender, MouseEventArgs e)
|
public void BrowseCustomLayout(object sender, MouseEventArgs e)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user