Skip to main content

Renderer

Struct Renderer 

Source
pub struct Renderer { /* private fields */ }

Implementations§

Source§

impl Renderer

Source

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

Source

pub fn new(device: Device) -> Result<Self, RenderError>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

pub fn unpin_fonts(&mut self)

Drops the pins of Renderer::pin_fonts.

Source

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.

Source

pub fn release_document(&mut self)

Source

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).

Source

pub fn image_wait(&self) -> f64

The part of media_wait spent on images.

Source

pub fn device(&self) -> &Device

Source

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.

Source

pub fn profile(&mut self) -> Result<Vec<GroupCost>, RenderError>

GPU time per group so far (waits for groups still running), most expensive first.

Source

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.

Source

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.

Source

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).

Source

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.

Source

pub fn set_mode(&mut self, mode: Mode)

Source

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.

Source

pub fn waits_for_fused(&self) -> bool

Source

pub fn mode(&self) -> Mode

Source

pub fn set_base_dir(&mut self, dir: &Path)

Directory relative resource paths resolve against.

Source

pub fn base_dir(&self) -> &Path

Source

pub fn plan(&self) -> Option<&Plan>

Source

pub fn kernels(&self) -> &Kernels

Source

pub fn diagnostics(&self) -> &[Diagnostic]

Source

pub fn clear_diagnostics(&mut self)

Source

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.

Source

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.

Source

pub fn node_bounds(&self, id: &str) -> Option<[f32; 4]>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn output_size(&self) -> Option<(u32, u32)>

The output size asked for (None: each document’s own).

Source

pub fn frame_size(&self, doc: &Document) -> (u32, u32)

The size frames of doc render at, in device pixels.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn read_export(&self) -> Vec<u8> ⓘ

Reads the last exported frame. Counted as a readback.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.