Skip to main content

Framebuffer

Struct Framebuffer 

Source
pub struct Framebuffer { /* private fields */ }
Expand description

Contiguous RGBA8 pixel framebuffer handed directly to OS surfaces or GPU upload paths.

Implementations§

Source§

impl Framebuffer

Pixel access, blitting, BGRA conversion, and deterministic hashing for Framebuffer.

Source

pub fn allocate(width: u32, height: u32) -> Self

Allocates a new zero-initialized RGBA8 framebuffer of (width, height).

§Arguments
  • u32 - Physical width in pixels.
  • u32 - Physical height in pixels.
§Returns
  • Self - Allocated framebuffer.
Source

pub fn resize(&mut self, width: u32, height: u32) -> bool

Resizes the framebuffer only when dimensions changed, avoiding per-frame reallocation.

§Arguments
  • &Self - Mutable framebuffer.
  • u32 - Target width.
  • u32 - Target height.
§Returns
  • bool - True if dimensions changed and buffer was resized.
Source

pub fn clear(&mut self, color: Color)

Fills the entire framebuffer with solid color using 32-byte wide auto-vectorized stores.

§Arguments
  • &Self - Mutable framebuffer.
  • Color - Clear color.
Source

pub fn fill_span(&mut self, x0: u32, x1: u32, y: u32, color: Color)

Fills or composites a contiguous horizontal pixel span [x0, x1) on row y.

§Arguments
  • &Self - Mutable framebuffer.
  • u32 - Inclusive start X pixel coordinate.
  • u32 - Exclusive end X pixel coordinate.
  • u32 - Row Y pixel coordinate.
  • Color - Foreground color to write or alpha-blend.
Source

pub fn fill_span_linear(&mut self, x0: u32, x1: u32, y: u32, color: Color)

Fills or composites a contiguous horizontal pixel span [x0, x1) on row y using gamma-correct linear-light blending.

§Arguments
  • &Self - Mutable framebuffer.
  • u32 - Inclusive start X pixel coordinate.
  • u32 - Exclusive end X pixel coordinate.
  • u32 - Row Y pixel coordinate.
  • Color - Foreground color to write or linear-light blend.
Source

pub fn blend_glyph_row( &mut self, dx: u32, dy: u32, coverage: &[u8], color: Color, ) -> usize

Blends a contiguous glyph alpha coverage row directly onto framebuffer row dy starting at dx.

§Arguments
  • &Self - Mutable framebuffer.
  • u32 - Destination starting X pixel coordinate.
  • u32 - Destination Y pixel coordinate.
  • &[u8] - Glyph coverage alpha bytes for the clipped horizontal slice.
  • Color - Foreground text color.
§Returns
  • usize - Number of non-zero coverage pixels shaded.
Source

pub fn get_pixel(&self, x: u32, y: u32) -> Option<Color>

Reads the RGBA Color at pixel coordinates (x, y).

§Arguments
  • &Self - Framebuffer reference.
  • u32 - X pixel coordinate.
  • u32 - Y pixel coordinate.
§Returns
  • Option<Color> - Pixel color if within bounds.
Source

pub fn blend_pixel_linear_dithered( &mut self, x: u32, y: u32, color: Color, dither: f32, )

Blends color over the pixel at (x, y) using gamma-correct linear-light compositing with optional sub-LSB dithering.

§Arguments
  • &Self - Mutable framebuffer.
  • u32 - X pixel coordinate.
  • u32 - Y pixel coordinate.
  • Color - Foreground color to composite.
  • f32 - Normalized dither offset in [-0.5, 0.5] to eliminate 8-bit banding.
Source

pub fn blend_pixel_f32_dithered( &mut self, x: u32, y: u32, color: Color, alpha_f: f32, dither: f32, )

Blends a foreground RGBA color with continuous floating-point alpha alpha_f in [0.0, 1.0] using linear-light compositing and IGN dithering.

§Arguments
  • &Self - Mutable framebuffer.
  • u32 - X pixel coordinate.
  • u32 - Y pixel coordinate.
  • Color - Foreground RGB tint (its own alpha is already folded into alpha_f).
  • f32 - Continuous opacity in [0.0, 1.0].
  • f32 - Normalized dither offset in [-0.5, 0.5].
Source

pub fn blend_pixel(&mut self, x: u32, y: u32, color: Color)

Blends color over the pixel at (x, y) using fast integer Porter-Duff source-over.

§Arguments
  • &Self - Mutable framebuffer.
  • u32 - X pixel coordinate.
  • u32 - Y pixel coordinate.
  • Color - Foreground color to composite.
Source

pub fn to_bgra_bytes(&self) -> Vec<u8> ⓘ

Converts RGBA8 pixels into BGRA8 byte order required by Win32 GDI, X11, and Cocoa/Metal.

§Arguments
  • &Self - Source RGBA8 framebuffer.
§Returns
  • Vec<u8> - Packed BGRA8 pixel buffer.
Source

pub fn fnv1a_hash(&self) -> u64

Computes a deterministic 64-bit 4-lane word-folded FNV-1a hash of the framebuffer pixels.

§Arguments
  • &Self - Framebuffer to hash.
§Returns
  • u64 - Deterministic endian-independent pixel hash.
Source

pub fn as_band_mut(&mut self) -> PixelBand<'_>

Borrows the entire framebuffer as a single zero-copy mutable PixelBand.

§Arguments
  • &Self - Mutable framebuffer.
§Returns
  • PixelBand<'_> - Full-surface mutable pixel band.
Source

pub fn split_bands_mut( &mut self, y0: u32, y1: u32, band_count: usize, ) -> Vec<PixelBand<'_>>

Splits rows [y0, y1) of this framebuffer into band_count disjoint mutable PixelBand slices for safe parallel rasterization.

§Arguments
  • &Self - Mutable framebuffer.
  • u32 - Inclusive starting physical Y row.
  • u32 - Exclusive ending physical Y row.
  • usize - Requested number of parallel bands.
§Returns
  • Vec<PixelBand<'_>> - Non-overlapping mutable horizontal bands covering [y0, y1).
Source§

impl Framebuffer

Source

pub fn get_width(&self) -> u32

Source

pub fn get_mut_width(&mut self) -> &mut u32

Source

pub fn set_width(&mut self, val: u32) -> &mut Self

Source

pub fn get_height(&self) -> u32

Source

pub fn get_mut_height(&mut self) -> &mut u32

Source

pub fn set_height(&mut self, val: u32) -> &mut Self

Source

pub fn get_pixels(&self) -> &Vec<u8> ⓘ

Source

pub fn get_mut_pixels(&mut self) -> &mut Vec<u8> ⓘ

Source

pub fn set_pixels(&mut self, val: Vec<u8>) -> &mut Self

Trait Implementations§

Source§

impl Clone for Framebuffer

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Framebuffer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Framebuffer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Framebuffer

Source§

impl PartialEq for Framebuffer

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Framebuffer

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.