feImage: skip pixels outside targetRect in filter pipeline#24
Merged
Conversation
When feImage has a targetRect smaller than the output region, the bilinear interpolation loop previously wrote into pixels outside the target rectangle, producing bleed artifacts at the edges. Add a pixel-center bounds check before sampling so that only pixels whose centers fall inside the targetRect are populated. Pixels outside the target remain transparent. Found during donner's SVG <filter> integration testing.
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
When
feImagehas atargetRectsmaller than the output region, the bilinear interpolation loop inexecuteFilterGraphpreviously wrote into pixels whose centers fall outside the target rectangle, producing bleed artifacts at the edges.This PR adds a pixel-center bounds check before sampling so only pixels whose centers fall inside
targetRectare populated. Pixels outside the target remain transparent, matching the SVG spec expectation.The fix was originally developed in donner PR #444 ("Implement full SVG support for TinySkia and Skia backends") where donner vendors this library as a git subtree. This PR brings the fix back upstream as part of syncing the donner subtree with upstream
main.Context
The donner subtree had drifted somewhat from upstream. After running
git subtree pullinto donner's worktree, the only substantive outgoing delta against upstreammainwas thisFilterGraph.cppchange (other deltas were local Bazel/zlib path adaptations and cosmetic whitespace).Test plan
feImagewith a partialtargetRect, if one is not already coveredbazel build //donner/svg/renderer/...(passing) and fullbazel build //donner/...(passing)