Support SVG filter effects in anyrender_svg - #90
Open
nicoburns wants to merge 1 commit into
Open
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Tested this PR by rendering SVGs headlessly to PNG with feGaussianBlur (stdDeviation=3) — renders correctly feDropShadow (dx=6 dy=6 stdDeviation=2) — renders correctly Details & additional checks
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses the "Filter effects" item of #88. Previously
render_groupsilently droppedgroup.filters(); now filtered groups are rendered inside a layer with ananyrender::Filterattached, leaving actual filter evaluation to the backend (no rasterization, purePaintSceneabstraction).New module
anyrender_svg::filterconverts a usvg filter chain into a singleanyrender::FilterDAG:FilterEffectcounterpart: blend, color matrix (incl. saturate/hueRotate/luminanceToAlpha), component transfer, composite (incl. arithmetic), convolve matrix, lighting, displacement map, drop shadow, flood, gaussian blur, morphology, offset, tile, turbulence.feMergeis lowered to a chain ofComposite(Over)nodes.in="SourceAlpha"in a chained filter is synthesized via a helperColorMatrixnode; namedresultreferences resolve through a result map.None(→ whole conversion fails) for the inexpressible cases:feImage, anisotropic blur/morphology/turbulence, non-square convolution kernels, non-white lighting colors.In
render_group, when a group has filters:The filter layer is pushed inside the existing clip/opacity/blend layer and clipped to the SVG filter region, so filtering applies to group content before the group's clip/opacity/blend composite — matching the SVG rendering model.
One small API extension in the
anyrendercrate:Filter::set_outputis nowpub, so multi-node graphs built outside the crate can select their output node.Known approximations (documented in
filter.rs): primitive subregions,color-interpolation-filters, convolvetargetX/targetY/edgeMode/kernelUnitLength, and turbulencestitchTilesare ignored.Unit tests cover blur, drop shadow, named-result references, merge lowering, and unsupported-case fallbacks.
Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/742382aca6144666b1a508e6897f72fc
Requested by: @nicoburns