pub struct Renderer { /* private fields */ }Expand description
Holds the GPU state bound to a surface and presents the frames.
Implementations§
Source§impl Renderer
impl Renderer
Sourcepub async fn new(
target: impl Into<SurfaceTarget<'static>>,
width: u32,
height: u32,
) -> Result<Self>
pub async fn new( target: impl Into<SurfaceTarget<'static>>, width: u32, height: u32, ) -> Result<Self>
Initialises the GPU context for a given surface.
target is typically an Arc<Window> supplied by the platform layer.
width and height must both be > 0.
Sourcepub async fn see_through(
target: impl Into<SurfaceTarget<'static>>,
width: u32,
height: u32,
) -> Result<Self>
pub async fn see_through( target: impl Into<SurfaceTarget<'static>>, width: u32, height: u32, ) -> Result<Self>
A renderer whose frames let what is behind the window show where they are transparent (milestone 643): its frames start transparent, are composed with the window’s surroundings by the system’s compositor, and are made of premultiplied colours — which is what this renderer’s blending produces over a transparent start.
On Windows it presents through DirectComposition (Direct3D 12): where a frame is
transparent on the title bar’s line, the system’s own caption shows — its backdrop
and its three buttons. Fails where that is not available — another system, no
Direct3D 12 adapter, no premultiplied composition — and the caller then makes an
ordinary new one. Its owner paints backdrop wherever the window is
not meant to be seen through.
Sourcepub fn sees_through(&self) -> bool
pub fn sees_through(&self) -> bool
Whether this renderer’s frames let what is behind the window show where they are
transparent: made by see_through.
Sourcepub fn resize(&mut self, width: u32, height: u32)
pub fn resize(&mut self, width: u32, height: u32)
Reconfigures the surface after the window is resized. The painters’ viewports
are set every frame by Painters::render.
Sourcepub fn reconfigure(&mut self)
pub fn reconfigure(&mut self)
Reapplies the current configuration, after a lost or outdated surface.
Sourcepub fn last_timings(&self) -> RenderTimings
pub fn last_timings(&self) -> RenderTimings
Where the last render spent its time, in milliseconds: waiting for
a surface image to draw into, drawing into it (tessellating, encoding and submitting),
and handing it to the display (milestone 609). Zero on the web, which has no clock
here.
Sourcepub fn render(&mut self, scene: &Scene) -> RenderOutcome
pub fn render(&mut self, scene: &Scene) -> RenderOutcome
Draws the scene — rectangles, images, paths, text, layers — and presents it.