mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 12:44:11 -10:00
How: gpuview's direct render has an RGBA mode (GpuView.rgba): its three-deep readback ring copies the composite itself (RGBA8 premultiplied) instead of making NV12, so a PNG costs no extra pass. runtime/encode writes each frame straight-coloured (straight(), the engine path's un-premultiply, now shared). RenderOpts.alpha (apps/media's --alpha, refused for video) sets the page's canvas row to #00000000; the camera's clear colour was read as RGB with alpha forced to 255, so a clear canvas came out black. runtime/view's camera_bg reads #rrggbbaa, premultiplied, for gpuview and cpuview (one function where each had its own copy). The help and cli.md say OUT.png and --alpha for PAGE.html. Check: bench/html-png/check.sh (a half-opaque red box sliding over an empty canvas): -o DIR --at 0,29 writes two PNGs, and the box moved between them; -o DIR into a folder that's there works; -o OUT.png --at 29 is byte-identical to the folder's frame 29, and -o OUT.png is frame 0; opaque, the canvas is white and the box pink (255,127,127); with --alpha the canvas is 0,0,0,0 and the box straight red at half alpha (255,0,0,128); --alpha to an MP4 is refused. It fails on the raea before this and passes on this one. bench/html-repeat, bench/frame-panic and bench/dropped-css still pass. Video is unchanged: bench/html-repeat to .txt gives identical hashes for all 270 frames before and after. fps to MP4, seven alternating rounds on a shared, busy machine (the "before" build is about an hour older, with other lanes' changes): median 181 before vs 170 after, ranges 165-202 and 159-198, no difference beyond the noise (closes #32)
44 lines
3.3 KiB
Bash
Executable File
44 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# #32: an HTML page renders to PNGs as a TSX composition does. index.html is a half-opaque red box sliding over a canvas
|
|
# with nothing else on it. Checked:
|
|
# -o DIR --at 0,29 two PNGs, frame-00000.png and frame-00029.png, the box moved between them
|
|
# -o DIR again into the folder that's there now (it was "Is a directory")
|
|
# -o OUT.png --at 29 one PNG, byte-identical to the folder's frame-00029.png
|
|
# -o OUT.png frame 0
|
|
# the pixels without --alpha the canvas is white and the box pink (255,128,128); with --alpha the canvas
|
|
# is clear (alpha 0) and the box straight red at half alpha (255,0,0,~128)
|
|
# --alpha -o OUT.mp4 refused
|
|
# Exits 1 on a failure.
|
|
# bench/html-png/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-html-png.XXXXXX")
|
|
trap 'rm -rf "$OUT"' EXIT
|
|
PAGE=bench/html-png/index.html
|
|
status=0
|
|
ok() { echo "PASS $1"; }
|
|
bad() { echo "FAIL $1"; status=1; }
|
|
px() { ffmpeg -v error -i "$1" -vf "crop=1:1:$2:$3" -f rawvideo -pix_fmt rgba - | od -An -tu1 | tr -s ' ' | sed 's/^ //; s/ *$//'; }
|
|
near() { # "R G B A" "R G B A": each within 3
|
|
read -r a b c d <<<"$1"; read -r e f g h <<<"$2"
|
|
for p in "$a $e" "$b $f" "$c $g" "$d $h"; do set -- $p; (( ${1:-999} - $2 <= 3 && $2 - ${1:-999} <= 3 )) || return 1; done
|
|
}
|
|
"$BIN" render $PAGE -o "$OUT/dir" --at 0,29 > "$OUT/log" 2>&1
|
|
n=$(ls "$OUT/dir" 2>/dev/null | grep -c '^frame-000\(00\|29\)\.png$')
|
|
[ "$n" = 2 ] && ok "-o DIR --at 0,29: two PNGs" || { bad "-o DIR: $n PNGs (want 2)"; cat "$OUT/log"; }
|
|
[ "$(px "$OUT/dir/frame-00000.png" 60 60)" != "$(px "$OUT/dir/frame-00029.png" 60 60)" ] && ok "the box moved between frames 0 and 29" || bad "frames 0 and 29 are the same at (60,60)"
|
|
"$BIN" render $PAGE -o "$OUT/dir" --at 29 > "$OUT/log" 2>&1 && ok "-o DIR into a folder that's there" || { bad "-o DIR into a folder that's there"; cat "$OUT/log"; }
|
|
"$BIN" render $PAGE -o "$OUT/one.png" --at 29 > "$OUT/log" 2>&1
|
|
cmp -s "$OUT/one.png" "$OUT/dir/frame-00029.png" && ok "-o OUT.png --at 29 is the folder's frame 29" || { bad "-o OUT.png --at 29 differs from the folder's frame 29"; cat "$OUT/log"; }
|
|
"$BIN" render $PAGE -o "$OUT/first.png" > "$OUT/log" 2>&1
|
|
cmp -s "$OUT/first.png" "$OUT/dir/frame-00000.png" && ok "-o OUT.png is frame 0" || { bad "-o OUT.png isn't frame 0"; cat "$OUT/log"; }
|
|
# frame 0: the box at x 40..140, y 40..140
|
|
canvas=$(px "$OUT/first.png" 5 5); box=$(px "$OUT/first.png" 90 90)
|
|
near "$canvas" "255 255 255 255" && near "$box" "255 128 128 255" && ok "opaque: white canvas ($canvas), pink box ($box)" || bad "opaque: canvas $canvas (want 255 255 255 255), box $box (want 255 128 128 255)"
|
|
"$BIN" render $PAGE -o "$OUT/alpha.png" --alpha > "$OUT/log" 2>&1
|
|
canvas=$(px "$OUT/alpha.png" 5 5); box=$(px "$OUT/alpha.png" 90 90)
|
|
[ "${canvas##* }" = 0 ] && near "$box" "255 0 0 128" && ok "--alpha: clear canvas ($canvas), straight red at half alpha ($box)" || { bad "--alpha: canvas $canvas (want alpha 0), box $box (want 255 0 0 128)"; cat "$OUT/log"; }
|
|
"$BIN" render $PAGE -o "$OUT/a.mp4" --alpha > "$OUT/log" 2>&1 && bad "--alpha to an MP4 wasn't refused" || ok "--alpha to an MP4 is refused"
|
|
exit $status
|