Skip to main content

DirtyRegion

Struct DirtyRegion 

Source
pub struct DirtyRegion { /* private fields */ }
Expand description

Tracks which tiles of the framebuffer have been modified since the last clear, enabling callers to skip re-compositing unchanged tiles.

On construction every tile is marked dirty so the first repaint always paints the full surface. After DirtyRegion::clear_all only tiles touched by DirtyRegion::mark_rect or DirtyRegion::mark_tile are reported as dirty.

Implementations§

Source§

impl DirtyRegion

Source

pub fn new(fb_width: u32, fb_height: u32, tile_size: u32) -> Self

Create a new DirtyRegion for a framebuffer of fb_width × fb_height pixels using tile_size-pixel tiles.

All tiles start dirty so the first frame is always fully rendered.

Source

pub fn mark_rect( &mut self, x: u32, y: u32, width: u32, height: u32, tile_size: u32, )

Mark the pixel rectangle (x, y, width, height) as dirty, dirtying every tile that overlaps it.

If all tiles are already dirty this is a no-op.

Source

pub fn mark_tile(&mut self, tx: u32, ty: u32)

Mark the single tile at (tx, ty) as dirty.

If all tiles are already dirty this is a no-op.

Source

pub fn is_tile_dirty(&self, tx: u32, ty: u32) -> bool

Return true if the tile at (tx, ty) needs to be re-rendered.

Source

pub fn clear_all(&mut self)

Clear all dirty flags after a completed repaint.

After this call DirtyRegion::dirty_count returns 0 until a tile is explicitly marked dirty again.

Source

pub fn invalidate_all(&mut self)

Mark every tile as dirty.

Use after a resize or any full framebuffer invalidation.

Source

pub fn dirty_tiles(&self) -> impl Iterator<Item = (u32, u32)> + '_

Iterate over the (tx, ty) coordinates of all dirty tiles.

Source

pub fn dirty_count(&self) -> usize

Return the number of tiles currently marked dirty.

Source

pub fn total_tiles(&self) -> usize

Return the total number of tiles in the framebuffer.

Trait Implementations§

Source§

impl Clone for DirtyRegion

Source§

fn clone(&self) -> DirtyRegion

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for DirtyRegion

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.