pub struct TileLayout {
pub config: TileConfig,
pub tiles: Vec<TileRegion>,
}Expand description
A grid of TileRegions computed from a TileConfig.
The last tile in each row/column absorbs any remainder pixels so the union of all tiles exactly covers the full frame with no overlap.
use oximedia_codec::tile_encoder::{TileConfig, TileLayout};
let cfg = TileConfig::new()
.tile_cols(2)
.tile_rows(2)
.frame_width(100)
.frame_height(100);
let layout = TileLayout::new(cfg);
assert_eq!(layout.tile_count(), 4);
// All tiles together cover 100×100 pixels.
let total: u64 = layout.tiles().iter().map(|t| t.area()).sum();
assert_eq!(total, 100 * 100);Fields§
§config: TileConfigThe configuration used to build this layout.
tiles: Vec<TileRegion>All tile regions in raster order (row-major).
Implementations§
Source§impl TileLayout
impl TileLayout
Sourcepub fn new(config: TileConfig) -> Self
pub fn new(config: TileConfig) -> Self
Compute a TileLayout from config.
Tile boundaries are computed as frame_width / tile_cols (integer
division); the last column and last row absorb the remainder pixels.
Sourcepub fn tile_count(&self) -> usize
pub fn tile_count(&self) -> usize
Total number of tiles.
Sourcepub fn get_tile(&self, col: u32, row: u32) -> Option<&TileRegion>
pub fn get_tile(&self, col: u32, row: u32) -> Option<&TileRegion>
Return the tile at grid position (col, row), or None if out of bounds.
Sourcepub fn tiles(&self) -> &[TileRegion]
pub fn tiles(&self) -> &[TileRegion]
All tile regions in raster order.
Sourcepub fn tile_for_pixel(&self, px: u32, py: u32) -> Option<&TileRegion>
pub fn tile_for_pixel(&self, px: u32, py: u32) -> Option<&TileRegion>
Find which tile contains the pixel (px, py).
Returns None if the pixel is outside the frame.
Trait Implementations§
Source§impl Clone for TileLayout
impl Clone for TileLayout
Source§fn clone(&self) -> TileLayout
fn clone(&self) -> TileLayout
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TileLayout
impl RefUnwindSafe for TileLayout
impl Send for TileLayout
impl Sync for TileLayout
impl Unpin for TileLayout
impl UnsafeUnpin for TileLayout
impl UnwindSafe for TileLayout
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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