Skip to main content

ContentMask

Struct ContentMask 

Source
#[repr(C)]
pub struct ContentMask<P: Clone + Debug + Default + PartialEq> { pub bounds: Bounds<P>, pub corner_radii: Corners<P>, }
Expand description

Indicates which region of the window is visible. Content falling outside of this mask will not be rendered.

vue-native fork: the mask is a ROUNDED rect. All-zero corner_radii is the plain rectangle gpui always had, and costs each fragment shader one uniform branch. With radii, every primitive’s fragment shader multiplies its coverage by the rounded rect’s antialiased SDF (content_mask_coverage in each backend), on top of the hardware clip to bounds. CSS overflow under a border-radius is what pushes one (crate::Style::overflow_mask). ContentMask::intersect says what nesting two masks keeps exact.

Fields§

§bounds: Bounds<P>

The bounds

§corner_radii: Corners<P>

vue-native fork: each corner’s radius, zero for a square corner. Every primitive carries it right after bounds, so the shaders’ structs do too.

Implementations§

Source§

impl<P: Clone + Debug + Default + PartialEq> ContentMask<P>

Source

pub fn rect(bounds: Bounds<P>) -> Self

vue-native fork: a plain rectangular mask.

Source

pub fn is_rounded(&self) -> bool

vue-native fork: whether any corner is rounded.

Source§

impl ContentMask<Pixels>

Source

pub fn scale(&self, factor: f32) -> ContentMask<ScaledPixels>

Scale the content mask’s pixel units by the given scaling factor.

Source§

impl<P> ContentMask<P>
where P: Copy + Ord + Debug + Default + Add<P, Output = P> + Sub<P, Output = P> + Div<f32, Output = P> + Into<f64>,

Source

pub fn intersect(&self, other: &Self) -> Self

Intersect the content mask with the given content mask.

vue-native fork, the rounded corners:

  • Two rectangles intersect exactly, as before.
  • A corner of the result that is also a corner of one of the masks keeps that mask’s radius. When both masks have a corner there, the larger radius wins. Two corners at one point nest, so the larger radius is the smaller region, and that is exact.
  • Any other corner of the result is square. That is exact when the rounded mask’s curve does not reach it: a rect clip inside the curve’s span, or a scroller inset from its rounded card. Where a rect clip cuts through a curve, the cut corner comes out square and shows the sliver the curve would have hidden. That is the one approximation; the common case, one rounded ancestor around rect clips that fill it or sit inside it, is exact.
Source

pub fn contains(&self, point: &Point<P>) -> bool

vue-native fork: whether point is inside the mask, its rounded corners included. The hit test asks this, so a click outside a rounded clip’s curve does not reach what the clip hides.

Trait Implementations§

Source§

impl<P: Clone + Clone + Debug + Default + PartialEq> Clone for ContentMask<P>

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<P: Copy + Clone + Debug + Default + PartialEq> Copy for ContentMask<P>

Source§

impl<P: Debug + Clone + Debug + Default + PartialEq> Debug for ContentMask<P>

Source§

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

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

impl<P: Default + Clone + Debug + Default + PartialEq> Default for ContentMask<P>

Source§

fn default() -> Self

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

impl<P: Eq + Clone + Debug + Default + PartialEq> Eq for ContentMask<P>

Source§

impl<P: PartialEq + Clone + Debug + Default + PartialEq> PartialEq for ContentMask<P>

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<P: PartialEq + Clone + Debug + Default + PartialEq> StructuralPartialEq for ContentMask<P>

Auto Trait Implementations§

§

impl<P> Forget for ContentMask<P>

§

impl<P> Freeze for ContentMask<P>
where Bounds<P>: Freeze, Corners<P>: Freeze,

§

impl<P> Move for ContentMask<P>

§

impl<P> RefUnwindSafe for ContentMask<P>

§

impl<P> Send for ContentMask<P>
where Bounds<P>: Send, Corners<P>: Send,

§

impl<P> Sync for ContentMask<P>
where Bounds<P>: Sync, Corners<P>: Sync,

§

impl<P> Unpin for ContentMask<P>
where Bounds<P>: Unpin, Corners<P>: Unpin,

§

impl<P> UnsafeUnpin for ContentMask<P>

§

impl<P> UnwindSafe for ContentMask<P>

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more