Skip to main content

CanvasDamage

Enum CanvasDamage 

Source
pub enum CanvasDamage {
    Full,
    Rect(CanvasRect),
}
Expand description

Describes the damaged region of a Canvas for repaint scheduling and partial updates.

Implements the invalidation contract.

Variants§

§

Full

The entire canvas area requires redraw.

§

Rect(CanvasRect)

A localized rectangular region in logical coordinates requires redraw.

Implementations§

Source§

impl CanvasDamage

Source

pub fn is_full(&self) -> bool

Returns true if this damage represents a full canvas repaint.

Source

pub fn is_empty(&self) -> bool

Returns true if this damage represents an empty rectangular region.

Source

pub fn rect(&self) -> Option<CanvasRect>

Returns the localized damage rectangle if this is CanvasDamage::Rect.

Source

pub fn union(&self, other: &CanvasDamage) -> CanvasDamage

Computes the conservative union of two damage specifications.

  • Full union anything yields Full.
  • Rect(r1) union Rect(r2) yields the minimal enclosing bounding box.
Source

pub fn union_rect(&self, rect: CanvasRect) -> CanvasDamage

Computes the union of this damage with a rectangle.

Source

pub fn area(&self) -> Option<u64>

Returns the pixel area of the damage rectangle, or None if this is CanvasDamage::Full.

Source

pub fn should_promote_to_full( &self, canvas_width: u32, canvas_height: u32, threshold_ratio: f64, ) -> bool

Evaluates whether this damage region should be promoted to CanvasDamage::Full.

Damage-scheduling rule: if the bounding box of accumulated rectangular damage exceeds the promotion threshold ratio (default 60%) of the total canvas area, partial rasterization overhead exceeds full redraw efficiency.

Trait Implementations§

Source§

impl Clone for CanvasDamage

Source§

fn clone(&self) -> Self

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 Copy for CanvasDamage

Source§

impl Debug for CanvasDamage

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for CanvasDamage

Source§

impl PartialEq for CanvasDamage

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CanvasDamage

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 = !

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.