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
impl CanvasDamage
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if this damage represents an empty rectangular region.
Sourcepub fn rect(&self) -> Option<CanvasRect>
pub fn rect(&self) -> Option<CanvasRect>
Returns the localized damage rectangle if this is CanvasDamage::Rect.
Sourcepub fn union(&self, other: &CanvasDamage) -> CanvasDamage
pub fn union(&self, other: &CanvasDamage) -> CanvasDamage
Computes the conservative union of two damage specifications.
Fullunion anything yieldsFull.Rect(r1)unionRect(r2)yields the minimal enclosing bounding box.
Sourcepub fn union_rect(&self, rect: CanvasRect) -> CanvasDamage
pub fn union_rect(&self, rect: CanvasRect) -> CanvasDamage
Computes the union of this damage with a rectangle.
Sourcepub fn area(&self) -> Option<u64>
pub fn area(&self) -> Option<u64>
Returns the pixel area of the damage rectangle, or None if this is CanvasDamage::Full.
Sourcepub fn should_promote_to_full(
&self,
canvas_width: u32,
canvas_height: u32,
threshold_ratio: f64,
) -> bool
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.