pub struct SurfaceTarget { /* private fields */ }Expand description
Frames presented to a wgpu::Surface.
The surface is configured when a frame begins at a size it isn’t configured at, so a target that replaces another on the same window configures it only after the other one has let go of it. A minimized window’s frames keep the size the surface was last configured at.
Implementations§
Source§impl SurfaceTarget
impl SurfaceTarget
Sourcepub fn new(
backend: &RendererBackend,
surface: Surface<'static>,
framebuffer_size: Size,
options: SurfaceOptions,
) -> Result<SurfaceTarget, Error>
pub fn new( backend: &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 options’ format, or the
device’s surface format, or else an 8-bit RGBA or BGRA format that
the surface supports: in the browser the one the canvas prefers, and
elsewhere the first of BGRA8 and RGBA8.
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.
Sourcepub fn format(&self) -> TextureFormat
pub fn format(&self) -> TextureFormat
The format the surface is configured with.
Sourcepub fn request_readback(&mut self)
pub fn request_readback(&mut self)
Copies the next presented frame, for take_readback.
Sourcepub fn take_readback(&mut self, gpu: &mut WebGpu) -> Option<FramePixels>
pub fn take_readback(&mut self, gpu: &mut WebGpu) -> Option<FramePixels>
The frame copied after request_readback,
once it is presented and mapped: natively at once, and in the browser
on a later turn of the event loop.
Sourcepub fn set_overlay(&mut self, overlay: Option<Overlay>)
pub fn set_overlay(&mut self, overlay: Option<Overlay>)
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 FrameTarget for SurfaceTarget
impl FrameTarget for SurfaceTarget
Source§fn resize(&mut self, _gpu: &mut WebGpu, size: Size)
fn resize(&mut self, _gpu: &mut WebGpu, size: Size)
Draws the next frame at size physical pixels.
Source§fn begin_frame(&mut self, gpu: &mut WebGpu) -> Option<FrameImage>
fn begin_frame(&mut self, gpu: &mut WebGpu) -> Option<FrameImage>
Acquires the surface’s next texture, unless the frame has one. A frame without one is skipped.