Skip to main content

TileLayout

Struct TileLayout 

Source
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: TileConfig

The configuration used to build this layout.

§tiles: Vec<TileRegion>

All tile regions in raster order (row-major).

Implementations§

Source§

impl TileLayout

Source

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.

Source

pub fn tile_count(&self) -> usize

Total number of tiles.

Source

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.

Source

pub fn tiles(&self) -> &[TileRegion]

All tile regions in raster order.

Source

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

Source§

fn clone(&self) -> TileLayout

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TileLayout

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.