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
impl WgpuRenderer
Sourcepub fn new_with_fonts(fonts: &[&[u8]]) -> Self
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]);Sourcepub fn new() -> Self
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.
Sourcepub fn init_gpu(
&mut self,
device: Arc<Device>,
queue: Arc<Queue>,
surface_format: TextureFormat,
)
pub fn init_gpu( &mut self, device: Arc<Device>, queue: Arc<Queue>, surface_format: TextureFormat, )
Initialize GPU resources with a WGPU device and queue.
Sourcepub fn set_root_scale(&mut self, scale: f32)
pub fn set_root_scale(&mut self, scale: f32)
Set root scale factor for text rendering (e.g., density scaling on Android)
Sourcepub fn render(
&mut self,
view: &TextureView,
width: u32,
height: u32,
) -> Result<(), WgpuRendererError>
pub fn render( &mut self, view: &TextureView, width: u32, height: u32, ) -> Result<(), WgpuRendererError>
Render the scene to a texture view.
Trait Implementations§
Source§impl Default for WgpuRenderer
impl Default for WgpuRenderer
Source§impl Renderer for WgpuRenderer
impl Renderer for WgpuRenderer
type Scene = Scene
type Error = WgpuRendererError
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>
Source§fn rebuild_scene_from_applier(
&mut self,
applier: &mut MemoryApplier,
root: NodeId,
_viewport: Size,
) -> Result<(), Self::Error>
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
Auto Trait Implementations§
impl Freeze for WgpuRenderer
impl !RefUnwindSafe for WgpuRenderer
impl !Send for WgpuRenderer
impl !Sync for WgpuRenderer
impl Unpin for WgpuRenderer
impl !UnwindSafe for WgpuRenderer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more