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
impl DirtyRegion
Sourcepub fn new(fb_width: u32, fb_height: u32, tile_size: u32) -> Self
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.
Sourcepub fn mark_rect(
&mut self,
x: u32,
y: u32,
width: u32,
height: u32,
tile_size: u32,
)
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.
Sourcepub fn mark_tile(&mut self, tx: u32, ty: u32)
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.
Sourcepub fn is_tile_dirty(&self, tx: u32, ty: u32) -> bool
pub fn is_tile_dirty(&self, tx: u32, ty: u32) -> bool
Return true if the tile at (tx, ty) needs to be re-rendered.
Sourcepub fn clear_all(&mut self)
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.
Sourcepub fn invalidate_all(&mut self)
pub fn invalidate_all(&mut self)
Mark every tile as dirty.
Use after a resize or any full framebuffer invalidation.
Sourcepub fn dirty_tiles(&self) -> impl Iterator<Item = (u32, u32)> + '_
pub fn dirty_tiles(&self) -> impl Iterator<Item = (u32, u32)> + '_
Iterate over the (tx, ty) coordinates of all dirty tiles.
Sourcepub fn dirty_count(&self) -> usize
pub fn dirty_count(&self) -> usize
Return the number of tiles currently marked dirty.
Sourcepub fn total_tiles(&self) -> usize
pub fn total_tiles(&self) -> usize
Return the total number of tiles in the framebuffer.
Trait Implementations§
Source§impl Clone for DirtyRegion
impl Clone for DirtyRegion
Source§fn clone(&self) -> DirtyRegion
fn clone(&self) -> DirtyRegion
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for DirtyRegion
impl RefUnwindSafe for DirtyRegion
impl Send for DirtyRegion
impl Sync for DirtyRegion
impl Unpin for DirtyRegion
impl UnsafeUnpin for DirtyRegion
impl UnwindSafe for DirtyRegion
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
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>
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>
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