Struct webrender::texture_pack::guillotine::GuillotineAllocator
source · pub struct GuillotineAllocator {
bins: [Bin; 3],
}
Expand description
A texture allocator using the guillotine algorithm.
See sections 2.2 and 2.2.5 in “A Thousand Ways to Pack the Bin - A Practical Approach to Two- Dimensional Rectangle Bin Packing”:
http://clb.demon.fi/files/RectangleBinPack.pdf
This approach was chosen because of its simplicity and good performance.
Note: the allocations are spread across multiple textures, and also are binned orthogonally in order to speed up the search.
Fields§
§bins: [Bin; 3]
Implementations§
source§impl GuillotineAllocator
impl GuillotineAllocator
pub fn new(initial_size: Option<DeviceIntSize>) -> Self
fn push(&mut self, slice: FreeRectSlice, rect: DeviceIntRect)
sourcefn find_index_of_best_rect(
&self,
requested_dimensions: &DeviceIntSize,
) -> Option<(FreeListBin, FreeListIndex)>
fn find_index_of_best_rect( &self, requested_dimensions: &DeviceIntSize, ) -> Option<(FreeListBin, FreeListIndex)>
Find a suitable rect in the free list. We choose the first fit.
fn split_guillotine( &mut self, chosen: &FreeRect, requested_dimensions: &DeviceIntSize, )
pub fn allocate( &mut self, requested_dimensions: &DeviceIntSize, ) -> Option<(FreeRectSlice, DeviceIntPoint)>
sourcepub fn extend(
&mut self,
slice: FreeRectSlice,
total_size: DeviceIntSize,
requested_dimensions: DeviceIntSize,
)
pub fn extend( &mut self, slice: FreeRectSlice, total_size: DeviceIntSize, requested_dimensions: DeviceIntSize, )
Add a new slice to the allocator, and immediately allocate a rect from it.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GuillotineAllocator
impl RefUnwindSafe for GuillotineAllocator
impl Send for GuillotineAllocator
impl Sync for GuillotineAllocator
impl Unpin for GuillotineAllocator
impl UnwindSafe for GuillotineAllocator
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more