#[repr(C)]pub struct Clip {
pub rect: Rect,
pub radius: [f32; 4],
pub transform: Transform,
pub inner: Rect,
pub inner_radius: [f32; 4],
}Expand description
The clip a node inherits: a rect, and the radii to round its corners by.
A node that clips (clip, scroll_x, scroll_y) and has a radius
rounds what it clips — the way CSS rounds overflow: hidden under a
border-radius — so the children of a rounded card stay inside its
corners instead of poking out of them. Nothing declares this: the radii
are the clipping node’s own.
One rounded rect cannot name the intersection of two, so nesting is
approximated by Clip::intersect, which says what it gives up.
An entry is the space a quad is painted in, not only what cuts it
(ADR 0043): transform is the similarity every quad naming it is drawn
through — the identity on every entry of a frame with no rotate or
scale — and inner is a second clip in the quad’s own space, before
the transform, from clipping nodes inside a turned subtree. rect and
radius stay the clip in framebuffer space, from clipping nodes
outside any turn. A backend that reads only rect and radius draws
a turned subtree upright and cut by its outer clip, which is what every
backend did before.
Fields§
§rect: Rect§radius: [f32; 4]Clockwise from the top-left: [tl, tr, br, bl]. All zero = a plain
rect clip.
transform: TransformThe turn, scale and move every quad naming this entry is drawn
through: pixel = R(angle) · scale · p + (tx, ty) for p a point
of the quad’s own rect. The identity when nothing turns.
inner: RectThe clip in the quad’s own space, before transform: what a
clipping node inside a turned subtree cuts. NO_CLIP when
nothing inside the turn clips, and on every entry of a frame with
no turn.
inner_radius: [f32; 4]inner’s corner radii, as radius is rect’s.
Implementations§
Source§impl Clip
impl Clip
Sourcepub fn turned(&self) -> bool
pub fn turned(&self) -> bool
Whether every quad naming this entry is drawn through a turn or a scale.
Sourcepub fn turned_by(&self, own: Transform) -> Clip
pub fn turned_by(&self, own: Transform) -> Clip
This space, entered by a node that turns by own (about its
pivot, in this space’s own coordinates): the transform composes,
the outer clip is untouched, and the inner clip is pulled back
into the new space as its bounding box there, its corners square
(ADR 0043, decision 4: a clip between two nested turns is
approximated).
Sourcepub fn visible(&self) -> Rect
pub fn visible(&self) -> Rect
The rect, in the quad’s own space, outside which nothing it draws
can show: rect itself when nothing turns, else the inner clip
narrowed by the outer one pulled back through the transform. What
a glyph cull and a visibility test read, since both compare
positions in the quad’s space.
Sourcepub fn shown(&self, rect: Rect) -> Rect
pub fn shown(&self, rect: Rect) -> Rect
Where rect, a box in the quad’s own space, shows on screen:
itself cut to the clip when nothing turns, else the bounding box
of its turned shape, cut to the outer clip. What the access tree
reports (ADR 0043, decision 7).
Sourcepub fn intersect(&self, box_rect: Rect, box_radius: [f32; 4]) -> Clip
pub fn intersect(&self, box_rect: Rect, box_radius: [f32; 4]) -> Clip
This clip narrowed by a clipping node’s box and that node’s radii.
The rect is the plain intersection, as it has always been. The radii are decided per corner: a corner takes whichever of the two shapes rounds it more (the intersection of two rounded corners is the tighter one), and only while that corner of the result is still the same point as that corner of the shape it came from — a corner an ancestor’s straight edge has already cut away is square, which is what that ancestor made it.
The one case it approximates: an ancestor edge that cuts partway into a rounded corner moves that corner, so its radius drops to zero and a sliver at the very corner goes unclipped. A second clipper offset from the first, both rounded, is the shape that does it.
Under a turn the box is in the quad’s own space, so it narrows the inner clip and leaves the framebuffer one alone (ADR 0043).
Trait Implementations§
impl Copy for Clip
impl StructuralPartialEq for Clip
Auto Trait Implementations§
impl Freeze for Clip
impl RefUnwindSafe for Clip
impl Send for Clip
impl Sync for Clip
impl Unpin for Clip
impl UnsafeUnpin for Clip
impl UnwindSafe for Clip
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.