Skip to main content

PixelsRenderer

Struct PixelsRenderer 

Source
pub struct PixelsRenderer { /* private fields */ }
Expand description

A renderer that draws the scene into a caller-owned RGBA pixel buffer on the CPU.

Implementations§

Source§

impl PixelsRenderer

Source

pub fn new() -> Self

Creates a renderer that draws text in the embedded default font when the embedded-default-font feature is on, and draws no text otherwise.

Source

pub fn with_fonts(fonts: &[&'static [u8]]) -> Self

A renderer that draws text in fonts. With none that parses, it uses the embedded default font when the embedded-default-font feature is on, and draws no text otherwise.

Source

pub fn draw(&self, frame: &mut [u8], width: u32, height: u32)

Draws the scene into frame, an RGBA8 buffer of width by height pixels, at one device pixel per logical pixel.

Source

pub fn draw_scaled(&self, frame: &mut [u8], width: u32, height: u32, scale: f32)

Rasterizes logical scene coordinates at scale device pixels per point. Hit regions stay in logical coordinates. Invalid scales use 1.0.

Source

pub fn update_picture( &self, picture: &mut Picture, width: u32, height: u32, scale: f32, changed: &mut Vec<PixelRect>, )

Moves picture to the current scene, drawn width by height device pixels at scale device pixels per point, and puts into changed the areas whose pixels differ from the picture it held: the whole frame the first time and after a change of size or scale. Invalid scales use 1.0.

Source

pub fn draw_picture_area( &self, picture: &Picture, area: PixelRect, pixels: &mut [u8], )

Draws area of picture into pixels as straight-alpha RGBA8 rows of area.width pixels, area.height of them. Draws nothing before the first Self::update_picture or when pixels is shorter than the area.

Source§

impl PixelsRenderer

Source

pub fn compose_sprites( &self, frame: &mut SpriteFrame, width: u32, height: u32, scale: f32, )

The scene at scale device pixels per point as sprites for a GPU compositor, into frame, which keeps its textures from the frames before. Invalid scales use 1.0.

Trait Implementations§

Source§

impl Default for PixelsRenderer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Renderer for PixelsRenderer

Source§

type Scene = Scene

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.
Source§

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

Installs renderer-provided app services into the target AppContext. Read more
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. Read more
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. Read more
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 refreshes the hit targets. 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. Hit targets are refreshed only when their geometry changed. The default implementation calls update_scene_from_applier.
Source§

fn set_root_scale(&mut self, _scale: f32)

Sets how many device pixels the renderer draws for one logical unit. Read more
Source§

fn draw_dev_overlay(&mut self, _text: &str, _viewport: Size)

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

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

Replaces the developer inspector graph outside the application scene. Read more
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.

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