Skip to main content

Backdrop

Struct Backdrop 

Source
pub struct Backdrop {
    pub filter: ImageFilter,
    pub blend: BlendMode,
    pub key: Option<u64>,
}
Expand description

A filter over what has already been painted underneath a layer: the frosted glass a sheet, a bar or a dialog sits on.

This is the expensive one, and the difference from ImageFilter on the layer itself is worth stating plainly. ImageFiltered blurs the widget, and its input is a texture the renderer was going to make anyway. A backdrop blurs the frame so far, so the renderer has to stop, take a copy of what it has drawn, filter that, and carry on — once per backdrop. When the effect wanted is “blur this widget”, the other one is both easier and dramatically cheaper.

The region is the layer’s clip, which is the ambient clip unless something narrows it. Unclipped, that is the whole surface — the same rule the reference states, and the same advice follows from it: wrap a backdrop in a clip to bound it to the shape it belongs to.

Fields§

§filter: ImageFilter

What to do to the pixels underneath. A blur, nearly always.

§blend: BlendMode

How the filtered copy meets what it was copied from. BlendMode::SrcOver — the default — paints it over, which is what an opaque frame wants; BlendMode::Src replaces instead, which is what a frame that is not opaque underneath wants. Those are the two the reference singles out, and the two supported here.

§key: Option<u64>

The sharing key. Several backdrops with the same key are filtered once and the one result is reused, which turns a list of sixty frosted rows from sixty full-surface blurs into one. None means this backdrop is filtered on its own.

Two backdrops that overlap must not share a key: the shared copy is taken once, before the first of them, so the second would not see the first.

Implementations§

Source§

impl Backdrop

Source

pub const fn blur(sigma: f32) -> Backdrop

A backdrop blur of sigma logical pixels, painted over what it filtered, on its own rather than shared.

Trait Implementations§

Source§

impl Clone for Backdrop

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

Source§

impl Debug for Backdrop

Source§

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

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

impl PartialEq for Backdrop

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 StructuralPartialEq for Backdrop

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<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.