[][src]Struct etagere::BucketedAtlasAllocator

pub struct BucketedAtlasAllocator { /* fields omitted */ }

A faster but less precise Shelf-packing dynamic texture atlas allocator, inspired by https://github.com/mapbox/shelf-pack/

Items are accumulated into buckets which are laid out in rows (shelves) of variable height. When allocating we first look for a suitable bucket. If none is found, a new shelf of the desired height is pushed.

Lifetime isn't tracked at item granularity. Instead, items are grouped into buckets and deallocation happens per bucket when all items of the buckets are removed. When the top-most shelf is empty, it is removed, potentially cascading into garbage-collecting the next shelf, etc.

This allocator works well when there are a lot of small items with similar sizes (typically, glyph atlases).

Implementations

impl BucketedAtlasAllocator[src]

pub fn with_options(size: Size, options: &AllocatorOptions) -> Self[src]

Create an atlas allocator with provided options.

pub fn new(size: Size) -> Self[src]

Create an atlas allocator with default options.

pub fn clear(&mut self)[src]

pub fn size(&self) -> Size[src]

pub fn is_empty(&self) -> bool[src]

pub fn allocate(&mut self, requested_size: Size) -> Option<Allocation>[src]

Allocate a rectangle in the atlas.

pub fn deallocate(&mut self, id: AllocId)[src]

Deallocate a rectangle in the atlas.

Space is only reclaimed when all items of the same bucket are deallocated.

pub fn dump_svg(&self, output: &mut dyn Write) -> Result<()>[src]

Dump a visual representation of the atlas in SVG format.

pub fn dump_into_svg(
    &self,
    rect: Option<&Rectangle>,
    output: &mut dyn Write
) -> Result<()>
[src]

Dump a visual representation of the atlas in SVG, omitting the beginning and end of the SVG document, so that it can be included in a larger document.

If a rectangle is provided, translate and scale the output to fit it.

Trait Implementations

impl Clone for BucketedAtlasAllocator[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.