Trait tiny_skia::blitter::Blitter

source ·
pub trait Blitter {
    // Provided methods
    fn blit_h(&mut self, _x: u32, _y: u32, _width: NonZeroU32) { ... }
    fn blit_anti_h(
        &mut self,
        _x: u32,
        _y: u32,
        _antialias: &mut [u8],
        _runs: &mut [Option<NonZeroU16>],
    ) { ... }
    fn blit_v(&mut self, _x: u32, _y: u32, _height: NonZeroU32, _alpha: u8) { ... }
    fn blit_anti_h2(&mut self, _x: u32, _y: u32, _alpha0: u8, _alpha1: u8) { ... }
    fn blit_anti_v2(&mut self, _x: u32, _y: u32, _alpha0: u8, _alpha1: u8) { ... }
    fn blit_rect(&mut self, _rect: &ScreenIntRect) { ... }
    fn blit_mask(&mut self, _mask: &Mask, _clip: &ScreenIntRect) { ... }
}
Expand description

Blitter is responsible for actually writing pixels into memory.

Besides efficiency, they handle clipping and antialiasing. An object that implements Blitter contains all the context needed to generate pixels for the destination and how src/generated pixels map to the destination. The coordinates passed to the blit_* calls are in destination pixel space.

Provided Methods§

source

fn blit_h(&mut self, _x: u32, _y: u32, _width: NonZeroU32)

Blits a horizontal run of one or more pixels.

source

fn blit_anti_h( &mut self, _x: u32, _y: u32, _antialias: &mut [u8], _runs: &mut [Option<NonZeroU16>], )

Blits a horizontal run of antialiased pixels.

runs[] is a sparse zero-terminated run-length encoding of spans of constant alpha values.

The runs[] and antialias[] work together to represent long runs of pixels with the same alphas. The runs[] contains the number of pixels with the same alpha, and antialias[] contain the coverage value for that number of pixels. The runs[] (and antialias[]) are encoded in a clever way. The runs array is zero terminated, and has enough entries for each pixel plus one, in most cases some of the entries will not contain valid data. An entry in the runs array contains the number of pixels (np) that have the same alpha value. The next np value is found np entries away. For example, if runs[0] = 7, then the next valid entry will by at runs[7]. The runs array and antialias[] are coupled by index. So, if the np entry is at runs[45] = 12 then the alpha value can be found at antialias[45] = 0x88. This would mean to use an alpha value of 0x88 for the next 12 pixels starting at pixel 45.

source

fn blit_v(&mut self, _x: u32, _y: u32, _height: NonZeroU32, _alpha: u8)

Blits a vertical run of pixels with a constant alpha value.

source

fn blit_anti_h2(&mut self, _x: u32, _y: u32, _alpha0: u8, _alpha1: u8)

source

fn blit_anti_v2(&mut self, _x: u32, _y: u32, _alpha0: u8, _alpha1: u8)

source

fn blit_rect(&mut self, _rect: &ScreenIntRect)

Blits a solid rectangle one or more pixels wide.

source

fn blit_mask(&mut self, _mask: &Mask, _clip: &ScreenIntRect)

Blits a pattern of pixels defined by a rectangle-clipped mask.

Implementors§