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: ImageFilterWhat to do to the pixels underneath. A blur, nearly always.
blend: BlendModeHow 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.