14 releases

0.6.2 Aug 10, 2021
0.6.1 May 16, 2021
0.6.0 Aug 7, 2020
0.5.2 Jun 5, 2020
0.3.0 Mar 30, 2019

#151 in Graphics APIs

Download history 15829/week @ 2023-12-13 13537/week @ 2023-12-20 14487/week @ 2023-12-27 16710/week @ 2024-01-03 20118/week @ 2024-01-10 27076/week @ 2024-01-17 22175/week @ 2024-01-24 22671/week @ 2024-01-31 20968/week @ 2024-02-07 24185/week @ 2024-02-14 25474/week @ 2024-02-21 24083/week @ 2024-02-28 23976/week @ 2024-03-06 21159/week @ 2024-03-13 22666/week @ 2024-03-20 19157/week @ 2024-03-27

91,185 downloads per month
Used in 389 crates (9 directly)

MIT/Apache

82KB
1.5K SLoC

Guillotière

Travis Build Status documentation

A dynamic texture atlas allocator with fast deallocation and rectangle coalescing.

Motivation

The ability to dynamically batch textures together is important for some graphics rendering scenarios (for example WebRender). A challenging aspect of dynamic atlas allocation is the need to coalesce free rectangles after deallocation to defragment the available space. Some atlas allocators perform this task by examining all possible pairs of free rectangles and test if they can be merged, which is prohibitively expensive for real-time applications.

Guillotière solves this problem by internally maintaining a data structure that allows constant time access to neighbor rectangles and greatly speeds up the coalesing operation.

The details of how this works are explained in the AtlasAllocator documentation.

Example

use guillotiere::*;

let mut atlas = AtlasAllocator::new(size2(1000, 1000));

let a = atlas.allocate(size2(100, 1000)).unwrap();
let b = atlas.allocate(size2(900, 200)).unwrap();

atlas.deallocate(a.id);

let c = atlas.allocate(size2(300, 200)).unwrap();

assert_eq!(c.rectangle, atlas[c.id]);

atlas.deallocate(c.id);
atlas.deallocate(b.id);

License

Licensed under either of

at your option.

Dependencies

~0.6–0.8MB
~19K SLoC