pub trait RenderTarget {
// Required methods
fn size(&self) -> PhysicalExtent;
fn format(&self) -> TextureFormat;
fn acquire_frame(&mut self) -> Result<RenderFrame, RendererError>;
// Provided methods
fn pre_present_notify(&self) { ... }
fn try_resize(
&mut self,
_size: PhysicalExtent,
) -> Result<ResizeOutcome, RendererError> { ... }
}Expand description
Host-agnostic render target that owns swapchain-like image acquisition.
Sizes are physical pixels and formats must match the renderer pipelines.
A target may defer resizing by returning ResizeOutcome::Deferred.
§Examples
use ailloli_ui_render_wgpu::{PhysicalExtent, RenderTarget};
fn dimensions(target: &impl RenderTarget) -> PhysicalExtent { target.size() }Required Methods§
Sourcefn size(&self) -> PhysicalExtent
fn size(&self) -> PhysicalExtent
Returns the current physical-pixel extent.
§Examples
use ailloli_ui_render_wgpu::RenderTarget;
fn width(target: &impl RenderTarget) -> u32 { target.size().width }Sourcefn format(&self) -> TextureFormat
fn format(&self) -> TextureFormat
Returns the texture format of subsequently acquired frames.
§Examples
use ailloli_ui_render_wgpu::RenderTarget;
fn format(target: &impl RenderTarget) -> wgpu::TextureFormat { target.format() }Sourcefn acquire_frame(&mut self) -> Result<RenderFrame, RendererError>
fn acquire_frame(&mut self) -> Result<RenderFrame, RendererError>
Acquires one renderable frame or a typed renderer error.
§Errors
Returns the target’s acquisition error, including typed surface timeout, loss, outdated, and out-of-memory conditions.
§Examples
use ailloli_ui_render_wgpu::{RenderFrame, RendererError, RenderTarget};
fn acquire(target: &mut impl RenderTarget) -> Result<RenderFrame, RendererError> {
target.acquire_frame()
}Provided Methods§
Sourcefn pre_present_notify(&self)
fn pre_present_notify(&self)
Gives the host a chance to notify its window system before presentation.
The default implementation is a no-op.
§Examples
use ailloli_ui_render_wgpu::RenderTarget;
fn notify(target: &impl RenderTarget) { target.pre_present_notify(); }Sourcefn try_resize(
&mut self,
_size: PhysicalExtent,
) -> Result<ResizeOutcome, RendererError>
fn try_resize( &mut self, _size: PhysicalExtent, ) -> Result<ResizeOutcome, RendererError>
Requests a new physical-pixel extent.
The default leaves the target unchanged. Implementations may configure immediately or return a deferred outcome for a zero-sized surface.
§Errors
Propagates target-specific reconfiguration failures.
§Examples
use ailloli_ui_render_wgpu::{PhysicalExtent, RenderTarget};
fn resize(target: &mut impl RenderTarget) {
let _ = target.try_resize(PhysicalExtent::new(800, 600));
}