Skip to main content

DamageTracker

Struct DamageTracker 

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

Accumulates per-frame damage and resolves it against buffer age.

One tracker per surface. Call add as things change, resolve once you know the age of the buffer you got, and end_frame after presenting.

Implementations§

Source§

impl DamageTracker

Source

pub fn new(size: Size) -> Self

Creates a tracker for a surface of size, starting fully damaged.

Source

pub const fn surface_size(&self) -> Size

Surface extent damage is clipped against.

Source

pub fn resize(&mut self, size: Size)

Resizes the surface. Every buffer in flight is now the wrong shape, so all history is discarded and the next frame is a full repaint.

Source

pub fn add(&mut self, rect: Rect)

Marks a region of the current frame dirty. Clipped to the surface.

Source

pub fn add_full(&mut self)

Marks the whole surface dirty for this frame.

Source

pub fn is_clean(&self) -> bool

Returns true if nothing has been marked dirty this frame.

Source

pub fn pending(&self) -> &[Rect]

What has been marked dirty this frame, before any buffer age widens it.

Distinct from resolved, which is the answer resolve last gave and therefore describes the previous frame until this one is resolved. This is what a caller wants when it has to hand one tracker’s damage to another before either has seen a buffer — a tree inside a backend’s event loop, which is exactly the arrangement DeniseApp::update puts them in.

Empty when the whole surface is marked: there is no rectangle list in that case, and is_clean is how to tell the two apart.

Source

pub fn resolve(&mut self, age: BufferAge) -> &[Rect]

Damage that must actually be repainted into a buffer of the given age.

For BufferAge::Frames(n) this is the union of the last n frames’ damage, current frame included. For BufferAge::Undefined, or an age deeper than MAX_TRACKED_FRAMES, it is the whole surface.

Pass the result to both the renderer and crate::Surface::present.

Source

pub fn resolved(&self) -> &[Rect]

The slice most recently returned by resolve.

Source

pub fn end_frame(&mut self)

Advances to the next frame, retiring the oldest history slot.

Trait Implementations§

Source§

impl Clone for DamageTracker

Source§

fn clone(&self) -> DamageTracker

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 DamageTracker

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> 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.