SVG Filters
Chain-level Optimizations
Buffer Scoping
Heuristic to avoid having buffers allocated that will no longer be referenced by the filter.
Approximate algorithm:
for all filter primitives in reverse order
{
for all inputs references to current primitive
{
if ((reference to partial result) AND
(referenced primitive has no deleted mark))
{
mark primitive deleted
mark the reference as a "deleting reference"
}
}
}
The algorithm above basically marks the edges in the filter graph/chain, to indicate
when a reference can be cleaned up after usage.
Area shrinking (not implemented)
Heuristic intended to minimize the actual area filtering is performed on.
Optimization possibilities exist for the following cases:
- Zero-preserving filter with known input
- Propagation of areas from refering primitives with one of the above
(inherit = inherit area from refering primitives)
Unary filter primitives
- feColorMatrix and feComponentTransfer
- inherit, investigate zero-preserving cases
- feConvolveMatrix
- inherit / zero-preserving (atleast for preserveAlpha=true)?
- feDiffuseLighting
- inherit
- feSpecularLighting
- inherit
- feMorphology and feGaussianBlur
- inherit (watch out for cases where the area may need contribution from wrapping)
- feOffset
- inherit
- feTile
- inherit
Binary filter primitives
- feComposite
- inherit, unless doing 'masking' (operator in) with Source(Alpha|Graphic)
- feBlend
- inherit
- feDisplacementMap
- inherit
N-ary filter primitives
- feMerge
- inherit / union of inputs
Generative filter primitives
- feFlood and feTurbulence
- inherit
- feImage
Chain collapsing/Compound filters (not implemented)
Detection of commonly used subgraphs, and substitution of these for
specially tailored filters (e.g. drop shadows).