pub struct SsSurfaceWeb { /* private fields */ }Expand description
One canvas and the scene drawn into it. Holds any number of
players, composited in ascending order in a single render pass.
Implementations§
Source§impl SsSurfaceWeb
impl SsSurfaceWeb
Sourcepub fn create_player(&self) -> Result<SsPlayerWeb, JsValue>
pub fn create_player(&self) -> Result<SsPlayerWeb, JsValue>
Add a player to this canvas. Players hold no GPU resource of their own, so a canvas with a dozen characters still costs one device, one renderer and one scene.
Sourcepub fn frame(&self, dt: f32) -> Result<(), JsValue>
pub fn frame(&self, dt: f32) -> Result<(), JsValue>
Advance every player on this canvas by dt seconds and render one frame.
A no-op while the device is lost — every GPU object it would touch is
dead. The host polls SsContextWeb::is_device_lost and calls
restoreDevice to resume.
Sourcepub fn resize(&self, width: u32, height: u32)
pub fn resize(&self, width: u32, height: u32)
Resize the swapchain, the stencil buffer and the projection to the canvas’s new pixel size.
Sourcepub fn set_group_alpha(&self, on: bool) -> Result<(), JsValue>
pub fn set_group_alpha(&self, on: bool) -> Result<(), JsValue>
Fade each player whose alpha is below 1 as one layer, composited at its alpha, rather than part by part — so overlapping parts of a half-faded character read half, not three quarters. Off by default.
Each player faded at once costs a render pass per frame and a layer the
size of the canvas (about 8 MiB at 1920x1080), counted in
stats().groupLayers; turning it off frees them. Inside a layer the parts
blend against transparency rather than the page: Add, Mul and Screen
parts composite with the player’s own parts alone.
Sourcepub fn group_alpha(&self) -> Result<bool, JsValue>
pub fn group_alpha(&self) -> Result<bool, JsValue>
Whether setGroupAlpha is on.
Sourcepub fn stats(&self) -> Result<Object, JsValue>
pub fn stats(&self) -> Result<Object, JsValue>
What the last frame cost, as a plain JS object.
gpuPassTimeNs is undefined unless the browser granted
timestamp-query, and lags one or two frames by design. The counters are
always available: mergeableDraws counts the draw calls that could have
joined the one before them, and redundantTextureBinds the texture binds
that repeated the one before them.
Sourcepub fn player_count(&self) -> usize
pub fn player_count(&self) -> usize
How many players draw into this canvas (diagnostic).
Sourcepub fn destroy(&self)
pub fn destroy(&self)
Detach this canvas and release its swapchain, scene and players.
Explicit because dropping the JS wrapper cannot do it: the surface lives in the shared context, not in this handle. Calling it twice, or calling anything else afterwards, is safe — the handle resolves to “destroyed”.
Trait Implementations§
Source§impl From<SsSurfaceWeb> for JsValue
impl From<SsSurfaceWeb> for JsValue
Source§fn from(value: SsSurfaceWeb) -> Self
fn from(value: SsSurfaceWeb) -> Self
Source§impl FromWasmAbi for SsSurfaceWeb
impl FromWasmAbi for SsSurfaceWeb
Source§impl IntoWasmAbi for SsSurfaceWeb
impl IntoWasmAbi for SsSurfaceWeb
Source§impl LongRefFromWasmAbi for SsSurfaceWeb
impl LongRefFromWasmAbi for SsSurfaceWeb
Source§type Abi = WasmPtr<WasmRefCell<SsSurfaceWeb>>
type Abi = WasmPtr<WasmRefCell<SsSurfaceWeb>>
RefFromWasmAbi::AbiSource§type Anchor = RcRef<SsSurfaceWeb>
type Anchor = RcRef<SsSurfaceWeb>
RefFromWasmAbi::AnchorSource§unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abiSource§impl NullableFromWasmAbi for SsSurfaceWeb
impl NullableFromWasmAbi for SsSurfaceWeb
Source§impl NullableIntoWasmAbi for SsSurfaceWeb
impl NullableIntoWasmAbi for SsSurfaceWeb
Source§impl OptionFromWasmAbi for SsSurfaceWeb
impl OptionFromWasmAbi for SsSurfaceWeb
Source§impl OptionIntoWasmAbi for SsSurfaceWeb
impl OptionIntoWasmAbi for SsSurfaceWeb
Source§impl RefFromWasmAbi for SsSurfaceWeb
impl RefFromWasmAbi for SsSurfaceWeb
Source§type Abi = WasmPtr<WasmRefCell<SsSurfaceWeb>>
type Abi = WasmPtr<WasmRefCell<SsSurfaceWeb>>
Self are recovered from.Source§type Anchor = RcRef<SsSurfaceWeb>
type Anchor = RcRef<SsSurfaceWeb>
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl RefMutFromWasmAbi for SsSurfaceWeb
impl RefMutFromWasmAbi for SsSurfaceWeb
Source§type Abi = WasmPtr<WasmRefCell<SsSurfaceWeb>>
type Abi = WasmPtr<WasmRefCell<SsSurfaceWeb>>
RefFromWasmAbi::AbiSource§type Anchor = RcRefMut<SsSurfaceWeb>
type Anchor = RcRefMut<SsSurfaceWeb>
RefFromWasmAbi::AnchorSource§unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abiimpl SupportsConstructor for SsSurfaceWeb
impl SupportsInstanceProperty for SsSurfaceWeb
impl SupportsStaticProperty for SsSurfaceWeb
Source§impl TryFromJsValue for SsSurfaceWeb
impl TryFromJsValue for SsSurfaceWeb
Source§fn try_from_js_value_ref(value: &JsValue) -> Option<Self>
fn try_from_js_value_ref(value: &JsValue) -> Option<Self>
Source§const NULLABLE: bool = false
const NULLABLE: bool = false
Self accepts null as a distinct value space, as
Nullable<T> does. An enclosing Option then passes null through
instead of reading it as None, so Option<T> is itself nullable
exactly when T is not. JsValue does not set this: it accepts
null as one value among all of them, not as a distinct space, and
Option<JsValue> reads it as None like the ABI does. This is the
JS-value side of NullableFromWasmAbi, which claims null at the
ABI.Source§impl VectorFromWasmAbi for SsSurfaceWeb
impl VectorFromWasmAbi for SsSurfaceWeb
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[SsSurfaceWeb]>
Source§impl VectorIntoWasmAbi for SsSurfaceWeb
impl VectorIntoWasmAbi for SsSurfaceWeb
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[SsSurfaceWeb]>) -> Self::Abi
Source§impl WasmDescribeVector for SsSurfaceWeb
impl WasmDescribeVector for SsSurfaceWeb
Auto Trait Implementations§
impl !RefUnwindSafe for SsSurfaceWeb
impl !Send for SsSurfaceWeb
impl !Sync for SsSurfaceWeb
impl !UnwindSafe for SsSurfaceWeb
impl Freeze for SsSurfaceWeb
impl Unpin for SsSurfaceWeb
impl UnsafeUnpin for SsSurfaceWeb
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> MaybeFromWasmAbi for Twhere
T: OptionFromWasmAbi,
impl<T> MaybeFromWasmAbi for Twhere
T: OptionFromWasmAbi,
Source§type MaybeAbi = <T as FromWasmAbi>::Abi
type MaybeAbi = <T as FromWasmAbi>::Abi
Option<Self>.Source§unsafe fn from_maybe_abi(js: <T as FromWasmAbi>::Abi) -> T
unsafe fn from_maybe_abi(js: <T as FromWasmAbi>::Abi) -> T
unsafe fn try_from_maybe_abi( js: <T as FromWasmAbi>::Abi, ) -> Result<T, &'static str>
Source§impl<T> MaybeIntoWasmAbi for Twhere
T: OptionIntoWasmAbi,
impl<T> MaybeIntoWasmAbi for Twhere
T: OptionIntoWasmAbi,
Source§type MaybeAbi = <T as IntoWasmAbi>::Abi
type MaybeAbi = <T as IntoWasmAbi>::Abi
Option<Self>.Source§fn into_maybe_abi(self) -> <T as IntoWasmAbi>::Abi
fn into_maybe_abi(self) -> <T as IntoWasmAbi>::Abi
Option<Self> ABI.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.