Skip to main content

ClipStack

Struct ClipStack 

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

The compiler’s clip stack: scissor rectangles and coverage masks, one stack.

Retained across frames like the strip generator it works beside — the mask context and the rewrite scratch are exactly the buffers a steady-state frame should be reusing. ClipStack::reset is what keeps it from carrying state between frames.

Implementations§

Source§

impl ClipStack

Source

pub fn new() -> Self

An empty stack, clipping nothing.

Source

pub fn reset(&mut self)

Drop every clip and counter, keeping the buffers.

Source

pub fn scissor_clips(&self) -> u32

Clips lowered to a scissor this frame.

Source

pub fn mask_clips(&self) -> u32

Clips lowered to a coverage mask this frame.

Source

pub fn mask_strips(&self) -> usize

Strips this frame’s coverage masks cost — zero for a frame whose clips all scissored.

Source

pub fn mask(&self) -> Option<PathDataRef<'_>>

The mask a draw generated now has to be clipped against, or None when no mask is on the stack.

Source

pub fn blocks_everything(&self) -> bool

Whether the current scissor admits nothing, so a draw need not be generated at all.

Source

pub fn push_rect( &mut self, rect: Rect, transform: Affine, generator: &mut StripGenerator, )

Push a rectangular clip: a scissor when the composed transform admits one, a coverage mask otherwise.

Source

pub fn push_rounded( &mut self, rect: Rect, radii: RoundedRectRadii, transform: Affine, generator: &mut StripGenerator, )

Push a clip with rounded corners.

Radii that are all square describe a plain rectangle, so such a clip takes the rectangular path and can still scissor: a caller spelling an unrounded clip through the rounded command pays nothing for the spelling.

Source

pub fn pop(&mut self)

Pop the most recent clip.

A pop with nothing to pop is ignored. A display list is recorded by a widget tree that can be unbalanced, and an unbalanced pop must not be able to lift a clip a sibling still relies on — nor to underflow the mask context, which would be a panic on the frame path.

Source

pub fn clip_run( &mut self, storage: &mut StripStorage, strip_start: usize, alpha_start: usize, )

Rewrite the strip run a draw just generated so nothing outside the scissor survives.

strip_start and alpha_start are storage’s two lengths from immediately before the draw generated, so everything past them belongs to this draw alone and can be replaced wholesale. The rewrite reclaims the coverage it drops — the original bytes are truncated away and only the kept ones re-appended — so a clipped frame’s alpha buffer stays proportional to what it actually paints.

A run that needs no change is left exactly as it was, which is the whole unclipped case and most of the clipped one.

Trait Implementations§

Source§

impl Debug for ClipStack

Source§

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

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

impl Default for ClipStack

Source§

fn default() -> Self

Returns the “default value” for a type. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,