Skip to main content

AaBuf

Struct AaBuf 

Source
pub struct AaBuf {
    pub width: usize,
    pub height: usize,
    /* private fields */
}
Expand description

Anti-aliasing scratch buffer: 4 rows × (bitmap_width × 4) columns, 1 bit/pixel.

Bit packing is MSB-first (matching SplashBitmap Mono1 layout and the renderAALine / clipAALine code in SplashXPathScanner.cc):

  • Bit 7 of byte 0 is pixel 0 of the row.
  • Left-edge mask for pixel x: 0xff >> (x & 7).
  • Right-edge mask for pixel x1 (exclusive): (0xff00u16 >> (x1 & 7)) as u8.

height is always AA_SIZE (4). width is bitmap_width * AA_SIZE.

Fields§

§width: usize

Width in pixels (= bitmap_width × AA_SIZE).

§height: usize

Always AA_SIZE (4).

Implementations§

Source§

impl AaBuf

Source

pub fn new(bitmap_width: usize) -> Self

Create a new zeroed AA buffer for a bitmap of the given pixel width.

Source

pub const fn row_bytes(&self) -> usize

Bytes per row (= width.div_ceil(8)).

Source

pub fn clear(&mut self)

Clear all bits to 0.

Source

pub fn set_span(&mut self, row: usize, x0: usize, x1: usize)

Set pixels [x0, x1) to 1 in the given row.

x0 and x1 are clamped to [0, width]. No-op if x0 ≥ x1.

§Panics

Panics if row >= height.

Source

pub fn get_byte(&self, row: usize, byte_idx: usize) -> u8

Read one raw byte from the given row at byte index byte_idx.

§Panics

Panics if row >= height or byte_idx >= row_bytes().

Source

pub fn row_slice(&self, row: usize) -> &[u8]

Read-only access to a full row as a byte slice.

§Panics

Panics if row >= height.

Auto Trait Implementations§

§

impl Freeze for AaBuf

§

impl RefUnwindSafe for AaBuf

§

impl Send for AaBuf

§

impl Sync for AaBuf

§

impl Unpin for AaBuf

§

impl UnsafeUnpin for AaBuf

§

impl UnwindSafe for AaBuf

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.