Skip to main content

Wgpu2DRenderer

Struct Wgpu2DRenderer 

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

Hardware wgpu 2D Batch, Stencil Clip, Vector Path, and Slug Text Renderer.

Consumes Hardware2DFrame batches compiled by crate::gpu_pipeline::UnifiedGpuCollector and renders analytical quads, dashed strokes, vector path caps/joins, Slug glyphs, and non-rectangular stencil clip masks directly into swapchain or offscreen wgpu::TextureViews.

Implementations§

Source§

impl Wgpu2DRenderer

Source

pub fn from_device( device: Arc<Device>, queue: Arc<Queue>, color_format: TextureFormat, ) -> Self

Creates a hardware 2D renderer sharing an existing wgpu::Device & wgpu::Queue.

Source

pub fn device(&self) -> &Arc<Device> ⓘ

Source

pub fn queue(&self) -> &Arc<Queue> ⓘ

Source

pub fn color_format(&self) -> TextureFormat

Source

pub fn stencil_clip_pipeline(&self) -> &GpuStencilClipPipeline

Returns the underlying hardware stencil clip pipeline bound to WGSL_STENCIL_CLIP_SHADER.

Source

pub fn gpu_memory_bytes(&self) -> u64

Total GPU buffer & render-target memory allocated by this 2D renderer in bytes.

Source

pub fn prepare_frame( &mut self, frame: &Hardware2DFrame, logical_w: f32, logical_h: f32, dpr: f32, )

Uploads frame uniform, quad, path, Slug glyph, and triangulated stencil clip buffers.

Source

pub fn render_batch_slice_to_view( &mut self, frame: &Hardware2DFrame, item_range: Range<usize>, target_view: &TextureView, target_width: u32, target_height: u32, logical_w: f32, logical_h: f32, clear_color: Option<[f32; 4]>, damage: Option<Rect>, )

Renders a contiguous range of frame.items (Batch items only) into target_view, preserving any Viewport3D split boundaries handled by a hybrid compositor caller.

Source

pub fn render_display_list_to_view( &mut self, collector: &mut UnifiedGpuCollector, list: &DisplayList, target_view: &TextureView, target_width: u32, target_height: u32, dpr: f32, clear_color: Option<[f32; 4]>, damage: Option<Rect>, ) -> GpuBatchSummary

Compiles list with collector and renders all 2D GPU batches (GpuBatch, GpuPathBatch, GpuSlugTextPipeline, and GpuStencilClipPipeline clip masks) directly into target_view.

Source

pub fn render_display_list_offscreen( &mut self, collector: &mut UnifiedGpuCollector, list: &DisplayList, width: u32, height: u32, dpr: f32, clear_color: [f32; 4], damage: Option<Rect>, readback: bool, ) -> Result<(GpuBatchSummary, Vec<u8>), String>

Renders list into a reusable hardware offscreen texture and reads back RGBA/BGRA bytes (matching Self::color_format) when readback is true.

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

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

impl<T> Upcast<T> for T

Source§

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

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,