layers::prelude

Function render_subtree_to_buffer

Source
pub fn render_subtree_to_buffer(
    scene: Arc<Scene>,
    root: NodeRef,
    backdrop: Option<&Image>,
    context: Option<&mut DirectContext>,
) -> Option<SubtreeBuffer>
Expand description

Render a single subtree root into its own buffer, for an external compositor (e.g. a KMS/DRM plane). Re-renders only when the subtree’s content or the supplied backdrop changed since the last call for this root; otherwise returns the cached buffer (SubtreeBuffer::from_cache == true).

backdrop is the composite of the planes BELOW this one, in scene/global coordinates (the caller owns plane order and compositing — typically the stack of lower KMS framebuffers). It is used to bake any BackgroundBlur layers in the subtree: the blur samples this image so vibrancy reflects the real content behind the plane even though planes are rendered independently. Pass None for the bottom plane or a subtree with no blur.

Pass a GPU context for GPU-backed surfaces, or None for raster surfaces.

Note: if root is itself image_cache(true), cross-buffer blur is not applied to its descendants (the offscreen cache has its own coordinate space); render such subtrees without image_cache to get vibrancy.