Skip to content

Compositor Layer Design

eschweic edited this page Sep 17, 2013 · 2 revisions

Compositor layers are pieces of a webpage that move independently of one another. These could be iframes, animations, or any element with a scrollbar. Each compositor layer owns a quadtree, which stores the image buffers that are painted to the screen.

Compositor layers are organized in a tree structure. The parent layer is managed by mod.rs, whereas all internal nodes are managed by their parents. "Managed" in this context means controlling the relative position of the layer's clipping rect, as well as which functions are passed to it. At the top level, managing also includes zooming (for most operations, compositor layers are blind to the current zoom scale and work in page coordinates). Layers themselves are responsible for keeping track of their own page size and scroll offset.

The benefit of this setup is that as far as any compositor layer knows, it has no parent. This means that all coordinates are local, as if the layer is positioned at the top left of the entire page.

The constellation initializes all compositor layers at once, but these layers may not have page sizes or scissor (clipping) bounds, which are both required to be displayed. Therefore, these layers are initialized as hidden, and are unhidden as sizes are computed by layout. As soon as a child layer has both, it is unhidden by its parent.

As child layers are unhidden, the quadtree in its parent's compositor layer is notified of the position of these children. These regions in the quadtree are marked as Hidden and are not rendered. If the child layer moves or is deleted, the parent is responisble for updating its quadtree appropriately: marking Hidden nodes as Normal and setting a new Hidden region as necessary.

Compositor layers ask their renderer for required tiles directly. Compositor layers also send unused buffers back to their renderer in this way. However, rendered tiles are sent to the compositor task and propagated down the tree until the correct layer is found (as determined by pipeline.id). This should probably be changed at some point.

Clone this wiki locally