Skip to main content

RenderEffect

Enum RenderEffect 

Source
pub enum RenderEffect {
    Blur {
        radius_x: f32,
        radius_y: f32,
        edge_treatment: TileMode,
    },
    Offset {
        offset_x: f32,
        offset_y: f32,
    },
    Shader {
        shader: Arc<RuntimeShader>,
    },
    Chain {
        first: Arc<RenderEffect>,
        second: Arc<RenderEffect>,
    },
}
Expand description

A render effect applied to a graphics layer’s rendered content.

Matches Jetpack Compose’s RenderEffect sealed class hierarchy, extended with Shader for custom WGSL effects.

Variants§

§

Blur

Gaussian blur applied to the layer’s rendered content.

Fields

§radius_x: f32

Blur radius along the x axis, in pixels.

§radius_y: f32

Blur radius along the y axis, in pixels.

§edge_treatment: TileMode

How pixels beyond the layer’s edge are treated while blurring.

§

Offset

Offset the rendered content by a fixed amount.

Fields

§offset_x: f32

Horizontal shift, in pixels. Positive values move the content to the right.

§offset_y: f32

Vertical shift, in pixels. Positive values move the content down.

§

Shader

Apply a custom WGSL shader effect.

Fields

§shader: Arc<RuntimeShader>

Shared shader configuration; use Arc::make_mut to edit a cloned effect independently.

§

Chain

Chain two effects: apply first, then apply second to the result.

Child effects are shared; use Arc::make_mut to edit a cloned chain independently.

Fields

§first: Arc<RenderEffect>

The effect applied first, to the layer’s rendered content.

§second: Arc<RenderEffect>

The effect applied to the result of first.

Implementations§

Source§

impl RenderEffect

Source

pub fn placeholder(&self) -> Option<ShaderPlaceholder>

What the effect draws while its pipelines compile: the placeholder of the shader that draws last, if it has one.

Source

pub fn blur(radius: f32) -> RenderEffect

Create a blur effect with equal radius in both directions.

Source

pub fn blur_with_edge_treatment( radius: f32, edge_treatment: TileMode, ) -> RenderEffect

Create a blur effect with equal radius in both directions and explicit edge treatment semantics.

Source

pub fn blur_xy( radius_x: f32, radius_y: f32, edge_treatment: TileMode, ) -> RenderEffect

Create a blur effect with separate horizontal and vertical radii.

Source

pub fn offset(offset_x: f32, offset_y: f32) -> RenderEffect

Create an offset effect.

Source

pub fn runtime_shader(shader: RuntimeShader) -> RenderEffect

Create a custom shader effect from a RuntimeShader.

Source

pub fn then(self, other: RenderEffect) -> RenderEffect

Chain this effect with another: self is applied first, then other.

Source

pub fn contains_runtime_shader(&self) -> bool

Returns true if this effect or any chained sub-effect is a RuntimeShader. Animated shaders produce different output every frame, so layer surface caching is counterproductive for them.

Source

pub fn preserves_transparency(&self) -> bool

Whether the effect returns zero over a transparent input: a blur or an offset of nothing is nothing, a shader when it declares so, and a chain when every step does.

Source

pub fn input_padding(&self) -> f32

Maximum logical-pixel input padding required by this effect.

Source

pub fn output_padding(&self) -> f32

Maximum logical-pixel distance this effect WRITES outside its rect. Only runtime shaders may declare one (SDF coverage past node bounds); blur/offset stay confined to their tight rect.

Source

pub fn output_support(&self) -> Option<Rect>

The rect outside which this effect writes nothing, in its logical space with the origin at its rect’s top-left, when the stage that produces its output declared one; blur and offset write their whole rect and declare none.

Source

pub fn sample_domain(&self) -> Option<Rect>

The rect outside which the stage that produces this effect’s output never samples what it is given, when it declared one; the whole input otherwise. A blur samples everything it writes and more.

Trait Implementations§

Source§

impl Clone for RenderEffect

Source§

fn clone(&self) -> RenderEffect

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 Debug for RenderEffect

Source§

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

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

impl PartialEq for RenderEffect

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl RenderHash for RenderEffect

Source§

fn render_hash(&self) -> u64

Returns a hash over exactly the values that change what is drawn. Equal values give equal hashes.
Source§

impl StructuralPartialEq for RenderEffect

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

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

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> LayoutData for T
where T: Any + Debug + PartialEq,

Source§

fn same_as(&self, other: &(dyn LayoutData + 'static)) -> bool

Whether other holds the same data, so a parent can keep its last measure.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

The data as Any, to read it by its type.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

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