Skip to main content

Module backdrop

Module backdrop 

Expand description

The blurred material floating chrome is made of.

Floating chrome — the palette, menus, popovers, quick settings, sheets, notifications and chrome over media — is drawn over a blurred copy of what is behind it, tinted with the panel ground (docs/design-language.md, “Material and transparency”). The blur radius and the tint’s opacity are theme roles (surfaces.material_blur_px, surfaces.material_opacity, set by the theme document’s material). A surface asks for the material with crate::floating_surface::Material::Floating; nothing outside the theme and this module picks a blur radius or a tint.

Vello cannot sample what it has already drawn, so the blur is a pass that runs before the frame:

  1. While a host holds a BackdropRecording, [fill] draws a surface’s body as a placeholder image under the tint and records what lies behind it: what the scene it is drawn into held so far, which of the host’s scenes that is (see layer_scene), the surface’s bounds and its blur radius.
  2. The host turns those records into a BackdropFrame in its target’s pixel space, each region carrying the complete scene composed below the surface.
  3. A renderer that composites materials calls BackdropBlur::prepare: each region’s backdrop is rendered at half resolution, halved until the blur fits a short kernel, blurred separably, and substituted for the placeholder. The frame then renders as usual, and BackdropBlur::release drops the substitutions.

The placeholder’s own pixels are the opaque panel ground, so any path that does not substitute it — no blur pass in the renderer, a failed backdrop render, a capture of the scene — shows the opaque material. Reduced transparency, forced colours and a theme without blur draw the opaque material directly.

Structs§

BackdropBlur
The GPU half of the material: renders, blurs and substitutes each region’s backdrop on one device. Built once per renderer.
BackdropFrame
The backdrops one frame draws its floating surfaces over.
BackdropRecording
Records the surfaces drawn in the blurred material on this thread until Self::finish. Nests: an inner recording hides the outer one and restores it when it ends.
BackdropRegion
One surface’s backdrop, in the pixel space of the target it renders to.
BackdropStats
What BackdropBlur::prepare did, for frame profiling.
RecordedBackdrop
One surface drawn in the blurred material while a recording was active, in the recording’s coordinates.

Constants§

MAX_BACKDROP_REGIONS
Most surfaces one frame blurs behind. Later ones in the same frame are opaque: each region costs one extra render of everything below it.

Functions§

append_nested
scene.append(child, Some(transform)), carrying the floating surfaces drawn into child since nest_scene onto scene: what scene holds so far lies below them. Returns how many surfaces child carried. A cache that carried any must be redrawn on every recorded frame: reused, its surfaces would show the opaque material.
layer_scene
Floating surfaces drawn into scene sit on layer. The host names every scene it draws its frame into, so it can rebuild what lies below a surface: the scenes it composes under that layer, plus RecordedBackdrop::below. A host drawing one scene names it once.
nest_scene
child is a scene a widget draws now and composes into another scene afterwards with append_nested (a subtree cache). Floating surfaces drawn into it wait there and take what lies below them once it is appended. child must not move until then. A no-op outside a recording.