Repository navigation
A filter takes in what its element draws outside its box, as Chrome filters it #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
shinyobjectz
merged 2 commits into
shinyobjectz:main
from
JimGHTB12:filter-layer-overflow
Nov 10, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| #!/bin/bash | ||
| # A filter takes in all its element draws, as Chrome filters it: what its descendants draw outside its box too. | ||
| # raea-page's filter layer was the element's border box grown by the filter's reach, so a blurred wrapper of no size | ||
| # lost its absolutely positioned children (a few px of blur were left), and a 60 px box with grayscale(1) showed 60 px | ||
| # of a 200x100 child. page.tsx draws both, and the same box clipping its overflow (which must still cut the child) | ||
| # and clipping x alone (which cuts its side and shows all its height), and a grayscale box around a square whose | ||
| # own drop shadow falls outside it. Each probe is Chrome 157's pixel, within 3. | ||
| # The layer stops at a clip in the way: clipped.tsx's 120 small filtered boxes each show 60 px of a child that | ||
| # covers the frame, cut four ways, 30 boxes each (a clipping box inside, one the stacking context paints, the | ||
| # filtered box's own clip over a z-indexed child, a `contain: paint` box inside). 30 layers the size of the frame | ||
| # are more than Vello's image atlas holds, so its 120 tiles are counted (from the frame's mean: each is 60x60 of | ||
| # grey 92 on white). Exits 1 on a failure. | ||
| # bench/filter-overflow/check.sh (RAEA_BIN: the raea to run, default target/release/raea) | ||
| cd "$(dirname "$0")/../.." || exit 2 | ||
| BIN=${RAEA_BIN:-$PWD/target/release/raea} | ||
| export RAEA_SIGN=0 RAEA_MARK=0 RAEA_EXPORT_CACHE=0 | ||
| OUT=$(mktemp -d "${TMPDIR:-/tmp}/raea-filter-overflow.XXXXXX") | ||
| trap 'rm -rf "$OUT"' EXIT | ||
| for c in page clipped; do | ||
| mkdir -p "$OUT/$c" | ||
| "$BIN" render bench/filter-overflow/$c.tsx --at 0 -o "$OUT/$c" > "$OUT/$c.log" 2>&1 && [ -f "$OUT/$c/frame-00000.png" ] || { echo "FAIL $c: the render failed"; sed 's/^/ /' "$OUT/$c.log" | tail -4; exit 1; } | ||
| done | ||
| status=0 | ||
| want() { # X,Y R G B WHAT: page.tsx's pixel, each channel within 3 | ||
| local p; p=$(magick "$OUT/page/frame-00000.png" -alpha off -format "%[fx:int(255*p{$1}.r+0.5)] %[fx:int(255*p{$1}.g+0.5)] %[fx:int(255*p{$1}.b+0.5)]" info:) | ||
| read -r r g b <<< "$p" | ||
| (( r - $2 <= 3 && $2 - r <= 3 && g - $3 <= 3 && $3 - g <= 3 && b - $4 <= 3 && $4 - b <= 3 )) || { echo "FAIL at $1: $p, wanted $2 $3 $4 ($5)"; status=1; } | ||
| } | ||
| want 100,100 255 0 0 "a blurred wrapper's first child, its middle" | ||
| want 240,100 0 0 255 "its second child" | ||
| want 430,90 54 54 54 "a grayscale box's red child" | ||
| want 530,90 54 54 54 "the child's own drop shadow, outside the box" | ||
| want 480,90 255 255 255 "between them" | ||
| want 70,250 92 92 92 "a grayscale box's child, inside the box" | ||
| want 190,270 92 92 92 "the child past the box" | ||
| want 190,330 255 255 255 "below the child" | ||
| want 370,250 92 92 92 "a clipping box's child, inside the box" | ||
| want 450,270 255 255 255 "its child past the box, clipped" | ||
| want 500,300 92 92 92 "a box clipping x alone: its child below the box" | ||
| want 580,250 255 255 255 "and its child past its side, clipped" | ||
| tiles=$(magick "$OUT/clipped/frame-00000.png" -alpha off -colorspace gray -format "%[fx:int((1-mean)*1920*1080/(3600*(1-92/255))+0.5)]" info:) | ||
| [ "$tiles" = 120 ] || { echo "FAIL clipped.tsx: $tiles of its 120 tiles drawn"; status=1; } | ||
| [ $status = 0 ] && echo "PASS a filter over what its element draws outside its box" | ||
| exit $status |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // 120 small filtered boxes, each showing 60 px of a child that covers the frame from any of them, cut four ways, 30 | ||
| // boxes each: by a clipping box inside; by one positioned with a z-index (the filtered box's stacking context paints | ||
| // it); by the filtered box's own clip, the child positioned with a z-index; and by a `contain: paint` box inside. | ||
| // 120 grey 60 px tiles on white. A filter's layer reaches over what its element draws, and stops at a clip in | ||
| // the way: made from the element's overflow, which reaches through clips, each of these layers would be the size of | ||
| // the frame, and 30 of them are more than Vello's image atlas holds, of either kind. bench/filter-overflow/check.sh | ||
| import { AbsoluteFill, Composition, registerRoot } from "raea"; | ||
| function O() { | ||
| return ( | ||
| <AbsoluteFill style={{ background: "#fff" }}> | ||
| {Array.from({ length: 120 }, (_, i) => { | ||
| const kind = Math.floor(i / 30); | ||
| const cover = <div style={{ position: "relative", left: -2000, top: -1500, width: 4000, height: 3000, background: "#008000", ...(kind === 2 ? { zIndex: 1 } : {}) }} />; | ||
| const inner = [{ overflow: "hidden" }, { overflow: "hidden", position: "relative", zIndex: 1 }, null, { contain: "paint" }][kind]; | ||
| return ( | ||
| <div key={i} style={{ position: "absolute", left: 30 + (i % 12) * 155, top: 20 + Math.floor(i / 12) * 105, width: 60, height: 60, filter: "grayscale(1)", ...(kind === 2 ? { overflow: "hidden" } : {}) }}> | ||
| {inner ? <div style={{ width: 60, height: 60, ...inner }}>{cover}</div> : cover} | ||
| </div> | ||
| ); | ||
| })} | ||
| </AbsoluteFill> | ||
| ); | ||
| } | ||
| registerRoot(() => <Composition id="o" component={O} width={1920} height={1080} fps={30} durationInFrames={1} />); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // A filter takes in all its element draws, what its descendants draw outside its box included. Top: a wrapper of no | ||
| // size with a blur, around two absolutely positioned squares; and a 60 px box with grayscale(1) around a red square | ||
| // whose own drop shadow falls 100 px to its right. Below, a 60 px box with grayscale(1) holding a 200x100 green | ||
| // child, three ways: as it is (all of the child shows), clipping its overflow (60 px of it), and clipping x alone | ||
| // (60 px wide, all 100 px tall). bench/filter-overflow/check.sh | ||
| import { AbsoluteFill, Composition, registerRoot } from "raea"; | ||
| const square = (left: number, background: string) => <div style={{ position: "absolute", left, top: 0, width: 120, height: 120, background }} />; | ||
| const box = (left: number, clip: object) => ( | ||
| <div style={{ position: "absolute", left, top: 220, width: 60, height: 60, filter: "grayscale(1)", ...clip }}> | ||
| <div style={{ width: 200, height: 100, background: "#008000" }} /> | ||
| </div> | ||
| ); | ||
| function O() { | ||
| return ( | ||
| <AbsoluteFill style={{ background: "#fff" }}> | ||
| <div style={{ position: "absolute", left: 40, top: 40, filter: "blur(4px)" }}>{square(0, "#f00")}{square(140, "#00f")}</div> | ||
| <div style={{ position: "absolute", left: 400, top: 60, width: 60, height: 60, filter: "grayscale(1)" }}> | ||
| <div style={{ width: 60, height: 60, background: "#f00", filter: "drop-shadow(100px 0 0 #f00)" }} /> | ||
| </div> | ||
| {box(40, {})} | ||
| {box(340, { overflow: "hidden" })} | ||
| {box(480, { overflowX: "clip", overflowY: "visible" })} | ||
| </AbsoluteFill> | ||
| ); | ||
| } | ||
| registerRoot(() => <Composition id="o" component={O} width={640} height={360} fps={30} durationInFrames={1} />); |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a small filtered
overflow: hiddenbox containing a frame-coveringposition: relative; z-index: 1child, this union adds the entire child back afterdrawn_bounds(node_id, false)correctly stopped at the owner's clip.draw_childrenactually paints that child inside the clip, so the new frame-sized texture contains almost entirely invisible content. Sixty such cards arranged likebench/filter-overflow/clipped.tsxrequire 124,416,000 image texels, exceeding Vello's 8192×8192 atlas;resolve_pending_imagesinvendor/vello_encoding/src/resolve.rsthen omits images whose allocations fail. Intersect ordinary hoisted-child bounds with their applicable clips before unioning them, while preserving the separate treatment of children painted outside those clips.Useful? React with 👍 / 👎.