Struct tiny_skia::alpha_runs::AlphaRuns

source ·
pub struct AlphaRuns {
    pub runs: Vec<Option<NonZeroU16>>,
    pub alpha: Vec<u8>,
}
Expand description

Sparse array of run-length-encoded alpha (supersampling coverage) values.

Sparseness allows us to independently compose several paths into the same AlphaRuns buffer.

Fields§

§runs: Vec<Option<NonZeroU16>>§alpha: Vec<u8>

Implementations§

source§

impl AlphaRuns

source

pub fn new(width: NonZeroU32) -> Self

source

pub fn catch_overflow(alpha: u16) -> u8

Returns 0-255 given 0-256.

source

pub fn is_empty(&self) -> bool

Returns true if the scanline contains only a single run, of alpha value 0.

source

pub fn reset(&mut self, width: NonZeroU32)

Reinitialize for a new scanline.

source

pub fn add( &mut self, x: u32, start_alpha: u8, middle_count: usize, stop_alpha: u8, max_value: u8, offset_x: usize, ) -> usize

Insert into the buffer a run starting at (x-offset_x).

if start_alpha > 0 one pixel with value += start_alpha, max 255 if middle_count > 0 middle_count pixels with value += max_value if stop_alpha > 0 one pixel with value += stop_alpha

Returns the offset_x value that should be passed on the next call, assuming we’re on the same scanline. If the caller is switching scanlines, then offset_x should be 0 when this is called.

source

fn break_run( runs: &mut [Option<NonZeroU16>], alpha: &mut [u8], x: usize, count: usize, )

Break the runs in the buffer at offsets x and x+count, properly updating the runs to the right and left.

i.e. from the state AAAABBBB, run-length encoded as A4B4, break_run(…, 2, 5) would produce AAAABBBB rle as A2A2B3B1. Allows add() to sum another run to some of the new sub-runs. i.e. adding ..CCCCC. would produce AADDEEEB, rle as A2D2E3B1.

source

pub fn break_at(alpha: &mut [u8], runs: &mut [Option<NonZeroU16>], x: i32)

Cut (at offset x in the buffer) a run into two shorter runs with matching alpha values.

Used by the RectClipBlitter to trim a RLE encoding to match the clipping rectangle.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.