Skip to main content

SurfaceTarget

Struct SurfaceTarget 

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

GLFWWebGPUBackend’s surface without the window: frames presented to a wgpu::Surface.

Implementations§

Source§

impl SurfaceTarget

Source

pub fn new( backend: Rc<RendererBackend>, surface: Surface<'static>, framebuffer_size: Size, options: SurfaceOptions, ) -> Result<SurfaceTarget, Error>

A target on backend that presents to surface, made with the instance of the backend’s device, at framebuffer_size physical pixels. The surface is configured with the device’s surface format, or with the first of BGRA8 and RGBA8 that the surface supports.

Fails with ErrorKind::Unsupported when the device’s adapter can’t present to the surface or the surface supports none of those formats, and with ErrorKind::InvalidArgument when the device has neither an adapter to ask nor a surface format.

Source

pub fn backend(&self) -> &Rc<RendererBackend>

The backend the target draws on.

Source

pub fn format(&self) -> TextureFormat

The format the surface is configured with.

Source

pub fn size(&self) -> Size

The size of the frames, in physical pixels.

Source

pub fn resize(&self, size: Size)

setFramebufferSize(Size): draws the next frame at size physical pixels.

Source

pub fn process_events(&self)

processEvents()

Source

pub fn request_readback(&self)

Port-only: copy the next presented frame (see take_readback).

Source

pub fn take_readback(&self) -> Option<PremultipliedImage>

Port-only: the frame copied after request_readback, once presented and mapped (natively at once; in the browser on a later turn of the event loop).

Source

pub fn set_overlay(&self, overlay: Option<Overlay>)

Port-only: draws overlay over each frame from now on, after the map and before the frame is presented (and read back), or stops with None.

Trait Implementations§

Source§

impl Drop for SurfaceTarget

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl FrameTarget for SurfaceTarget

Source§

fn begin_frame(&self) -> Option<Rc<dyn DrawTarget>>

Acquires the surface’s next texture, unless the frame has one. A frame without one is skipped: a render pass without a color attachment trips the drawables’ debug assertions.

Source§

fn end_frame(&self, encoder: &dyn GfxCommandEncoder) -> Handoff

Submits what the renderer recorded into encoder for the frame, and hands the frame’s image off.

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