# ImmutableCustomEffect

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/media/effects/struct-immutablecustomeffect/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct ImmutableCustomEffect
```

The immutable snapshot of a custom effect: what `Visual.Effect` holds
for a custom effect value and what crosses to the render thread.

It is `Send + Sync` and compares by value. Cloning shares the value.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L638)

## Members

- [`new`](#function-new)
- [`name`](#function-name)
- [`value_type_id`](#function-value_type_id)
- [`is`](#function-is)
- [`downcast_ref`](#function-downcast_ref)
- [`padding`](#function-padding)
- [`for_each_parameter`](#function-for_each_parameter)
- [`parameters`](#function-parameters)
- [`parameter`](#function-parameter)
- [`interpolate`](#function-interpolate)
- [`neutral`](#function-neutral)
- [`has_graph`](#function-has_graph)
- [`graph_error`](#function-graph_error)
- [`graph_members`](#function-graph_members)
- [`for_each_graph_value`](#function-for_each_graph_value)
- [`cpu_reference`](#function-cpu_reference)
- [`shader`](#function-shader)
- [`has_shader`](#function-has_shader)
- [`for_each_shader_uniform`](#function-for_each_shader_uniform)
- [`shader_uniform_layout`](#function-shader_uniform_layout)
- [`for_each_shader_child`](#function-for_each_shader_child)
- [`check_shader_children`](#function-check_shader_children)
- [`report_unhandled`](#function-report_unhandled)

<a id="function-new"></a>

### new

```rust
fn new<T: CustomEffect>(value: T) -> Self
```

The snapshot of `value`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L649)

<a id="function-name"></a>

### name

```rust
fn name(self: &Self) -> &'static str
```

The name of the effect (`CustomEffect::NAME`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L654)

<a id="function-value_type_id"></a>

### value_type_id

```rust
fn value_type_id(self: &Self) -> TypeId
```

The type of the value, by which a backend finds its factory for the
effect.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L660)

<a id="function-is"></a>

### is

```rust
fn is<T: CustomEffect>(self: &Self) -> bool
```

Whether the value is a `T`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L665)

<a id="function-downcast_ref"></a>

### downcast_ref

```rust
fn downcast_ref<T: CustomEffect>(self: &Self) -> Option<&T>
```

The value, when it is a `T`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L670)

<a id="function-padding"></a>

### padding

```rust
fn padding(self: &Self) -> Thickness
```

How far the output of the effect extends beyond the bounds of its
content (`CustomEffect::padding`): each side at least zero, a value
that is not finite read as zero. A shader effect whose padding is
`ShaderEffectPadding::SampleRadius` adds its sample radius to each
side.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L679)

<a id="function-for_each_parameter"></a>

### for_each_parameter

```rust
fn for_each_parameter(self: &Self, f: &mut dyn FnMut(&'static str, EffectParameterValue) -> ())
```

Calls `f` with the name and value of each parameter
(`CustomEffect::for_each_parameter`), without allocating.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L696)

<a id="function-parameters"></a>

### parameters

```rust
fn parameters(self: &Self) -> Vec<(&'static str, EffectParameterValue)>
```

The parameters with their values.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L701)

<a id="function-parameter"></a>

### parameter

```rust
fn parameter(self: &Self, name: &str) -> Option<EffectParameterValue>
```

The value of the parameter `name` (ignoring case, `-` and `_`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L708)

<a id="function-interpolate"></a>

### interpolate

```rust
fn interpolate(self: &Self, to: &ImmutableCustomEffect, progress: f64) -> Option<ImmutableCustomEffect>
```

The effect at `progress` of the way from `self` to `to`
(`CustomEffect::interpolate`); `None` when the two are effects of
different types.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L722)

<a id="function-neutral"></a>

### neutral

```rust
fn neutral(self: &Self) -> Option<ImmutableCustomEffect>
```

The value of this effect's type that leaves its content unchanged
(`CustomEffect::neutral`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L728)

<a id="function-has_graph"></a>

### has_graph

```rust
fn has_graph(self: &Self) -> bool
```

Whether the type of the effect has a graph that loaded
(`CustomEffect::graph`): the render walk draws the effect as that
graph around the content of its visual.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L742)

<a id="function-graph_error"></a>

### graph_error

```rust
fn graph_error(self: &Self) -> Option<CompositionEffectFactoryError>
```

Why the graph of the type of the effect did not load, as an effect
factory reports it; `None` when it loaded or the type has none.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L748)

<a id="function-graph_members"></a>

### graph_members

```rust
fn graph_members(self: &Self) -> Vec<(&'static str, String)>
```

The animatable members of the graph of the type: for each value of
`for_each_graph_value`, in order, its
name and the full name of the member it sets
(`EffectName.PropertyName`). Empty without a graph.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L756)

<a id="function-for_each_graph_value"></a>

### for_each_graph_value

```rust
fn for_each_graph_value(self: &Self, f: &mut dyn FnMut(&'static str, EffectParameterValue) -> ())
```

Calls `f` with the name and value of each animatable member of the
graph of the effect (`CustomEffect::for_each_graph_value`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L762)

<a id="function-cpu_reference"></a>

### cpu_reference

```rust
fn cpu_reference(self: &Self, pixels: &mut [u8], width: usize, height: usize, scale: f64) -> bool
```

Applies the CPU reference of the effect to premultiplied RGBA pixels
(`CustomEffect::cpu_reference`); returns whether the effect has one.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L768)

<a id="function-shader"></a>

### shader

```rust
fn shader(self: &Self) -> Option<Arc<ShaderEffectDescription>>
```

The runtime shader of the type of the effect, read once per type
(`CustomEffect::shader`); `None` when the type has none, or has a
graph, which takes precedence.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L775)

<a id="function-has_shader"></a>

### has_shader

```rust
fn has_shader(self: &Self) -> bool
```

Whether the type of the effect is a runtime shader effect
(`shader`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L781)

<a id="function-for_each_shader_uniform"></a>

### for_each_shader_uniform

```rust
fn for_each_shader_uniform(self: &Self, layer_size: [f32; 2], layer_scale: f32, f: &mut dyn FnMut(&'static str, ShaderUniformValue) -> ())
```

Calls `f` with the name and the value of each uniform of the shader of
the effect by the convention of `ShaderEffectDescription`:
`layer_size` (the area of the effect in device pixels), `layer_scale`
(device pixels per device independent pixel), then the parameters in
order (text skipped), named as
`CustomEffect::for_each_parameter` names them. Without allocating:
what a backend calls each frame to fill the uniforms of the program.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L792)

<a id="function-shader_uniform_layout"></a>

### shader_uniform_layout

```rust
fn shader_uniform_layout(self: &Self) -> Vec<(String, ShaderUniformType)>
```

The uniforms a program of the shader of this effect's type declares by
the convention, in order: their names (a parameter's with every `-`
written `_`) and types. What a backend checks a compiled program
against, once.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L805)

<a id="function-for_each_shader_child"></a>

### for_each_shader_child

```rust
fn for_each_shader_child(self: &Self, f: &mut dyn FnMut(&str, &EffectImage) -> ())
```

Calls `f` with the name and the image of each child of the shader of
the effect (#455, E6), in the order of the description's
`children`: the name of the
image parameter (the child of the program is that name with every `-`
written `_`) and its value in this snapshot, the empty image when the
effect has no image parameter of that name. Without allocating: what a
backend calls each frame to bind the children of the program. Nothing
for an effect without a shader.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L821)

<a id="function-check_shader_children"></a>

### check_shader_children

```rust
fn check_shader_children(self: &Self) -> Result<(), String>
```

Checks the children of the shader of the effect's type against its
parameters (#455, E6): at most `MAX_SHADER_CHILDREN`, each the name
of an image parameter of the effect, none twice and none `content`,
and none for a program that samples the content (see
`ShaderEffectDescription::children`). What both backends check once
per type before they compile the program; the error says why not.
`Ok` for an effect without a shader or without children.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L844)

<a id="function-report_unhandled"></a>

### report_unhandled

```rust
fn report_unhandled(self: &Self, backend: &'static str) -> bool
```

Reports that `backend` has no factory for this effect, so that it
draws the content of the effect unchanged. The first report of each
backend and effect name is logged (a warning in the log area named
by `backend`) and returns `true`; later ones return `false`. Called by
the drawing contexts of the backends on the render thread.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/effects/custom_effect.rs#L890)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `ToString`
- `ErasedDestructor`
- `IntoEither`
- `Clone`
- `Debug`
- `PartialEq`
- `From<ImmutableCustomEffect>`
- `Display`
- [`IEffect`](/docs/0.5.0/api/ferroui-base/media/effects/trait-ieffect/)
- [`IImmutableEffect`](/docs/0.5.0/api/ferroui-base/media/effects/trait-iimmutableeffect/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
