the dump harness
a scene rendered headless, straight to a png
mirrored from
window/cpp/window.core/dump/README.md, which is the only copy of this text. edits made here are overwritten the next time the site builds
P1.31, the headless dump harness, a scene rendered into plain memory n written out as a png with no window anywhere near it
links into window.core, needs render/ n nothing else, n there is no windows.h in this module
| file | what |
|---|---|
dump.{h,cpp} | P1.31, render_scene, dump_scene n write_png |
why it works at all
the whole thing is one idea reused, the renderer only ever needed a pointer n a stride. that seam exists so a fourth present path is a new file instead of a rewrite, n a lump of malloc is just another thing on the far side of it, so a scene drawn into memory is the same scene drawn into a dib, byte for byte
so a dump creates no hwnd, opens no dc, registers no window class n never pumps a message. it runs over ssh, in ci, in a container, on a box with no desktop at all. the runner proves the no-hwnd half by counting process user objects across a dump, which is the same number P1.9 uses to prove a live window costs one
time is stated, never read
a scene is handed the second it is being drawn at n asks nothing about the clock. that is what makes two dumps of one scene byte identical, n it is also why a scene with something animating in it dumps rather than hangs
the ahk lib hit the other side of this, a live timer made win.dump() hang
(window-chrome.ahk:96) n the fix there was to make the chrome strips ticker opt in. here there is
nothing to opt out of, the harness never pumps so nothing can schedule, n anything that moves reads
the t it was given. P1.22s tween ticker inherits the same deal when it lands
a third parameter rather than a clock the scene reads, bc a clock can be read twice in one frame n give two answers, n then two dumps are not identical for a reason nobody can see
the lib holds no table of scenes
what a scene is is the callers business. the runner keeps its own list n so would a tool, bc a registry inside the lib is a thing every consumer has to register into n nobody can shrink
the runner exposes it as window.test --dump [scene], which writes dumps\<name>.png, one path per
line to stdout so a script can pipe them on, with everything else on stderr. exit 0 wrote
everything, 1 something failed to write, 2 the folder could not be made or the name is not a scene
the two things worth knowing before editing it
- the buffer is zeroed before the render, not just cleared.
clear()only reaches what the current clip allows, so a scene that pushes a clip before it draws would leave the outside holding whatever the allocator handed us, n two dumps would differ by whatever was in memory - the png codec unpremultiplies on the way out. a surface is premultiplied argb32 n a png holds
straight alpha, so blend2d converts both ways. the runner pins it by writing a 50% red n reading it
back,
0x80800000out n0x80800000in. a codec that wrote the premultiplied bytes through as if they were already straight would premultiply a second time on the read n hand back about0x80400000
not here yet
no diff or comparison tool, that is out of scope by the plan, the pngs are compared by eye n by hash.
write_png is the seam a compare would sit next to when one is wanted