pub struct Renderer { /* private fields */ }Implementations§
Source§impl Renderer
impl Renderer
Sourcepub fn probe_texts(
&mut self,
doc: &Document,
t: f64,
) -> Result<(Vec<u8>, Vec<TextProbe>), RenderError>
pub fn probe_texts( &mut self, doc: &Document, t: f64, ) -> Result<(Vec<u8>, Vec<TextProbe>), RenderError>
Renders frame t and measures every visible text in it. Returns the
frame (sRGB RGBA8, opaque) and the probes.
Source§impl Renderer
impl Renderer
pub fn new(device: Device) -> Result<Self, RenderError>
Sourcepub fn new_on_demand(device: Device) -> Result<Self, RenderError>
pub fn new_on_demand(device: Device) -> Result<Self, RenderError>
A renderer whose ops’ tier-0 kernels compile only when a frame first
needs one (Kernels::on_demand), for a command that renders and
exits (an export, a frame, a check): its exact renders wait for
their fused kernels anyway. On the first run after an install or an
upgrade it starts about 0.9 s sooner. Renderer::new builds them
all first, so a live session never waits on the compiler.
Sourcepub fn set_slot_budget(&mut self, bytes: u64)
pub fn set_slot_budget(&mut self, bytes: u64)
Bytes resident group slots and kept raster textures may use before cold ones are given back.
Sourcepub fn set_sequential(&mut self, on: bool)
pub fn set_sequential(&mut self, on: bool)
Declares that frames will be rendered once each, in order (an export), so state kept only for seeking back can be skipped.
Sourcepub fn pin_fonts(&mut self, pins: &[FontPin]) -> Result<(), String>
pub fn pin_fonts(&mut self, pins: &[FontPin]) -> Result<(), String>
Lets go of everything held for the current document (plan, group
and raster textures, decoders, images, simulations, built parts)
and keeps what any document reuses: compiled kernels, pipelines and
fonts. A warm renderer serving one document after another calls this
between them, so GPU memory returns to its baseline instead of
collecting every earlier document’s resources. Call with no frames
in flight.
Pins font files to their family, weight and style for what renders
next, until Renderer::unpin_fonts (see
geom::Fonts::pin): a document laid out elsewhere with those
files sets its text with them here.
Sourcepub fn set_script_fonts(&mut self, rows: Vec<ScriptFont>)
pub fn set_script_fonts(&mut self, rows: Vec<ScriptFont>)
How what renders next sets the writing systems its fonts do not
cover, until Renderer::unpin_fonts (see
geom::Fonts::set_script_fonts).
Sourcepub fn unpin_fonts(&mut self)
pub fn unpin_fonts(&mut self)
Drops the pins of Renderer::pin_fonts.
Sourcepub fn refresh_changed_media(&mut self) -> usize
pub fn refresh_changed_media(&mut self) -> usize
Drops the decoded images and video decoders whose files changed on disk since they were read (a look re-rendered into the same file, a sheet rebuilt), and the cached results made from them, so the next frame shows the files as they are now. Returns how many it dropped; costs a stat per image and video held. A player calls it when a document is (re)loaded and every so often while it is open.
pub fn release_document(&mut self)
Sourcepub fn media_wait(&self) -> f64
pub fn media_wait(&self) -> f64
Seconds this renderer has spent waiting for decoded media and uploading decoded images (part of the CPU time of the frames).
Sourcepub fn image_wait(&self) -> f64
pub fn image_wait(&self) -> f64
The part of media_wait spent on images.
pub fn device(&self) -> &Device
Sourcepub fn set_profiling(&mut self, on: bool)
pub fn set_profiling(&mut self, on: bool)
Profiling: every group is submitted to the GPU on its own and timed,
which is slower but says what each part of a film costs. Read the
totals with Renderer::profile.
Sourcepub fn profile(&mut self) -> Result<Vec<GroupCost>, RenderError>
pub fn profile(&mut self) -> Result<Vec<GroupCost>, RenderError>
GPU time per group so far (waits for groups still running), most expensive first.
Sourcepub fn set_skip_redundant(&mut self, on: bool)
pub fn set_skip_redundant(&mut self, on: bool)
Whether to skip work that cannot change the frame (redrawing still geometry, copying layers that only pass through). On by default; off (or ULTRAFAST_NO_SKIP) renders a reference to check it against.
Sourcepub fn profile_frames(
&mut self,
doc: &Document,
frames: u64,
from: f64,
) -> Result<ProfileReport, RenderError>
pub fn profile_frames( &mut self, doc: &Document, frames: u64, from: f64, ) -> Result<ProfileReport, RenderError>
Renders frames frames from from seconds with every group timed
on its own: where the GPU time of doc goes, per frame.
Sourcepub fn set_full_motion_blur(&mut self, full: bool)
pub fn set_full_motion_blur(&mut self, full: bool)
Motion blur samples every group on every frame instead of only what moves (reference renders).
Sourcepub fn set_motion_blur(&mut self, on: bool)
pub fn set_motion_blur(&mut self, on: bool)
Turns the document’s motion blur on or off for the frames that follow. A player turns it off while it plays (one render a frame keeps playback smooth) and back on when it stops, so a still frame shows exactly what the export will.
pub fn set_mode(&mut self, mode: Mode)
Sourcepub fn set_wait_for_fused(&mut self, on: bool)
pub fn set_wait_for_fused(&mut self, on: bool)
Whether exact renders wait for fused kernels still compiling. Off, such a group renders op by op with the tier-0 kernels (built at startup) until its fused kernel is ready: the same image to within half-float rounding of the intermediates, with no compile stall when a document’s structure is new (a new look on a render service). Groups with an op that has no tier-0 kernel (custom shaders) still wait.
pub fn waits_for_fused(&self) -> bool
pub fn mode(&self) -> Mode
Sourcepub fn set_base_dir(&mut self, dir: &Path)
pub fn set_base_dir(&mut self, dir: &Path)
Directory relative resource paths resolve against.
pub fn base_dir(&self) -> &Path
pub fn plan(&self) -> Option<&Plan>
pub fn kernels(&self) -> &Kernels
pub fn diagnostics(&self) -> &[Diagnostic]
pub fn clear_diagnostics(&mut self)
Sourcepub fn text_outline(&mut self, node: &Node) -> Result<String, RenderError>
pub fn text_outline(&mut self, node: &Node) -> Result<String, RenderError>
Bounds (min x, min y, max x, max y) in output pixels of a path or text node, as of the last frame it was rasterized. Outlines of a text node as SVG path data (pixels, placed), for morphing letters or reusing type as vector shapes.
Sourcepub fn measure_text(&mut self, node: &Node) -> Result<LineMetrics, RenderError>
pub fn measure_text(&mut self, node: &Node) -> Result<LineMetrics, RenderError>
Glyph-by-glyph metrics of a single-line text node (see
geom::measure), with this renderer’s fonts and base directory.
pub fn node_bounds(&self, id: &str) -> Option<[f32; 4]>
Sourcepub fn pick(&self, doc: &Document, t: f64, x: f32, y: f32) -> Option<Picked>
pub fn pick(&self, doc: &Document, t: f64, x: f32, y: f32) -> Option<Picked>
What is under frame point (x, y) at t, as last rendered: the
smallest visible element there (text, path, shape, image, video),
named by the document node it belongs to (a component instance or
block for its parts) and by the part itself, with its frame bounds.
Sourcepub fn visible(&self, doc: &Document, t: f64) -> Vec<Visible>
pub fn visible(&self, doc: &Document, t: f64) -> Vec<Visible>
Every visible element at t, as last rendered (render t first):
texts, paths, shapes, images and videos that are active and inside
the frame, with their document node, bounds, and the words of text.
Sourcepub fn content_bounds(&self, id: &str) -> Option<[f32; 4]>
pub fn content_bounds(&self, id: &str) -> Option<[f32; 4]>
Frame bounds of a node’s vector content: its own, or the union over
the nodes of a component instance (id/...), as last rendered.
Sourcepub fn prefetch_fonts(&mut self, doc: &Document)
pub fn prefetch_fonts(&mut self, doc: &Document)
Fetches the font families doc names that this machine lacks,
several at once, before its first render would fetch them one by one.
Sourcepub fn set_output_size(&mut self, size: Option<(u32, u32)>)
pub fn set_output_size(&mut self, size: Option<(u32, u32)>)
Renders the frames that follow at size (device pixels) instead of
each document’s own size; None goes back to that. The document stays
in its own frame pixels: a 1920x1080 document at 3840x2160 is drawn
with twice the texels (text, paths, blurs, particles, 3D re-rendered
at the finer grid), not scaled up. A size of another shape keeps the
finer of the two scales and crops the last texel row or column.
Sourcepub fn output_size(&self) -> Option<(u32, u32)>
pub fn output_size(&self) -> Option<(u32, u32)>
The output size asked for (None: each document’s own).
Sourcepub fn frame_size(&self, doc: &Document) -> (u32, u32)
pub fn frame_size(&self, doc: &Document) -> (u32, u32)
The size frames of doc render at, in device pixels.
Sourcepub fn submit_frame(
&mut self,
doc: &Document,
t: f64,
export: bool,
) -> Result<(Submitted, FrameReport), RenderError>
pub fn submit_frame( &mut self, doc: &Document, t: f64, export: bool, ) -> Result<(Submitted, FrameReport), RenderError>
Encodes and submits frame t (seconds). With export, the final image
is also encoded to sRGB RGBA8 in a CPU-readable texture for
Renderer::read_export. Does not wait for the GPU.
Sourcepub fn submit_frame_with(
&mut self,
doc: &Document,
t: f64,
finish: impl FnOnce(FrameOutput<'_>),
) -> Result<(Submitted, FrameReport), RenderError>
pub fn submit_frame_with( &mut self, doc: &Document, t: f64, finish: impl FnOnce(FrameOutput<'_>), ) -> Result<(Submitted, FrameReport), RenderError>
Encodes frame t, then lets finish add work that consumes the
final image (export, display, video encode) before submitting.
Sourcepub fn frame_mse(
&mut self,
doc: &Document,
t: f64,
reference: &Texture,
) -> Result<f64, RenderError>
pub fn frame_mse( &mut self, doc: &Document, t: f64, reference: &Texture, ) -> Result<f64, RenderError>
Mean squared error (8-bit sRGB units, over black) between frame t
and reference (an RGBA8 sRGB texture of the frame’s size), reduced
on the GPU: only one partial sum per 16x16 tile is read back.
Sourcepub fn render_rgba8(
&mut self,
doc: &Document,
t: f64,
) -> Result<(Vec<u8>, FrameReport), RenderError>
pub fn render_rgba8( &mut self, doc: &Document, t: f64, ) -> Result<(Vec<u8>, FrameReport), RenderError>
Renders frame t, waits, and returns tightly packed sRGB RGBA8 pixels.
Sourcepub fn render_readback(
&mut self,
doc: &Document,
t: f64,
kind: Readback,
opaque: bool,
) -> Result<(Vec<u8>, FrameReport), RenderError>
pub fn render_readback( &mut self, doc: &Document, t: f64, kind: Readback, opaque: bool, ) -> Result<(Vec<u8>, FrameReport), RenderError>
Renders frame t, waits, and returns it tightly packed as kind.
opaque flattens it over black, as a video without alpha shows it;
otherwise alpha is straight.
Sourcepub fn render_presented(
&mut self,
doc: &Document,
t: f64,
width: u32,
height: u32,
hud: [f32; 6],
marks: &[([f32; 4], f32)],
) -> Result<Vec<u8>, RenderError>
pub fn render_presented( &mut self, doc: &Document, t: f64, width: u32, height: u32, hud: [f32; 6], marks: &[([f32; 4], f32)], ) -> Result<Vec<u8>, RenderError>
Renders frame t the way the player shows it: letterboxed into a
width x height view with the timeline drawn over it (hud: on,
playhead 0..1, loop in, loop out, emphasis, playing). RGBA8, sRGB.
Sourcepub fn read_export(&self) -> Vec<u8> ⓘ
pub fn read_export(&self) -> Vec<u8> ⓘ
Reads the last exported frame. Counted as a readback.