remove old unused material rendering code. Cache drawing operation.
MODIFY
WalletWasabi.Fluent/Controls/BlurBehind.cs
WalletWasabi.Fluent/Controls/BlurBehind.cs
@@ -4,26 +4,17 @@ using Avalonia.Media;
using Avalonia.Platform;
using Avalonia.Rendering.SceneGraph;
using Avalonia.Skia;
-using JetBrains.Annotations;
using SkiaSharp;
namespace WalletWasabi.Fluent.Controls;
-public class CustomBlurBehind : Control
+public class BlurBehind : Control
{
- public static readonly StyledProperty<ExperimentalAcrylicMaterial> MaterialProperty =
- AvaloniaProperty.Register<CustomBlurBehind, ExperimentalAcrylicMaterial>(
- "Material");
+ private BlurBehindRenderOperation? _operation;
public static readonly StyledProperty<Vector> BlurRadiusProperty =
- AvaloniaProperty.Register<CustomBlurBehind, Vector>(
- "BlurRadius", defaultValue: new Vector(10, 10));
-
- public ExperimentalAcrylicMaterial Material
- {
- get => GetValue(MaterialProperty);
- set => SetValue(MaterialProperty, value);
- }
+ AvaloniaProperty.Register<BlurBehind, Vector>(
+ nameof(BlurRadius), new Vector(10, 10));
public Vector BlurRadius
{
@@ -31,60 +22,23 @@ public class CustomBlurBehind : Control
set => SetValue(BlurRadiusProperty, value);
}
- static ImmutableExperimentalAcrylicMaterial DefaultAcrylicMaterial =
- (ImmutableExperimentalAcrylicMaterial)new ExperimentalAcrylicMaterial()
- {
- MaterialOpacity = 0.0,
- TintColor = Colors.Azure,
- TintOpacity = 0.0,
- PlatformTransparencyCompensationLevel = 0
- }.ToImmutable();
-
- static CustomBlurBehind()
- {
- AffectsRender<CustomBlurBehind>(MaterialProperty);
- }
-
- [CanBeNull] private static SKShader s_acrylicNoiseShader;
-
private class BlurBehindRenderOperation : ICustomDrawOperation
{
- private readonly ImmutableExperimentalAcrylicMaterial _material;
private readonly Rect _bounds;
private readonly Vector _blurRadius;
- public BlurBehindRenderOperation(ImmutableExperimentalAcrylicMaterial material, Rect bounds, Vector blurRadius)
+ public BlurBehindRenderOperation(Rect bounds, Vector blurRadius)
{
- _material = material;
_bounds = bounds;
_blurRadius = blurRadius;
}
public void Dispose()
{
-
}
public bool HitTest(Point p) => _bounds.Contains(p);
- static SKColorFilter CreateAlphaColorFilter(double opacity)
- {
- if (opacity > 1)
- {
- opacity = 1;
- }
-
- var c = new byte[256];
- var a = new byte[256];
- for (var i = 0; i < 256; i++)
- {
- c[i] = (byte)i;
- a[i] = (byte)(i * opacity);
- }
-
- return SKColorFilter.CreateTable(a, c, c, c);
- }
-
public void Render(IDrawingContextImpl context)
{
if (context is not ISkiaDrawingContextImpl skia)
@@ -104,7 +58,8 @@ public class CustomBlurBehind : Control
using var blurred = SKSurface.Create(skia.GrContext, false, new SKImageInfo(
(int)Math.Ceiling(_bounds.Width),
(int)Math.Ceiling(_bounds.Height), SKImageInfo.PlatformColorType, SKAlphaType.Premul));
- using (var filter = SKImageFilter.CreateBlur((int)_blurRadius.X, (int)_blurRadius.Y, SKShaderTileMode.Clamp))
+ using (var filter =
+ SKImageFilter.CreateBlur((int)_blurRadius.X, (int)_blurRadius.Y, SKShaderTileMode.Clamp))
using (var blurPaint = new SKPaint
{
Shader = backdropShader,
@@ -126,20 +81,26 @@ public class CustomBlurBehind : Control
}
}
- public Rect Bounds => _bounds.Inflate(4);
+ public Rect Bounds => _bounds.Inflate(_blurRadius.X);
public bool Equals(ICustomDrawOperation? other)
{
- return other is BlurBehindRenderOperation op && op._bounds == _bounds && op._material.Equals(_material);
+ return other is BlurBehindRenderOperation op && op._bounds == _bounds;
}
}
+ protected override Size ArrangeOverride(Size finalSize)
+ {
+ _operation = new BlurBehindRenderOperation(new Rect(new Point(), finalSize), BlurRadius);
+
+ return base.ArrangeOverride(finalSize);
+ }
public override void Render(DrawingContext context)
{
- var mat = Material != null
- ? (ImmutableExperimentalAcrylicMaterial)Material.ToImmutable()
- : DefaultAcrylicMaterial;
- context.Custom(new BlurBehindRenderOperation(mat, new Rect(default, Bounds.Size), BlurRadius));
+ if (_operation is { })
+ {
+ context.Custom(_operation);
+ }
}
}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/Views/MainView.axaml
WalletWasabi.Fluent/Views/MainView.axaml
<Panel>
<Border Background="{DynamicResource RegionColor}" IsHitTestVisible="False" />
<Panel Background="{DynamicResource RegionColor}" VerticalAlignment="Bottom"
- Height="64">
+ Height="100">
<spectrum:SpectrumControl Opacity="0.6" IsActive="{Binding IsCoinJoinActive}" IsDockEffectVisible="{Binding MusicControls.IsActive}" />
- <c:CustomBlurBehind />
<statusBar:StatusBar DataContext="{Binding StatusBar}" />
</Panel>
<DockPanel>

MODIFY
WalletWasabi.Fluent/Views/Wallets/MusicControlsView.axaml
WalletWasabi.Fluent/Views/Wallets/MusicControlsView.axaml
Background="#19FFFFFF"
BorderBrush="#3CFFFFFF">
<Panel >
- <controls:CustomBlurBehind BlurRadius="20,20"/>
+ <controls:BlurBehind BlurRadius="20,20"/>
<StackPanel Margin="20 10" Orientation="Horizontal" Spacing="20">
<controls:ScrollingTextBlock MaxWidth="350" Text="{Binding CurrentStatus}" />
<PathIcon Data="{StaticResource stop_regular}" />
</Button>
</StackPanel>
-
</Panel>
</Border>
</UserControl>
\ No newline at end of file

remove old unused material rendering code. Cache drawing operation.