pub struct ClipStack { /* private fields */ }Expand description
A push-down stack of intersecting clip rectangles.
Each push intersects the new rect with the current top and stores the
result. Callers are therefore always looking at the effective clip, never
the raw per-layer rect.
Implementations§
Source§impl ClipStack
impl ClipStack
Sourcepub fn push(&mut self, rect: ClipRect)
pub fn push(&mut self, rect: ClipRect)
Push a new clip rect, intersecting it with the current top.
If the stack is empty, rect is pushed directly. If the intersection
with the current top is empty, nothing is pushed and the stack is
unchanged (the new layer would clip everything away anyway; the caller
should balance pushes with pops regardless).
Sourcepub fn pop(&mut self)
pub fn pop(&mut self)
Pop the topmost clip rect. Does nothing (no panic) if the stack is empty.
Sourcepub fn current(&self) -> Option<&ClipRect>
pub fn current(&self) -> Option<&ClipRect>
Return the current (topmost, effective) clip rect, or None if the
stack is empty.
Sourcepub fn as_scissor(&self) -> Option<[u32; 4]>
pub fn as_scissor(&self) -> Option<[u32; 4]>
Return the current clip as integer [x, y, w, h] rounded outward
(floor on origin, ceil on extent).
Returns None if the stack is empty. Negative components are clamped
to zero before the conversion.