Skip to main content

Renderer

Trait Renderer 

Source
pub trait Renderer {
    type Scene: RenderScene;
    type Error;

Show 16 methods // Required methods fn scene(&self) -> &Self::Scene; fn scene_mut(&mut self) -> &mut Self::Scene; fn rebuild_scene( &mut self, layout_tree: &LayoutTree, viewport: Size, ) -> Result<(), Self::Error>; fn rebuild_scene_from_applier( &mut self, applier: &mut MemoryApplier, root: NodeId, viewport: Size, ) -> Result<(), Self::Error>; // Provided methods fn attach_app_context_services(&mut self, _app_context: &AppContext) { ... } fn apply_installed_fonts(&mut self, _app_context: &AppContext) { ... } fn set_root_scale(&mut self, _scale: f32) { ... } fn update_scene_from_applier( &mut self, applier: &mut MemoryApplier, root: NodeId, viewport: Size, updates: SceneUpdates<'_>, ) -> Result<(), Self::Error> { ... } fn update_visual_scene_from_applier( &mut self, applier: &mut MemoryApplier, root: NodeId, viewport: Size, updates: SceneUpdates<'_>, ) -> Result<(), Self::Error> { ... } fn draw_dev_overlay( &mut self, _overlay: &PreparedTextLayout, _viewport: Size, ) { ... } fn set_inspector_overlay(&mut self, _graph: Option<RenderGraph>) { ... } fn note_held_still(&mut self) { ... } fn note_pointer_held(&mut self) { ... } fn build_while_idle(&mut self) -> bool { ... } fn needs_frame_warmup(&self) -> bool { ... } fn awaits_pipelines(&self) -> bool { ... }
}
Expand description

Abstraction implemented by concrete renderer backends.

Required Associated Types§

Source

type Scene: RenderScene

The scene type that holds the render graph and the hit targets of this renderer.

Source

type Error

Error returned when the scene cannot be rebuilt or updated.

Required Methods§

Source

fn scene(&self) -> &Self::Scene

The scene that holds the render graph and the hit targets.

Source

fn scene_mut(&mut self) -> &mut Self::Scene

Mutable access to the scene.

Source

fn rebuild_scene( &mut self, layout_tree: &LayoutTree, viewport: Size, ) -> Result<(), Self::Error>

Rebuilds the scene from layout_tree for a viewport of the given size.

Source

fn rebuild_scene_from_applier( &mut self, applier: &mut MemoryApplier, root: NodeId, viewport: Size, ) -> Result<(), Self::Error>

Rebuilds the scene by traversing the LayoutNode tree directly via Applier.

This is the new architecture that eliminates per-frame LayoutTree reconstruction. Implementors must read layout state from LayoutNode.layout_state() directly.

Provided Methods§

Source

fn attach_app_context_services(&mut self, _app_context: &AppContext)

Installs renderer-provided app services into the target AppContext.

AppShell calls this before the first composition pass. Renderers that provide text measurement or other per-app services should install them here rather than as constructor side effects.

Source

fn apply_installed_fonts(&mut self, _app_context: &AppContext)

Takes in the fonts installed since the renderer last looked (see installed_fonts::install_font_file). A renderer that installed the app’s text measurer installs one with the new faces, so text lays out again with them.

AppShell calls this before the layout of a frame that follows an install.

Source

fn set_root_scale(&mut self, _scale: f32)

Sets how many device pixels the renderer draws for one logical unit.

AppShell sets its primary renderer’s scale to the density it lays out with, at construction and on every density change, so a host sets it only for the renderers of other surfaces. Renderers that take the scale with each draw ignore it.

Source

fn update_scene_from_applier( &mut self, applier: &mut MemoryApplier, root: NodeId, viewport: Size, updates: SceneUpdates<'_>, ) -> Result<(), Self::Error>

Updates the scene for the nodes in updates, and the hit targets when the update changed one or the geometry above one. The default implementation rebuilds the whole scene.

Source

fn update_visual_scene_from_applier( &mut self, applier: &mut MemoryApplier, root: NodeId, viewport: Size, updates: SceneUpdates<'_>, ) -> Result<(), Self::Error>

Updates the scene when only what is drawn changed: nothing was composed or laid out. The default implementation calls update_scene_from_applier.

Source

fn draw_dev_overlay(&mut self, _overlay: &PreparedTextLayout, _viewport: Size)

Draw a development overlay (e.g., FPS counter) on top of the scene.

This is called after rebuild_scene when dev options are enabled. The text, laid out in overlay, is drawn directly by the renderer without affecting composition.

Default implementation does nothing.

Source

fn set_inspector_overlay(&mut self, _graph: Option<RenderGraph>)

Replaces the developer inspector graph outside the application scene.

Passing None removes the inspector. Its primitives must not participate in application hit testing, layout, or accessibility.

Source

fn note_held_still(&mut self)

Tells the renderer that its app held still between the last frame and the next one: the shell asked the platform for no frame and no update. A renderer that compares frames to draw only what changed counts the frames on either side of the pause apart.

AppShell calls this before the first frame after such a pause.

Source

fn note_pointer_held(&mut self)

Tells the renderer that a pointer is held on the app’s controls for the coming frame: the user may move it at any moment, so the frame is not one to spend on work that holds the frames after it back, such as a WebGL program link.

AppShell calls this before each frame drawn while a pointer is held.

Source

fn build_while_idle(&mut self) -> bool

Runs one step of the pipeline builds that wait for a frame, where frames run them (a WebGL page links one program at a frame’s end), while the app draws none: a page that stands still still builds what its next touch draws. Returns whether builds still wait.

The platform calls this in its idle periods while it has no frame to draw.

Source

fn needs_frame_warmup(&self) -> bool

Returns whether renderer-side cache materialization needs a visible follow-up frame.

Source

fn awaits_pipelines(&self) -> bool

Returns whether the last frame drew a placeholder for an effect whose pipelines are still compiling, so its picture is not final yet; the renderer asks for the frame that replaces it once they land.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§