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
impl ClipStack
Sourcepub fn scissor_clips(&self) -> u32
pub fn scissor_clips(&self) -> u32
Clips lowered to a scissor this frame.
Sourcepub fn mask_clips(&self) -> u32
pub fn mask_clips(&self) -> u32
Clips lowered to a coverage mask this frame.
Sourcepub fn mask_strips(&self) -> usize
pub fn mask_strips(&self) -> usize
Strips this frame’s coverage masks cost — zero for a frame whose clips all scissored.
Sourcepub fn mask(&self) -> Option<PathDataRef<'_>>
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.
Sourcepub fn blocks_everything(&self) -> bool
pub fn blocks_everything(&self) -> bool
Whether the current scissor admits nothing, so a draw need not be generated at all.
Sourcepub fn push_rect(
&mut self,
rect: Rect,
transform: Affine,
generator: &mut StripGenerator,
)
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.
Sourcepub fn push_rounded(
&mut self,
rect: Rect,
radii: RoundedRectRadii,
transform: Affine,
generator: &mut StripGenerator,
)
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.
Sourcepub fn pop(&mut self)
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.
Sourcepub fn clip_run(
&mut self,
storage: &mut StripStorage,
strip_start: usize,
alpha_start: usize,
)
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.