mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Blur effect - Some minor optimizations
Profile editor - Properly update effects on render
This commit is contained in:
1 parent
8eed347de5
commit
34bcd22f8c
5 files changed
+33
-9
No files matched your search
@@ -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");
|
||||
|
||||
Reference in new issue
Block a user