Skip to main content

PixelFormat

Trait PixelFormat 

Source
pub trait PixelFormat {
    type ColorType;

    // Required methods
    fn width(&self) -> u32;
    fn height(&self) -> u32;
    fn blend_pixel(
        &mut self,
        x: i32,
        y: i32,
        c: &Self::ColorType,
        cover: CoverType,
    );
    fn blend_hline(
        &mut self,
        x: i32,
        y: i32,
        len: u32,
        c: &Self::ColorType,
        cover: CoverType,
    );
    fn blend_solid_hspan(
        &mut self,
        x: i32,
        y: i32,
        len: u32,
        c: &Self::ColorType,
        covers: &[CoverType],
    );
    fn copy_hline(&mut self, x: i32, y: i32, len: u32, c: &Self::ColorType);
    fn copy_pixel(&mut self, x: i32, y: i32, c: &Self::ColorType);
    fn blend_color_hspan(
        &mut self,
        x: i32,
        y: i32,
        len: u32,
        colors: &[Self::ColorType],
        covers: &[CoverType],
        cover: CoverType,
    );
    fn pixel(&self, x: i32, y: i32) -> Self::ColorType;
}
Expand description

Trait for pixel format renderers that can blend colors into a rendering buffer.

This is the abstraction layer between the renderer and the raw pixel data. Different implementations handle different pixel layouts (RGBA, RGB, gray) and blending modes (premultiplied, non-premultiplied).

Required Associated Types§

Required Methods§

Source

fn width(&self) -> u32

Source

fn height(&self) -> u32

Source

fn blend_pixel(&mut self, x: i32, y: i32, c: &Self::ColorType, cover: CoverType)

Blend a single pixel at (x, y) with color c and coverage cover.

Source

fn blend_hline( &mut self, x: i32, y: i32, len: u32, c: &Self::ColorType, cover: CoverType, )

Blend a horizontal line of len pixels at (x, y) with uniform color and coverage.

Source

fn blend_solid_hspan( &mut self, x: i32, y: i32, len: u32, c: &Self::ColorType, covers: &[CoverType], )

Blend a horizontal span of len pixels with per-pixel coverage values.

Source

fn copy_hline(&mut self, x: i32, y: i32, len: u32, c: &Self::ColorType)

Copy (overwrite) a horizontal line of len pixels with color c.

Source

fn copy_pixel(&mut self, x: i32, y: i32, c: &Self::ColorType)

Copy (overwrite) a single pixel at (x, y) with color c.

Source

fn blend_color_hspan( &mut self, x: i32, y: i32, len: u32, colors: &[Self::ColorType], covers: &[CoverType], cover: CoverType, )

Blend a horizontal span with per-pixel colors and optional per-pixel coverage.

If covers is non-empty, each pixel uses its corresponding coverage. If covers is empty, all pixels use the uniform cover value.

Source

fn pixel(&self, x: i32, y: i32) -> Self::ColorType

Get the pixel color at (x, y).

Implementors§