Skip to content

Cache the surface ring's drop shadow to cut per-frame GPU cost - #72

Merged
danielchalmers merged 1 commit into
mainfrom
optimize-drop-shadow
Jul 25, 2026
Merged

Cache the surface ring's drop shadow to cut per-frame GPU cost#72
danielchalmers merged 1 commit into
mainfrom
optimize-drop-shadow

Conversation

@danielchalmers

Copy link
Copy Markdown
Owner

Summary

The surface ring carries a DropShadowEffect with BlurRadius=32 and RenderingBias="Quality", and it sits underneath every animating element in the menu. WPF re-evaluates the multi-pass Gaussian blur whenever the scene recomposes, so the blur runs during hover/press transitions, drag-to-reorder, and the window fades, which is exactly when the per-frame budget matters.

This wraps the shadowed ring in a container with a BitmapCache (rendered at the current DPI scale so it stays crisp under display scaling), so the blur is rasterized once per menu build and then composited as a texture on every subsequent frame.

Notes

  • RenderingBias stays at Quality: with the result cached, the high-quality blur only costs once per rebuild instead of once per frame, so there's no reason to trade it away.
  • The high-contrast path (which has no shadow) is unchanged.
  • Verified with an offscreen render comparison of the old vs. new code path: the shadow gradient matches within 8/255 per channel, and the only larger deltas are sub-pixel antialiasing on the 1px silhouette edge of the ring where the cached bitmap composites. Nothing off-edge changed.

@danielchalmers
danielchalmers merged commit 804754e into main Jul 25, 2026
1 check passed
@danielchalmers
danielchalmers deleted the optimize-drop-shadow branch July 25, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant