Skip to main content

LayerFilter

Struct LayerFilter 

Source
pub struct LayerFilter {
    pub image: Option<ImageFilter>,
    pub color: Option<ColorFilter>,
    pub mask: Option<ShaderMask>,
    pub backdrop: Option<Backdrop>,
    pub blend: Option<BlendMode>,
}
Expand description

What a layer does at compositing, for painting a scene by hand. Everything a layer applies to its own pixels at compositing time. All three are optional and independent; LayerFilter::is_none is the fast path the renderer takes when nothing is asked for, which is nearly always.

Fields§

§image: Option<ImageFilter>

Treats the layer as an image: a blur, a dilate, an erode.

§color: Option<ColorFilter>

A function of one pixel: a tint, a greyscale, a contrast curve.

§mask: Option<ShaderMask>

A colour blended over the result.

§backdrop: Option<Backdrop>

A filter over what is painted underneath, drawn before the layer’s own content. Not one of the three above: it never touches the layer’s pixels.

§blend: Option<BlendMode>

How the layer meets what is underneath (milestone 646): None paints it over, as every layer has always been. Any other mode reads the frame painted so far under the layer and combines the two by it, in the space colours are written in, the way a paint’s blend mode does in the reference. The layer’s clip shape is its coverage: outside it, what was there stays.

Implementations§

Source§

impl LayerFilter

Source

pub const NONE: LayerFilter

Nothing at all — the default, and what every layer that is only an opacity group or a clip carries.

Source

pub fn is_none(&self) -> bool

true when this layer asks for no effect, so compositing can take its original path unchanged.

Source

pub fn merge(self, other: LayerFilter) -> Option<LayerFilter>

Folds other into this filter, keeping what is already set.

This is what lets two filter widgets wrapped one inside the other share a single layer instead of nesting two. It returns None when both sides ask for the same slot, because there the outer one is a filter of the inner’s result and merging would silently drop one of them. A backdrop refuses to share with a filter of the layer itself. It is a filter of what lies underneath, drawn before the layer’s content; a colour filter sharing the layer would be applied to the content and not to the backdrop, and the picture would quietly differ from what the two widgets read as. It shares happily with nothing at all, which is what a clip is, and that case matters: a clip around a backdrop is the shape the backdrop should take.

A blend mode shares with nothing but nothing either. It is how the whole layer meets what is under it, so a filter folded in beside it would be applied before or after the blend depending on which widget it came from.

Source

pub fn scaled_xy(self, sx: f32, sy: f32) -> LayerFilter

Scales the geometry per axis, as DPI does. A colour matrix has no length in it and is left alone; the blur radius and the mask both have one.

Source

pub fn translated(self, dx: f32, dy: f32) -> LayerFilter

Moves the geometry with the subtree it covers. Only the mask has any: a blur radius is a length, not a place.

Source

pub fn resolve_mask(shader: FractionalMask, box_rect: Rect) -> MaskShader

Resolves a mask written in fractions of box_rect into the absolute geometry a scene holds. A radial radius is a fraction of the box smaller side, so a circle stays a circle in a box that is not square.

Trait Implementations§

Source§

impl Clone for LayerFilter

Source§

fn clone(&self) -> LayerFilter

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 Copy for LayerFilter

Source§

impl Debug for LayerFilter

Source§

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

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

impl Default for LayerFilter

Source§

fn default() -> LayerFilter

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

impl PartialEq for LayerFilter

Source§

fn eq(&self, other: &LayerFilter) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LayerFilter

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<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<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<Msg> IntoMsg<Msg> for Msg

Source§

fn defer(work: impl Fn() -> Msg + 'static) -> Msg

The message that stands for work’s result.
Source§

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

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.