pub struct MultiAtlasManager {
atlases: Vec<Atlas>,
config: AtlasConfig,
round_robin_counter: usize,
}Expand description
Manages multiple texture atlases.
Fields§
§atlases: Vec<Atlas>All atlases managed by this instance.
config: AtlasConfigConfiguration for atlas management.
round_robin_counter: usizeRound-robin counter for allocation strategy.
Implementations§
Source§impl MultiAtlasManager
impl MultiAtlasManager
Sourcepub fn new(config: AtlasConfig) -> Self
pub fn new(config: AtlasConfig) -> Self
Create a new multi-atlas manager with the given configuration.
Sourcepub fn config(&self) -> &AtlasConfig
pub fn config(&self) -> &AtlasConfig
Get the current configuration.
Sourcepub fn create_atlas(&mut self) -> Result<AtlasId, AtlasError>
pub fn create_atlas(&mut self) -> Result<AtlasId, AtlasError>
Create a new atlas and return its ID.
Sourcepub fn next_atlas_id(&self) -> u32
pub fn next_atlas_id(&self) -> u32
Get the next available atlas ID.
Sourcepub fn try_allocate(
&mut self,
width: u32,
height: u32,
) -> Result<AtlasAllocation, AtlasError>
pub fn try_allocate( &mut self, width: u32, height: u32, ) -> Result<AtlasAllocation, AtlasError>
Try to allocate space for an image with the given dimensions.
Sourcepub fn try_allocate_excluding(
&mut self,
width: u32,
height: u32,
exclude_atlas_id: Option<AtlasId>,
) -> Result<AtlasAllocation, AtlasError>
pub fn try_allocate_excluding( &mut self, width: u32, height: u32, exclude_atlas_id: Option<AtlasId>, ) -> Result<AtlasAllocation, AtlasError>
Try to allocate space for an image with the given dimensions, optionally excluding a specific atlas.
fn space_diagnostics(&self, width: u32, height: u32) -> AtlasSpaceDiagnostics
fn no_space_available(&self, width: u32, height: u32) -> AtlasError
fn atlas_limit_reached(&self, width: u32, height: u32) -> AtlasError
Sourcefn allocate_first_fit(
&mut self,
width: u32,
height: u32,
exclude_atlas_id: Option<AtlasId>,
) -> Result<AtlasAllocation, AtlasError>
fn allocate_first_fit( &mut self, width: u32, height: u32, exclude_atlas_id: Option<AtlasId>, ) -> Result<AtlasAllocation, AtlasError>
Allocate using first-fit strategy: try atlases in order until one has space.
Sourcefn allocate_best_fit(
&mut self,
width: u32,
height: u32,
exclude_atlas_id: Option<AtlasId>,
) -> Result<AtlasAllocation, AtlasError>
fn allocate_best_fit( &mut self, width: u32, height: u32, exclude_atlas_id: Option<AtlasId>, ) -> Result<AtlasAllocation, AtlasError>
Allocate using best-fit strategy: choose the atlas with the smallest remaining space that can fit the image.
Sourcefn allocate_least_used(
&mut self,
width: u32,
height: u32,
exclude_atlas_id: Option<AtlasId>,
) -> Result<AtlasAllocation, AtlasError>
fn allocate_least_used( &mut self, width: u32, height: u32, exclude_atlas_id: Option<AtlasId>, ) -> Result<AtlasAllocation, AtlasError>
Allocate using least-used strategy: prefer the atlas with the lowest usage percentage.
Sourcefn allocate_round_robin(
&mut self,
width: u32,
height: u32,
exclude_atlas_id: Option<AtlasId>,
) -> Result<AtlasAllocation, AtlasError>
fn allocate_round_robin( &mut self, width: u32, height: u32, exclude_atlas_id: Option<AtlasId>, ) -> Result<AtlasAllocation, AtlasError>
Allocate using round-robin strategy: cycle through atlases using a round-robin counter.
Sourcepub fn deallocate(
&mut self,
atlas_id: AtlasId,
alloc_id: AllocId,
width: u32,
height: u32,
) -> Result<(), AtlasError>
pub fn deallocate( &mut self, atlas_id: AtlasId, alloc_id: AllocId, width: u32, height: u32, ) -> Result<(), AtlasError>
Deallocate space in the specified atlas.
Sourcepub fn atlas_stats(&self) -> Vec<(AtlasId, &AtlasUsageStats)>
pub fn atlas_stats(&self) -> Vec<(AtlasId, &AtlasUsageStats)>
Get statistics for all atlases.
Sourcepub fn atlas_count(&self) -> usize
pub fn atlas_count(&self) -> usize
Get the number of atlases.