⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

ShelfAllocator

Struct ShelfAllocator 

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

Bin-packing shelf allocator for a texture atlas.

Allocates rectangular regions from a fixed-size atlas using the shelf (skyline) algorithm. Shelves are created lazily as needed.

Implementations§

Source§

impl ShelfAllocator

Source

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

Create a new shelf allocator for an atlas of the given dimensions.

Source

pub fn width(&self) -> u32

Atlas width.

Source

pub fn height(&self) -> u32

Atlas height.

Source

pub fn allocation_count(&self) -> u32

Number of live allocations.

Source

pub fn allocate(&mut self, width: u32, height: u32) -> Option<AtlasRegion>

Allocate a region of width x height pixels.

Returns None if the atlas is full.

Source

pub fn deallocate(&mut self, region: &AtlasRegion)

Deallocate a previously allocated region.

The region is returned to its shelf for reuse.

Source

pub fn shelf_count(&self) -> usize

Total number of shelves created.

Source

pub fn utilisation_percent(&self) -> u32

Fraction of atlas height used, as a percentage (0-100).

Source

pub fn reset(&mut self)

Reset the allocator, freeing all regions.

Trait Implementations§

Source§

impl Debug for ShelfAllocator

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for ShelfAllocator

§

impl RefUnwindSafe for ShelfAllocator

§

impl Send for ShelfAllocator

§

impl Sync for ShelfAllocator

§

impl Unpin for ShelfAllocator

§

impl UnwindSafe for ShelfAllocator

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.