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_with_fonts(fonts: &[&[u8]]) -> Self

Create a new WGPU renderer with the specified font data.

This is the recommended constructor for applications. Call init_gpu before rendering.

§Example
let font_light = include_bytes!("path/to/font-light.ttf");
let font_regular = include_bytes!("path/to/font-regular.ttf");
let renderer = WgpuRenderer::new_with_fonts(&[font_light, font_regular]);
Source

pub fn new() -> Self

Create a new WGPU renderer without any fonts.

Warning: This is for internal use only. Applications should use new_with_fonts(). Text rendering will fail without fonts.

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