Implement the blur() filter function
This finally gets us to the point where we can implement CSS filter functions easily.
Based on work from !387 (closed), I've finished refactoring the filters code like this:
- At rendering time, an element's filters get resolved into a
FilterSpec
. This contains all the parameters for CSS filtering - bounds, units, and the list of filter primitives. - While rendering each filter primitive, the code does not have to pull out parameters from nodes/values/etc. - they are all part of the
PrimitiveParams
variants, and generally in the form of fundamental types (e.g. an already-normalizedf64
instead ofLength
).
The code has all the machinery necessary to transform an attribute like filter="blur(5)"
into a FilterSpec
with a PrimitiveParams::GaussianBlur
inside it.
There's a new source file, src/filter_func.rs
, where we should put all the other filter functions:
-
FilterFunc
is an enum that just has aBlur
variant right now; it should have one for each of the [functions in the spec]((https://www.w3.org/TR/filter-effects/#filter-functions). -
FilterFunc::parse
needs to be expanded for each additional function. -
FilterFunc::to_filter_spec
does the conversion from high-level functions to low-levelFilterSpec
and its primitives. For example, thedrop_shadow
function will expand to a blur/offset/merge/etc.