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

#14 in Graphics APIs

Download history 29841/week @ 2024-08-13 23936/week @ 2024-08-20 26722/week @ 2024-08-27 27792/week @ 2024-09-03 22278/week @ 2024-09-10 26821/week @ 2024-09-17 28426/week @ 2024-09-24 28287/week @ 2024-10-01 25588/week @ 2024-10-08 22254/week @ 2024-10-15 19694/week @ 2024-10-22 20273/week @ 2024-10-29 20575/week @ 2024-11-05 18550/week @ 2024-11-12 18468/week @ 2024-11-19 17693/week @ 2024-11-26

79,664 downloads per month
Used in 539 crates (11 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