Skip to main content

BrowserSurface

Struct BrowserSurface 

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

The state every surface of a view has: its canvas, its compositor and its size in device pixels and logical units.

Implementations§

Source§

impl BrowserSurface

Source

pub fn new(js_surface: CanvasSurface, compositor: Rc<Compositor>) -> Self

Creates the surface state for a canvas of the page.

Source

pub fn compositor(&self) -> Rc<Compositor>

The compositor that renders to the surface.

Source

pub fn scaling(&self) -> f64

The scaling from logical units to device pixels.

Source

pub fn client_size(&self) -> Size

The size in logical units.

Source

pub fn render_size(&self) -> PixelSize

The size in device pixels.

Source

pub fn is_valid(&self) -> bool

Whether the surface has a size it can be rendered at.

Source

pub fn size_changed(&self, handler: Rc<dyn Fn()>) -> u64

Subscribes to changes of the client size.

Source

pub fn scaling_changed(&self, handler: Rc<dyn Fn()>) -> u64

Subscribes to changes of the scaling.

Source

pub fn initial_size(&self) -> Option<(f64, f64, f64)>

The size and the scaling the canvas has right now, as (pixel width, pixel height, scaling); None once disposed.

Source

pub fn dispose(&self)

Releases the canvas surface.

Source

pub fn on_size_changed(&self, pixel_width: f64, pixel_height: f64, dpr: f64)

Records the size of the canvas and raises the change events.

pixel_width and pixel_height are in device pixels; dpr is the device pixel ratio.

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<T> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). Read more
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, 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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more