Skip to main content

WgpuRenderer

Struct WgpuRenderer 

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

WGPU-based renderer for GPU-accelerated 2D rendering.

This renderer supports:

  • GPU-accelerated shape rendering (rectangles, rounded rectangles)
  • Gradients (solid, linear, radial)
  • GPU text rendering via glyphon
  • Cross-platform support (Desktop, Web, Mobile)

Implementations§

Source§

impl WgpuRenderer

Source

pub fn new(fonts: &[&[u8]]) -> Self

Create a new WGPU renderer.

  • fonts – font bytes to load, ordered by priority (first = highest priority). Pass &[] to load no fonts; text will not render until fonts are provided.

Call init_gpu before rendering.

Source

pub fn init_gpu( &mut self, device: Arc<Device>, queue: Arc<Queue>, surface_format: TextureFormat, )

Initialize GPU resources with a WGPU device and queue.

Source

pub fn set_root_scale(&mut self, scale: f32)

Set root scale factor for text rendering (e.g., density scaling on Android)

Source

pub fn render( &mut self, view: &TextureView, width: u32, height: u32, ) -> Result<(), WgpuRendererError>

Render the scene to a texture view.

Source

pub fn capture_frame( &mut self, width: u32, height: u32, ) -> Result<CapturedFrame, WgpuRendererError>

Render the current scene into an RGBA pixel buffer for robot tests.

Uses the renderer’s configured root scale.

Source

pub fn capture_frame_with_scale( &mut self, width: u32, height: u32, root_scale: f32, ) -> Result<CapturedFrame, WgpuRendererError>

Render the current scene into an RGBA pixel buffer with an explicit scale.

Source

pub fn device(&self) -> &Device

Get access to the WGPU device (for surface configuration).

Trait Implementations§

Source§

impl Default for WgpuRenderer

Source§

fn default() -> Self

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

impl Renderer for WgpuRenderer

Source§

type Scene = Scene

Source§

type Error = WgpuRendererError

Source§

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

Source§

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

Source§

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

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 draw_dev_overlay(&mut self, text: &str, viewport: Size)

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

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>