pub trait Compositor {
    // Required method
    fn composite<'a, B: CompositableRegion + Clone, P: 'a + Pixel>(
        &mut self,
        src_fbs: impl IntoIterator<Item = FramebufferUpdates<'a, P>>,
        dest_fb: &mut Framebuffer<P>,
        dest_bounding_boxes: impl IntoIterator<Item = B> + Clone
    ) -> Result<(), &'static str>;
}
Expand description

A compositor composites (combines or blends) a series of “source” framebuffers onto a single “destination” framebuffer. The type parameter B allows a compositor to support multiple types of regions or “bounding boxes”, given by the trait bound CompositableRegion.

Required Methods§

source

fn composite<'a, B: CompositableRegion + Clone, P: 'a + Pixel>( &mut self, src_fbs: impl IntoIterator<Item = FramebufferUpdates<'a, P>>, dest_fb: &mut Framebuffer<P>, dest_bounding_boxes: impl IntoIterator<Item = B> + Clone ) -> Result<(), &'static str>

Composites the framebuffers in the list of source framebuffers src_fbs onto the destination framebuffer dest_fb.

Arguments
  • src_fbs: an iterator over the source framebuffers to be composited, along with where in the dest_fb they should be composited.
  • dest_fb: the destination framebuffer that will hold the source framebuffers to be composited.
  • dest_bounding_boxes: an iterator over bounding boxes that specify which regions in the destination framebuffer should be updated. For each source framebuffer in src_fbs, the compositor will iterate over every bounding box and find the corresponding region in that source framebuffer and then blend that region into the destination.

For example, if the window manager wants to draw a new partially-transparent window, it will pass the framebuffers for all existing windows plus the new window (in bottom-to-top order) to the compositor, in the argument src_fbs. The dest_fb would be the final framebuffer mapped to the display device (screen memory), and the bounding_boxes would be an iterator over just a single region in the final framebuffer where that new window will be located. When the source framebuffers are composited from bottom to top, the compositor will redraw the region of every source framebuffer that intersects with that bounding box.

For another example, suppose the window manager wants to draw a transparent mouse pointer on top of all windows. It will pass the framebuffers of existing windows as well as a top framebuffer that contains the mouse pointer image. In this case, the bounding_boxes could be the coordinates of all individual pixels in the mouse pointer image (expressed as coordinates in the final framebuffer).

Implementors§