-
Notifications
You must be signed in to change notification settings - Fork 3.1k
test(ci): make verify-capture fallback assertion rasterization-safe #10758
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
Changes from all commits
fe79d5e
2bddc17
7dab18d
d24a6f2
d311ec3
8bfefaa
c135f7d
5c25c75
8763adc
d7fc5cb
82769e4
abac4b7
4f643cc
9773fce
db45023
2fd5750
0c4cefe
372b575
81ee054
96820d6
ab4c195
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -213,15 +213,35 @@ describe('verify-capture helper', () => { | |
| const { data, info } = await sharp(png) | ||
| .raw() | ||
| .toBuffer({ resolveWithObject: true }); | ||
| // FG_DEFAULT is #d4d4d4 — look for a pixel matching it. | ||
| let hasFallback = false; | ||
| // FG_DEFAULT is #d4d4d4. Text is anti-aliased, so how many pixels land | ||
| // exactly on it depends on the host's font rasterisation, and the exact | ||
| // scan flaked. Count bright near-neutral pixels instead — both ends of | ||
| // the blend axis (#d4d4d4 over #1e1e1e) are neutral, so every blend of | ||
| // them is neutral at any coverage, while a grossly tinted FG_DEFAULT or | ||
| // the hardcoded #9cdcfe title fill is not and cannot satisfy the count | ||
| // in the fallback's place. The bound is tight because this pipeline never | ||
| // fringes (measured max spread 0) — slack would only let a tinted | ||
| // FG_DEFAULT (#d4d4c8) pass; the floor is strict to keep a mid-grey | ||
| // FG_DEFAULT (#808080) out. Deleting the guard ships fill="undefined", | ||
| // which librsvg paints black, never this bright on #1e1e1e. | ||
| let fallbackPixels = 0; | ||
| for (let i = 0; i + 2 < data.length; i += info.channels) { | ||
| if (data[i] === 0xd4 && data[i + 1] === 0xd4 && data[i + 2] === 0xd4) { | ||
| hasFallback = true; | ||
| break; | ||
| const spread = | ||
| Math.max(data[i], data[i + 1], data[i + 2]) - | ||
| Math.min(data[i], data[i + 1], data[i + 2]); | ||
| if ( | ||
| data[i] > 0x80 && | ||
| data[i + 1] > 0x80 && | ||
| data[i + 2] > 0x80 && | ||
| spread <= 4 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spread <= 4 is the neutrality gate. Both #d4d4d4 and #1e1e1e have equal R/G/B, so every blend between them also has spread=0. Any saturated color like #9cdcfe (spread=98) cannot pass here, ruling out false positives from the title fill color. |
||
| ) { | ||
| fallbackPixels += 1; | ||
| } | ||
| } | ||
| expect(hasFallback, '256-colour text did not render as #d4d4d4').toBe(true); | ||
| expect( | ||
| fallbackPixels, | ||
| '256-colour text did not render as #d4d4d4', | ||
| ).toBeGreaterThan(0); | ||
|
yiliang114 marked this conversation as resolved.
yiliang114 marked this conversation as resolved.
yiliang114 marked this conversation as resolved.
yiliang114 marked this conversation as resolved.
yiliang114 marked this conversation as resolved.
yiliang114 marked this conversation as resolved.
yiliang114 marked this conversation as resolved.
yiliang114 marked this conversation as resolved.
yiliang114 marked this conversation as resolved.
yiliang114 marked this conversation as resolved.
yiliang114 marked this conversation as resolved.
yiliang114 marked this conversation as resolved.
yiliang114 marked this conversation as resolved.
yiliang114 marked this conversation as resolved.
yiliang114 marked this conversation as resolved.
yiliang114 marked this conversation as resolved.
yiliang114 marked this conversation as resolved.
yiliang114 marked this conversation as resolved.
yiliang114 marked this conversation as resolved.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regression anchor: if the bounds guard in verify-capture.mjs is deleted, 256-color/truecolor cells produce fill="undefined" in the SVG. librsvg renders that as black. Black pixels have R=G=B~0, so 0 > 0x80 is false for all, fallbackPixels stays 0, and this assertion fails. Mutation confirmed by the PR author. |
||
| }); | ||
|
|
||
| // SGR 30 maps to #1e1e1e — identical to the canvas BG — so black-foreground | ||
|
|
||
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.
Brightness floor: all channels > 0x80 (128). For the #d4d4d4 over #1e1e1e blend axis, a pixel at coverage a has channels = 30 + 182*a, which exceeds 128 when a > 53.8%. Visible text glyphs satisfy this on any rasteriser. Canvas background (#1e1e1e, R=30) and title fill (#9cdcfe, spread=98) are both excluded.