diff options
| author | eunhhu <[email protected]> | 2026-09-27 14:59:54 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-27 14:59:54 +0100 |
| commit | 5313285bbfedf6154d2611c4923cff458d7ef271 (patch) | |
| tree | 81a9d1516f5666c351cf716b394523255d9a5183 /tests/check.py | |
| parent | 993871c6dfa19cf4e0bd4a16c9aad26cb0025d70 (diff) | |
| download | vega-5313285bbfedf6154d2611c4923cff458d7ef271.tar.gz vega-5313285bbfedf6154d2611c4923cff458d7ef271.zip | |
Put the frames on a display through KMS, checked by writeback
vega display draws the same frames on a display with the kernel's mode
setting and no library between: a connected connector's mode on a CRTC, its
primary plane flipped between two dumb buffers by atomic commits, the grid
as many cells as fit. Frames are drawn in cached memory and copied over,
since blending over write-combined buffers read them back slowly (a 1080p
frame took 370 ms; now 20.6 ms with a vertical sync and the check below).
This Pi has no screen but its display controller has writeback connectors:
--writeback sets a mode on one and takes every frame back as the controller
put it out. Each came back exactly as drawn, and the new check finds it the
pixel surface's frame for the same grid, pixel for pixel.
Diffstat (limited to 'tests/check.py')
| -rw-r--r-- | tests/check.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/check.py b/tests/check.py index e21cfc8..119328a 100644 --- a/tests/check.py +++ b/tests/check.py @@ -33,6 +33,9 @@ (a Latin monospace font, then Korean from a CJK one): the same text, blank cells only background (a focused row's own colour), every other cell inked, so no glyph spills into its neighbour. +12. Display: the same frames through KMS on a writeback connector (when the + device has one) come back from the display controller exactly as drawn, + and are the pixel surface's frames for the same grid. 10. Symbols: SVG icons (arcs, compact flags, holes, no viewBox) become outlines of the right area, an icon asking for what symbols cannot hold is refused by name, damaged files are refused whole, and (when DejaVu Sans is @@ -1074,6 +1077,39 @@ def pixels(vega, tool, module, work): return {'frames': len(frames), 'cells': checked} +def display(vega, module, work): + """The same frames on a display through KMS, on a writeback connector: each + comes back from the display controller exactly as drawn, and it is the + pixel surface's frame for the same grid. None without such a device.""" + card, face = Path('/dev/dri/card1'), work / 'ui.vsym' + if not card.exists() or not face.exists(): + return None + items = ['우유 사기', 'Pure 런타임 문서 읽기', 'on the display'] + script = ''.join(f'text {item.encode().hex()}\n' for item in items) + 'key Space\nshow\nkey ArrowUp\nshow\n' + shown = run(vega, 'display', module, '--symbols', face, '--size', 18, '--card', card, '--writeback', '640x480', + '--out', work / 'display', stdin=script) + if shown.returncode == 2 and ('writeback' in shown.stderr or 'cannot open' in shown.stderr): + return None # no writeback connector, or no access to the card + assert shown.returncode == 0, shown.stderr + frames = [line.split() for line in shown.stdout.splitlines() if line.startswith('frame ')] + assert len(frames) == 2 and all(frame[3] == '0' for frame in frames), frames + grid = frames[0][5] + drawn = run(vega, 'pixels', module, '--symbols', face, '--size', 18, '--grid', grid, '--out', work / 'grid', stdin=script) + assert drawn.returncode == 0, drawn.stderr + assert [line for line in drawn.stdout.splitlines() if not line.startswith('frame ')] == \ + [line for line in shown.stdout.splitlines() if not line.startswith('frame ')] + compared = 0 + for (_, captured, *_), (_, pixel_path, size) in zip(frames, [l.split() for l in drawn.stdout.splitlines() if l.startswith('frame ')]): + header, image = Path(captured).read_bytes().split(b'255\n', 1) + full_width = int(header.split()[1]) + head, grid_image = Path(pixel_path).read_bytes().split(b'255\n', 1) + width, height = map(int, head.split()[1:3]) + for y in range(height): + assert image[3 * y * full_width:3 * (y * full_width + width)] == grid_image[3 * y * width:3 * (y + 1) * width], y + compared += width * height + return {'frames': len(frames), 'pixels': compared} + + def width_of(character): return width(character) or 0 @@ -1117,6 +1153,7 @@ def main(): if args.symbols: report['symbols'] = symbols(args.symbols.resolve(), work) report['pixels'] = pixels(vega, args.symbols.resolve(), modules['todo'], work) + report['display'] = display(vega, modules['todo'], work) print(json.dumps(report)) |
