mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Blur effect - Some minor optimizations
Profile editor - Properly update effects on render
This commit is contained in:
parent
8eed347de5
commit
34bcd22f8c
@ -287,6 +287,7 @@ namespace Artemis.Core.Models.Profile
|
||||
|
||||
using (var paint = new SKPaint())
|
||||
{
|
||||
paint.FilterQuality = SKFilterQuality.Low;
|
||||
paint.BlendMode = General.BlendMode.CurrentValue;
|
||||
paint.Color = new SKColor(0, 0, 0, (byte) (Transform.Opacity.CurrentValue * 2.55f));
|
||||
|
||||
|
||||
@ -102,6 +102,8 @@ namespace Artemis.UI.Shared.Services
|
||||
{
|
||||
layer.OverrideProgress(CurrentTime);
|
||||
layer.LayerBrush?.Update(delta.TotalSeconds);
|
||||
foreach (var baseLayerEffect in layer.LayerEffects)
|
||||
baseLayerEffect.Update(delta.TotalSeconds);
|
||||
}
|
||||
|
||||
_lastUpdateTime = CurrentTime;
|
||||
|
||||
@ -40,8 +40,8 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<materialDesign:PackIcon Kind="{Binding Icon}" Width="20" Height="20" VerticalAlignment="Center" />
|
||||
<StackPanel Margin="8 0 0 0" Grid.Column="1" VerticalAlignment="Stretch">
|
||||
<TextBlock FontWeight="Bold" Text="{Binding DisplayName}" />
|
||||
<TextBlock Text="{Binding Description}" />
|
||||
<TextBlock FontWeight="Bold" Text="{Binding DisplayName}" TextWrapping="Wrap" />
|
||||
<TextBlock Text="{Binding Description}" TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
@ -1,10 +1,15 @@
|
||||
using Artemis.Core.Plugins.LayerEffect.Abstract;
|
||||
using System;
|
||||
using Artemis.Core.Plugins.LayerEffect.Abstract;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Plugins.LayerEffects.Filter
|
||||
{
|
||||
public class BlurEffect : LayerEffect<BlurEffectProperties>
|
||||
{
|
||||
private double _lastWidth;
|
||||
private double _lastHeight;
|
||||
private SKImageFilter _imageFilter;
|
||||
|
||||
public override void EnableLayerEffect()
|
||||
{
|
||||
}
|
||||
@ -15,15 +20,27 @@ namespace Artemis.Plugins.LayerEffects.Filter
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
if (Math.Abs(Properties.BlurAmount.CurrentValue.Width - _lastWidth) > 0.01 || Math.Abs(Properties.BlurAmount.CurrentValue.Height - _lastHeight) > 0.01)
|
||||
{
|
||||
if (Properties.BlurAmount.CurrentValue.Width <= 0 && Properties.BlurAmount.CurrentValue.Height <= 0)
|
||||
_imageFilter = null;
|
||||
else
|
||||
{
|
||||
_imageFilter = SKImageFilter.CreateBlur(
|
||||
Properties.BlurAmount.CurrentValue.Width,
|
||||
Properties.BlurAmount.CurrentValue.Height
|
||||
);
|
||||
}
|
||||
|
||||
_lastWidth = Properties.BlurAmount.CurrentValue.Width;
|
||||
_lastHeight = Properties.BlurAmount.CurrentValue.Height;
|
||||
}
|
||||
}
|
||||
|
||||
public override void PreProcess(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint)
|
||||
{
|
||||
paint.ImageFilter = SKImageFilter.CreateBlur(
|
||||
Properties.BlurAmount.CurrentValue.Width,
|
||||
Properties.BlurAmount.CurrentValue.Height,
|
||||
paint.ImageFilter
|
||||
);
|
||||
if (_imageFilter != null)
|
||||
paint.ImageFilter = SKImageFilter.CreateMerge(paint.ImageFilter, _imageFilter);
|
||||
}
|
||||
|
||||
public override void PostProcess(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint)
|
||||
|
||||
@ -6,7 +6,11 @@ namespace Artemis.Plugins.LayerEffects.Filter
|
||||
{
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
AddLayerEffectDescriptor<BlurEffect>("Blur", "A layer effect providing a blur filter effect", "BlurOn");
|
||||
AddLayerEffectDescriptor<BlurEffect>(
|
||||
"Blur",
|
||||
"A layer effect providing a blur filter effect. \r\nNote: CPU intensive, best to only use on small layers or for a short period of time.",
|
||||
"BlurOn"
|
||||
);
|
||||
AddLayerEffectDescriptor<DilateEffect>("Dilate", "A layer effect providing a dilation filter effect", "EyePlus");
|
||||
AddLayerEffectDescriptor<ErodeEffect>("Erode", "A layer effect providing an erode filter effect", "EyeMinus");
|
||||
AddLayerEffectDescriptor<GlowEffect>("Glow", "A layer effect providing a glow filter effect", "BoxShadow");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user