Skip to main content

GridWriter

Struct GridWriter 

Source
pub struct GridWriter<'a, T> { /* private fields */ }
Expand description

Concurrent writer for a buffer partitioned into a regular tile grid.

Tiles of a grid share buffer rows, so chunks_mut cannot hand them out to threads. GridWriter lets each thread claim a tile and write its rows directly into the final image. Soundness rests on two checked invariants: (1) every claim is recorded in an atomic flag, so a tile can be claimed at most once; (2) grid tiles cover pairwise-disjoint rectangles, and every row slice handed out is clipped to its tile, so no two claims alias.

The buffer may cover a sub-rectangle (origin, width x height) of the grid’s coordinate space, which is how region decoding writes only intersecting tiles.

Implementations§

Source§

impl<'a, T: Send> GridWriter<'a, T>

Source

pub fn new( buf: &'a mut [T], width: u32, height: u32, cpp: u32, origin: (u32, u32), tile_w: u32, tile_h: u32, grid_w: u32, grid_h: u32, ) -> Option<Self>

buf holds width x height pixels of cpp samples, covering grid coordinates starting at origin. The grid has tile_w x tile_h tiles anchored at (0, 0) and spans grid_w x grid_h pixels.

Source

pub fn tiles_x(&self) -> u32

Source

pub fn tiles_y(&self) -> u32

Source

pub fn claim(&self, tx: u32, ty: u32) -> Option<TileMut<'_, 'a, T>>

Claim tile (tx, ty). Returns None if out of range, already claimed, or if the tile does not intersect the buffer area.

Trait Implementations§

Source§

impl<T: Send> Send for GridWriter<'_, T>

Source§

impl<T: Send> Sync for GridWriter<'_, T>

Auto Trait Implementations§

§

impl<'a, T> !UnwindSafe for GridWriter<'a, T>

§

impl<'a, T> Freeze for GridWriter<'a, T>
where *mut T: Freeze, PhantomData<&'a mut [T]>: Freeze,

§

impl<'a, T> RefUnwindSafe for GridWriter<'a, T>

§

impl<'a, T> Unpin for GridWriter<'a, T>
where *mut T: Unpin, PhantomData<&'a mut [T]>: Unpin,

§

impl<'a, T> UnsafeUnpin for GridWriter<'a, T>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.