From ecd9189bf91a30addab892bf098b3ab969824b19 Mon Sep 17 00:00:00 2001 From: Daniel Chalmers Date: Sat, 25 Jul 2026 15:04:33 -0500 Subject: [PATCH] Cache the surface ring's drop shadow to cut per-frame GPU cost --- RadialActions/Pie/PieVisualBuilder.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/RadialActions/Pie/PieVisualBuilder.cs b/RadialActions/Pie/PieVisualBuilder.cs index af1f2e4..b01f17b 100644 --- a/RadialActions/Pie/PieVisualBuilder.cs +++ b/RadialActions/Pie/PieVisualBuilder.cs @@ -53,13 +53,23 @@ public static void AddSurfaceRing( SnapsToDevicePixels = true, }; + UIElement surfaceElement = surfacePath; + if (!isHighContrast && ambientShadowEffect != null) { surfacePath.Effect = ambientShadowEffect.CloneCurrentValue(); + + // Wrap in a cached container so the expensive shadow blur is baked into a bitmap once instead of being re-evaluated on every animation frame. + surfaceElement = new Border + { + Child = surfacePath, + IsHitTestVisible = false, + CacheMode = new BitmapCache(VisualTreeHelper.GetDpi(canvas).PixelsPerDip), + }; } - Panel.SetZIndex(surfacePath, 0); - canvas.Children.Add(surfacePath); + Panel.SetZIndex(surfaceElement, 0); + canvas.Children.Add(surfaceElement); } public static CenterElements CreateCenterElements(