layers::engine::occlusion

Function compute_occlusion_aware_damage

Source
pub fn compute_occlusion_aware_damage(
    root: NodeRef,
    arena: &Arena<SceneNode>,
    per_node_damage: &HashMap<NodeRef, Rect>,
) -> Rect
Expand description

Fold occlusion into per-node damage to produce an occlusion-aware scene damage rect.

Walks the subtree rooted at root front-to-back with a running skia::Region that accumulates the bounds of every valid opaque occluder seen so far. For each node with damage, the running region is subtracted from the damage rect before it is unioned into the scene total. Nodes whose entire damage rect is covered by the running region contribute nothing.

per_node_damage maps a node id to its global-coordinates damage rect as already computed by update_node_single. Nodes not present in the map are assumed to have no damage this frame.

Returns the bounding Rect of the resulting damage region, matching the legacy Engine::damage() return type so callers don’t have to change. The full pixel set is visible to the caller only via this bounding box — sufficient for the use case where downstream consumers clip/redraw a rectangular area.