pub trait CompositableRegion {
    // Required methods
    fn size(&self) -> usize;
    fn row_range(&self) -> Range<isize>;
    fn blend_buffers<P: Pixel>(
        &self,
        src_fb: &Framebuffer<P>,
        dest_fb: &mut Framebuffer<P>,
        dest_coord: Coord,
        src_fb_row_range: Range<usize>
    ) -> Result<(), &'static str>;
}
Expand description

A CompositableRegion is an abstract region (i.e., a bounding box) that can optimize the compositing (blending) of one framebuffer into another framebuffer according to the specifics of the region’s shape. For example, a single 2-D point (Coord) offers no real room for optimization because only one pixel will be composited, but a rectangle does allow for optimization, as a large chunk of pixels can be composited all at once.

In addition, a CompositableRegion makes it easier for a compositor to only composite pixels in a subset of a given source framebuffer rather than forcing it to composite the whole framebuffer, which vastly improves performance.

Required Methods§

source

fn size(&self) -> usize

Returns the number of pixels in the region.

source

fn row_range(&self) -> Range<isize>

Returns the range of rows covered by this region, given as row indices where row 0 is the top row in the region.

source

fn blend_buffers<P: Pixel>( &self, src_fb: &Framebuffer<P>, dest_fb: &mut Framebuffer<P>, dest_coord: Coord, src_fb_row_range: Range<usize> ) -> Result<(), &'static str>

Blends the pixels in the source framebuffer src_fb within the range of rows (src_fb_row_range) into the pixels in the destination framebuffer dest_fb. The dest_coord is the coordinate in the destination buffer (relative to its top-left corner) where the src_fb will be composited (starting at the src_fb’s top-left corner). src_fb_row_range is the index range of rows in the source framebuffer to blend.

Implementations on Foreign Types§

source§

impl CompositableRegion for Rectangle

source§

fn row_range(&self) -> Range<isize>

source§

fn size(&self) -> usize

source§

fn blend_buffers<P: Pixel>( &self, src_fb: &Framebuffer<P>, dest_fb: &mut Framebuffer<P>, dest_coord: Coord, src_fb_row_range: Range<usize> ) -> Result<(), &'static str>

source§

impl CompositableRegion for Coord

source§

fn row_range(&self) -> Range<isize>

source§

fn size(&self) -> usize

source§

fn blend_buffers<P: Pixel>( &self, src_fb: &Framebuffer<P>, dest_fb: &mut Framebuffer<P>, dest_coord: Coord, _src_fb_row_range: Range<usize> ) -> Result<(), &'static str>

Implementors§