Skip to main content

ClipRole

Enum ClipRole 

Source
pub enum ClipRole {
    Content,
    Narrow,
    Widen,
}
Expand description

What a draw does with the stencil buffer.

§Why the stencil holds a depth rather than a mask

The obvious encoding gives each clip a bit, which caps nesting at eight and makes intersecting two clips a per-bit affair. Storing the nesting depth instead lets a clip stack of any size fit in the same eight bits, and makes the test a single comparison: content belongs to depth d and draws where the stencil holds d, which is true only where every clip down to that depth admitted the pixel.

It also makes undoing a clip a local operation. Because a stack unwinds in the order it was built, no pixel can hold more than the depth being left, so stepping back is a decrement rather than a recomputation from the remaining clips.

Variants§

§

Content

Draw color where the stencil already matches. Leaves the stencil alone.

§

Narrow

Narrow the clip: step the stencil forward where it matches and this draw covers. Writes no color.

The geometry must be a triangulation of the clip region rather than an overlapping set, since a pixel covered twice would step forward twice and stop matching anything. The fill tessellator produces exactly that, which is what lets this be a plain increment instead of the parity trick an overlapping fan would need.

§

Widen

Widen the clip back: step the stencil back where it matches. Writes no color.

Implementations§

Source§

impl ClipRole

Source

pub const fn writes_color(self) -> bool

Whether this role writes to the color attachment.

Source

pub const fn writes_stencil(self) -> bool

Whether this role modifies the stencil.

Trait Implementations§

Source§

impl Clone for ClipRole

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 ClipRole

Source§

impl Debug for ClipRole

Source§

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

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

impl Default for ClipRole

Source§

fn default() -> Self

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

impl Eq for ClipRole

Source§

impl Hash for ClipRole

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ClipRole

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 ClipRole

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.