Skip to main content

Module render

Module render 

Source
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 NSView into a width x height bitmap.
capture_window⚠
Capture a window including its titlebar, at width x height.
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 body once, delay seconds from now, inside whatever loop is running.
mouse_event_for⚠
Build a synthetic NSEvent in window’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 by pump_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 dispatching NSEvents.
pump_events_until
pump_until, but dequeuing application events as well.
pump_until
Run the run loop until ready holds, or limit seconds have passed.
render
Render a view offscreen at exactly width x height pixels.
render_chrome
Build a real titled window around view, sized so its frame — titlebar included — is exactly width x height, and capture the whole thing.
render_composited
Render view in 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 view in a real window and capture the popover it puts up.
render_sheet
Present view in 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 NSEvent timestamps use.