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.
Offset
Offset the rendered content by a fixed amount.
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.
Implementations§
Source§impl RenderEffect
impl RenderEffect
Sourcepub fn placeholder(&self) -> Option<ShaderPlaceholder>
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.
Sourcepub fn blur(radius: f32) -> RenderEffect
pub fn blur(radius: f32) -> RenderEffect
Create a blur effect with equal radius in both directions.
Sourcepub fn blur_with_edge_treatment(
radius: f32,
edge_treatment: TileMode,
) -> RenderEffect
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.
Sourcepub fn blur_xy(
radius_x: f32,
radius_y: f32,
edge_treatment: TileMode,
) -> RenderEffect
pub fn blur_xy( radius_x: f32, radius_y: f32, edge_treatment: TileMode, ) -> RenderEffect
Create a blur effect with separate horizontal and vertical radii.
Sourcepub fn offset(offset_x: f32, offset_y: f32) -> RenderEffect
pub fn offset(offset_x: f32, offset_y: f32) -> RenderEffect
Create an offset effect.
Sourcepub fn runtime_shader(shader: RuntimeShader) -> RenderEffect
pub fn runtime_shader(shader: RuntimeShader) -> RenderEffect
Create a custom shader effect from a RuntimeShader.
Sourcepub fn then(self, other: RenderEffect) -> RenderEffect
pub fn then(self, other: RenderEffect) -> RenderEffect
Chain this effect with another: self is applied first, then other.
Sourcepub fn contains_runtime_shader(&self) -> bool
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.
Sourcepub fn preserves_transparency(&self) -> bool
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.
Sourcepub fn input_padding(&self) -> f32
pub fn input_padding(&self) -> f32
Maximum logical-pixel input padding required by this effect.
Sourcepub fn output_padding(&self) -> f32
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.
Sourcepub fn output_support(&self) -> Option<Rect>
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.
Sourcepub fn sample_domain(&self) -> Option<Rect>
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
impl Clone for RenderEffect
Source§fn clone(&self) -> RenderEffect
fn clone(&self) -> RenderEffect
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RenderEffect
impl Debug for RenderEffect
Source§impl PartialEq for RenderEffect
impl PartialEq for RenderEffect
Source§impl RenderHash for RenderEffect
impl RenderHash for RenderEffect
fn render_hash(&self) -> u64
impl StructuralPartialEq for RenderEffect
Auto Trait Implementations§
impl Freeze for RenderEffect
impl RefUnwindSafe for RenderEffect
impl Send for RenderEffect
impl Sync for RenderEffect
impl Unpin for RenderEffect
impl UnsafeUnpin for RenderEffect
impl UnwindSafe for RenderEffect
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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