Seregon/StratoSDK

StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.

Rust/27.3 KB/No license
crates/strato-ui-renderer/src/rendering/atlas/mod.rs
1mod allocator;
2mod manager;
3 
4pub(crate) use manager::{Manager, TextureId};
5 
6use pathfinder_geometry::rect::{RectF, RectI};
7use thiserror::Error;
8 
9/// A region of an atlas that has been allocated.
10#[derive(Copy, Debug, Clone)]
11pub(crate) struct AllocatedRegion {
12 /// The region of the atlas that was allocated in UV (texture) coordinates.
13 pub uv_region: RectF,
14 /// The region of the atlas that was allocated in screen coordinates.
15 pub pixel_region: RectI,
16}
17 
18/// Error that can happen when attempting to allocate an element into the atlas.
19#[derive(Error, Debug)]
20pub(crate) enum AllocationError {
21 /// Texture atlas is full.
22 #[error("Unable to insert; atlas is full")]
23 Full,
24 
25 /// The item cannot fit within a single texture.
26 #[error("Unable to insert; item is too large to fit into atlas")]
27 ItemTooLarge,
28}
29