Skip to main content

RectSet

Struct RectSet 

Source
pub struct RectSet<const N: usize = DEFAULT_SET_CAPACITY> {
    rects: [Rect; N],
    len: usize,
}
Expand description

A fixed-capacity set of non-overlapping dirty rectangles.

Replacement for both DirtyRectSet and Damage. The rules are:

  • overlapping or edge-adjacent rectangles are merged, transitively;
  • when the set is full, the new rectangle is merged into the existing one whose union grows the least, so a single far-away rect cannot drag the presented area to the corner of the screen;
  • insertion never allocates and never fails.

Fields§

§rects: [Rect; N]§len: usize

Implementations§

Source§

impl<const N: usize> RectSet<N>

Source

pub const fn empty() -> Self

Source

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

Insert a rectangle. Empty rectangles are ignored.

Source

pub fn include_set<const M: usize>(&mut self, other: &RectSet<M>)

Insert every rectangle of another set.

The capacities may differ: this keeps callers such as the kernel Presenter from silently depending on two constants staying equal.

Source

pub fn clear(&mut self)

Source

pub fn is_empty(&self) -> bool

Source

pub fn len(&self) -> usize

Source

pub fn spare(&self) -> usize

Number of slots still available before merging starts.

Source

pub fn capacity(&self) -> usize

Source

pub fn iter(&self) -> RectSetIter<'_, N> ⓘ

Source

pub fn bounds(&self) -> Rect

Bounding box of every rectangle, or Rect::EMPTY.

Source

pub fn total_area(&self) -> u64

Sum of the areas. Adjacent rects are merged, so this does not double-count the common case.

Trait Implementations§

Source§

impl<const N: usize> Clone for RectSet<N>

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<const N: usize> Copy for RectSet<N>

Source§

impl<const N: usize> Debug for RectSet<N>

Source§

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

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

impl<const N: usize> Default for RectSet<N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const N: usize> IntoIterator for RectSet<N>

Source§

type Item = Rect

The type of the elements being iterated over.
Source§

type IntoIter = RectSetOwnedIter<N>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, const N: usize> IntoIterator for &'a RectSet<N>

Source§

type Item = Rect

The type of the elements being iterated over.
Source§

type IntoIter = RectSetIter<'a, N>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<const N: usize> Forget for RectSet<N>

§

impl<const N: usize> Freeze for RectSet<N>
where [Rect; N]: Freeze,

§

impl<const N: usize> Move for RectSet<N>

§

impl<const N: usize> RefUnwindSafe for RectSet<N>
where [Rect; N]: RefUnwindSafe,

§

impl<const N: usize> Send for RectSet<N>
where [Rect; N]: Send,

§

impl<const N: usize> Sync for RectSet<N>
where [Rect; N]: Sync,

§

impl<const N: usize> Unpin for RectSet<N>
where [Rect; N]: Unpin,

§

impl<const N: usize> UnsafeUnpin for RectSet<N>
where [Rect; N]: UnsafeUnpin,

§

impl<const N: usize> UnwindSafe for RectSet<N>
where [Rect; N]: UnwindSafe,

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.