Skip to main content

Renderer

Struct Renderer 

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

Holds the GPU state bound to a surface and presents the frames.

Implementations§

Source§

impl Renderer

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn reconfigure(&mut self)

Reapplies the current configuration, after a lost or outdated surface.

Source

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.

Source

pub fn render(&mut self, scene: &Scene) -> RenderOutcome

Draws the scene — rectangles, images, paths, text, layers — and presents it.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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,