Skip to content

feImage: skip pixels outside targetRect in filter pipeline#24

Merged
jwmcglynn merged 1 commit into
mainfrom
tsk-feimage-bounds
Apr 12, 2026
Merged

feImage: skip pixels outside targetRect in filter pipeline#24
jwmcglynn merged 1 commit into
mainfrom
tsk-feimage-bounds

Conversation

@jwmcglynn
Copy link
Copy Markdown
Owner

Summary

When feImage has a targetRect smaller than the output region, the bilinear interpolation loop in executeFilterGraph previously 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 targetRect are 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 pull into donner's worktree, the only substantive outgoing delta against upstream main was this FilterGraph.cpp change (other deltas were local Bazel/zlib path adaptations and cosmetic whitespace).

Test plan

  • Confirm existing upstream tests still pass
  • Add a regression test for feImage with a partial targetRect, if one is not already covered
  • Exercised in donner via bazel build //donner/svg/renderer/... (passing) and full bazel build //donner/... (passing)

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.
@jwmcglynn jwmcglynn merged commit 4a44526 into main Apr 12, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant