Expand description
Deterministic offscreen rendering — the basis of the visual parity tests.
Everything here is pinned so that two runs, or a Rust run and a Swift run, produce byte-identical output:
- the bitmap is created explicitly at 1 pixel per point, so the result does not depend on the attached display’s backing scale factor;
- the appearance is forced to Aqua, so it does not depend on the host’s light/dark setting;
- the view is hosted in an offscreen window, so layout matches what an on-screen window would produce.
Structs§
- Animation
- A sequence of rendered frames.
- Rendered
- A rendered bitmap: 8-bit RGBA, row-major, no padding.
Functions§
- activate
- Bring the application forward and wait until the window server agrees.
- capture_
composited ⚠ - Ask the window server for a window’s composited contents.
- capture_
view ⚠ - Capture any
NSViewinto awidthxheightbitmap. - capture_
window ⚠ - Capture a window including its titlebar, at
widthxheight. - deactivate
- Give up frontmost status and wait until the window server agrees.
- drain
- Let AppKit and SwiftUI finish work they have deferred to the run loop.
- during_
tracking ⚠ - Run
bodyonce,delayseconds from now, inside whatever loop is running. - mouse_
event_ ⚠for - Build a synthetic
NSEventinwindow’s coordinate space. - post_
key ⚠ - Post a key press and release to whichever window is key.
- post_
mouse ⚠ - Post a synthetic mouse event to
window, to be delivered bypump_events. - pump
- Run the main run loop for
seconds, letting SwiftUI’s clock advance. - pump_
events - Run a real event loop for
seconds, dequeuing and dispatchingNSEvents. - pump_
events_ until pump_until, but dequeuing application events as well.- pump_
until - Run the run loop until
readyholds, orlimitseconds have passed. - render
- Render a view offscreen at exactly
widthxheightpixels. - render_
chrome - Build a real titled window around
view, sized so its frame — titlebar included — is exactlywidthxheight, and capture the whole thing. - render_
composited - Render
viewin a real window and capture it as the window server composited it, rather than as its own layers draw. - render_
hosting - Render an existing hosting view — used when the root is swapped between frames.
- render_
image - Render a view through SwiftUI’s own
ImageRenderer. - render_
png - Render straight to a PNG file.
- render_
popover - Present
viewin a real window and capture the popover it puts up. - render_
sheet - Present
viewin a real window and capture the sheet it puts up, not the window itself. - send_
key ⚠ - Send a key down and up straight to
window. - send_
mouse ⚠ - Hand a synthetic mouse event straight to
window, bypassing the application’s event queue. - uptime
- Seconds since boot — the timebase
NSEventtimestamps use.