Skip to main content

SharedView

Struct SharedView 

Source
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§

Methods from Deref<Target = View>§

Source

pub fn id(&self) -> u64

Source

pub fn request_id(&self) -> Option<u64>

The request this view arrived for; none for a view the shell gave.

Source

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.

Source

pub fn window(&self) -> Option<Window>

The window this view is in; none where the platform shows it without one.

Source

pub fn screen(&self) -> Option<Screen>

The screen this view is on now; none while it is on no screen.

Source

pub fn context(&self) -> GpuCanvasContext

The WebGPU context that draws into this view.

Source

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.

Source

pub fn metrics(&self) -> Metrics

The view’s current geometry.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn set_cursor(&self, cursor: Cursor)

The cursor to show while a pointer is over this view.

Source

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.

Source

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§

impl Clone for SharedView

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SharedView

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for SharedView

Source§

type Target = View

The resulting type after dereferencing.
Source§

fn deref(&self) -> &View

Dereferences the value.
Source§

impl HasDisplayHandle for SharedView

Source§

fn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError>

The web’s display, which carries nothing: the view is reached through its window handle.

Source§

impl HasWindowHandle for SharedView

Source§

fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError>

A WebCanvas handle pointing at this view.

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> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> CommonTraits for T
where T: AsAny + Any + Debug + WasmNotSendSync,

Source§

impl<T> DisplayAndWindowHandle for T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HasRawDisplayHandle for T
where T: HasDisplayHandle + ?Sized,

Source§

fn raw_display_handle(&self) -> Result<RawDisplayHandle, HandleError>

👎Deprecated:

Use HasDisplayHandle instead

Source§

impl<T> HasRawWindowHandle for T
where T: HasWindowHandle + ?Sized,

Source§

fn raw_window_handle(&self) -> Result<RawWindowHandle, HandleError>

👎Deprecated:

Use HasWindowHandle instead

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Resource for T
where T: 'static,

Source§

type Rep = Option<T>

The type which is actually stored in-memory for this resource. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WgpuHasDisplayHandle for T
where T: HasDisplayHandle + Debug + Send + Sync + 'static,

Source§

impl<T> WindowHandle for T