pub struct WgpuWindowPresenter { /* private fields */ }Expand description
Hardware wgpu window surface presenter managing 3D rendering, hardware 2D/stencil-clip
Wgpu2DRenderer batches, and cached 2D HUD compositing.
Implementations§
Source§impl WgpuWindowPresenter
impl WgpuWindowPresenter
Sourcepub fn new_offscreen(present_mode: PresentMode) -> Result<Self, String>
pub fn new_offscreen(present_mode: PresentMode) -> Result<Self, String>
Creates an offscreen-capable WgpuWindowPresenter with BGRA8 pixel format matching Cairo.
Sourcepub unsafe fn from_raw_handles(
window_handle: RawWindowHandle,
display_handle: RawDisplayHandle,
width: u32,
height: u32,
present_mode: PresentMode,
) -> Result<Self, String>
pub unsafe fn from_raw_handles( window_handle: RawWindowHandle, display_handle: RawDisplayHandle, width: u32, height: u32, present_mode: PresentMode, ) -> Result<Self, String>
Creates a WgpuWindowPresenter bound directly to a native window/display handle pair.
§Safety
window_handle and display_handle must remain valid for the lifetime of this presenter.
pub fn renderer_mut(&mut self) -> &mut Wgpu3DRenderer
pub fn renderer_2d(&self) -> &Wgpu2DRenderer
pub fn renderer_2d_mut(&mut self) -> &mut Wgpu2DRenderer
pub fn batch_collector(&self) -> &UnifiedGpuCollector
pub fn last_batch_summary(&self) -> GpuBatchSummary
pub fn stencil_clip_pipeline(&self) -> &GpuStencilClipPipeline
pub fn active_wgpu_present_mode(&self) -> Option<PresentMode>
pub fn surface_size(&self) -> (u32, u32)
pub fn has_surface(&self) -> bool
pub fn resize(&mut self, width: u32, height: u32)
Sourcepub fn upload_ui_overlay_bgra(&mut self, width: u32, height: u32, bgra: &[u8])
pub fn upload_ui_overlay_bgra(&mut self, width: u32, height: u32, bgra: &[u8])
Uploads a new cached 2D UI HUD overlay (BGRA8 pixels matching Cairo ARgb32).
Called only when 2D layout/DOM paint_dirty repaints; unchanged camera-only 3D frames
reuse this GPU texture with zero CPU work.
Sourcepub fn upload_ui_overlay_bgra_rects(
&mut self,
width: u32,
height: u32,
stride: usize,
bgra: &[u8],
rects: &[(u32, u32, u32, u32)],
scratch: &mut Vec<u8>,
)
pub fn upload_ui_overlay_bgra_rects( &mut self, width: u32, height: u32, stride: usize, bgra: &[u8], rects: &[(u32, u32, u32, u32)], scratch: &mut Vec<u8>, )
Uploads only damaged sub-rectangles of the 2D UI HUD overlay texture, avoiding full-frame 8 MB CPU-to-GPU transfers when only small labels or HUD counters changed.
Sourcepub fn present_to_surface(
&mut self,
scene: &Scene3D,
viewport: Option<[f32; 4]>,
draw_overlay: bool,
) -> Result<(), String>
pub fn present_to_surface( &mut self, scene: &Scene3D, viewport: Option<[f32; 4]>, draw_overlay: bool, ) -> Result<(), String>
Presents scene directly to the swapchain surface and composites cached 2D UI overlay if enabled.
Sourcepub fn present_viewports_to_surface(
&mut self,
viewports: &[([f32; 4], &Scene3D)],
draw_overlay: bool,
) -> Result<(), String>
pub fn present_viewports_to_surface( &mut self, viewports: &[([f32; 4], &Scene3D)], draw_overlay: bool, ) -> Result<(), String>
Presents one or more 3D viewports directly into the single swapchain frame and composites the cached 2D UI overlay once on top before presenting.
Sourcepub fn present_display_list_to_surface(
&mut self,
list: &DisplayList,
logical_width: f32,
logical_height: f32,
dpr: f32,
damage: Option<Rect>,
clear_color: [f32; 4],
) -> Result<GpuBatchSummary, String>
pub fn present_display_list_to_surface( &mut self, list: &DisplayList, logical_width: f32, logical_height: f32, dpr: f32, damage: Option<Rect>, clear_color: [f32; 4], ) -> Result<GpuBatchSummary, String>
Presents an entire DisplayList (2D quads, vector paths with caps/joins, dashed strokes,
Slug text, polygonal GpuStencilClipPipeline masks, and any interleaved DrawViewport3D)
directly onto the hardware wgpu::Surface swapchain via UnifiedGpuCollector + Wgpu2DRenderer.
Sourcepub fn present_overlay_to_surface(
&mut self,
clear_color: [f32; 4],
) -> Result<(), String>
pub fn present_overlay_to_surface( &mut self, clear_color: [f32; 4], ) -> Result<(), String>
Presents the cached ui_overlay texture directly onto the swapchain surface.
Sourcepub fn render_display_list_offscreen_bgra(
&mut self,
list: &DisplayList,
width: u32,
height: u32,
dpr: f32,
damage: Option<Rect>,
clear_color: [f32; 4],
readback: bool,
) -> Result<(GpuBatchSummary, Vec<u8>), String>
pub fn render_display_list_offscreen_bgra( &mut self, list: &DisplayList, width: u32, height: u32, dpr: f32, damage: Option<Rect>, clear_color: [f32; 4], readback: bool, ) -> Result<(GpuBatchSummary, Vec<u8>), String>
Renders a DisplayList (pure 2D or hybrid 3D+2D) via UnifiedGpuCollector,
GpuStencilClipPipeline, and Wgpu2DRenderer into an offscreen BGRA8 target,
returning raw BGRA8 pixels when readback is true.
Sourcepub fn render_offscreen_bgra(
&mut self,
scene: &Scene3D,
width: u32,
height: u32,
readback: bool,
) -> Result<Vec<u8>, String>
pub fn render_offscreen_bgra( &mut self, scene: &Scene3D, width: u32, height: u32, readback: bool, ) -> Result<Vec<u8>, String>
Offscreen render returning BGRA8 pixels (or empty vec if readback == false).