pub struct SharedView(/* private fields */);Expand description
A program’s view, shared by the program and the surfaces made on it: the window wgpu makes a
surface for, as an HTML canvas is on the web. It is the view’s Arc with the window handle
Rust’s orphan rule keeps off Arc<View>, so it dereferences to the view; every clone is the
same view.
let view = wasdk_wgpu::SharedView::new(view);
let surface = instance.create_surface(view.clone())?;
view.request_frame();Implementations§
pub fn new(view: View) -> SharedView
Methods from Deref<Target = View>§
pub fn id(&self) -> u64
Sourcepub fn request_id(&self) -> Option<u64>
pub fn request_id(&self) -> Option<u64>
The request this view arrived for; none for a view the shell gave.
Sourcepub fn initial_data(&self) -> Option<String>
pub fn initial_data(&self) -> Option<String>
What the request this view arrived for attached; none for a view the shell gave, or a request that attached nothing.
Sourcepub fn window(&self) -> Option<Window>
pub fn window(&self) -> Option<Window>
The window this view is in; none where the platform shows it without one.
Sourcepub fn screen(&self) -> Option<Screen>
pub fn screen(&self) -> Option<Screen>
The screen this view is on now; none while it is on no screen.
Sourcepub fn context(&self) -> GpuCanvasContext
pub fn context(&self) -> GpuCanvasContext
The WebGPU context that draws into this view.
Sourcepub fn set_canvas_size(&self, width: u32, height: u32)
pub fn set_canvas_size(&self, width: u32, height: u32)
Sets the size of the textures the view’s canvas hands out, in physical pixels: the size the program draws its pictures at, kept until set again, whatever the view’s size, and taken from the canvas’s next texture on. The canvas has no size until one is set: configuring a context on it, or taking a texture, before then traps the program, as does a size of zero, or one past the largest 2D texture of the device the context is configured against.
Sourcepub fn events(
&self,
) -> Option<RawStreamReader<&'static StreamVtable<ViewEvent>>>
pub fn events( &self, ) -> Option<RawStreamReader<&'static StreamVtable<ViewEvent>>>
Everything that happens to this view and to what holds it, in the order it happened, from the view’s opening on. Nothing is lost: while the program is behind, a pointer’s consecutive moves are merged into the latest, and so are consecutive changes of geometry. A view has one reader: the first call takes the stream, and a later one answers none. The stream ends when the view is gone.
Sourcepub fn request_frame(&self)
pub fn request_frame(&self)
Asks for one frame event at the next refresh of the screen the view is on. Asking
again before it arrives changes nothing. None arrive while the view is not on screen,
or on no screen: the frame asked for then arrives at the first refresh after it is.
Sourcepub fn set_layers(&self, layers: &[PlacedLayer<'_>])
pub fn set_layers(&self, layers: &[PlacedLayer<'_>])
Sets the layers beneath the view’s picture, each with its placement, the bottom-most first. They are kept until set again, and the view’s next present shows them; a layer the list does not name is taken off with that present’s picture.
Sourcepub fn present(&self)
pub fn present(&self)
Puts the texture last taken from the context on screen, with the view’s layers beneath it, once the GPU has finished the work the program submitted and the writes it queued before this call. A present with no picture drawn since the last does nothing, its layers included, since a layer moves with the picture that makes room for it: layers set since wait for the next picture.
Sourcepub fn set_cursor(&self, cursor: Cursor)
pub fn set_cursor(&self, cursor: Cursor)
The cursor to show while a pointer is over this view.
Sourcepub fn text_input(&self) -> Option<TextInput>
pub fn text_input(&self) -> Option<TextInput>
How the platform’s input methods and on-screen keyboard edit text the program draws in this view; none where the platform has no text input for it.
Sourcepub fn request_focus_change(
&self,
state: ViewFocusState,
direction: ViewFocusDirection,
)
pub fn request_focus_change( &self, state: ViewFocusState, direction: ViewFocusDirection, )
Asks the platform to give this view the input focus, or to take it away: Flutter’s
requestViewFocusChange. A platform that cannot move its focus does nothing.
Trait Implementations§
Source§fn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError>
fn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError>
The web’s display, which carries nothing: the view is reached through its window handle.
Source§fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError>
fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError>
A WebCanvas handle pointing at this view.
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CommonTraits for T
impl<T> DisplayAndWindowHandle for Twhere
T: WindowHandle + HasDisplayHandle,
Source§impl<T> HasRawDisplayHandle for Twhere
T: HasDisplayHandle + ?Sized,
impl<T> HasRawDisplayHandle for Twhere
T: HasDisplayHandle + ?Sized,
Source§fn raw_display_handle(&self) -> Result<RawDisplayHandle, HandleError>
fn raw_display_handle(&self) -> Result<RawDisplayHandle, HandleError>
Use HasDisplayHandle instead
Source§impl<T> HasRawWindowHandle for Twhere
T: HasWindowHandle + ?Sized,
impl<T> HasRawWindowHandle for Twhere
T: HasWindowHandle + ?Sized,
Source§fn raw_window_handle(&self) -> Result<RawWindowHandle, HandleError>
fn raw_window_handle(&self) -> Result<RawWindowHandle, HandleError>
Use HasWindowHandle instead