struct SurfaceWrapper {
surface: Option<Surface<'static>>,
config: Option<SurfaceConfiguration>,
}Expand description
Wrapper type which manages the surface and surface configuration.
As surface usage varies per platform, wrapping this up cleans up the event loop code.
Fields§
§surface: Option<Surface<'static>>§config: Option<SurfaceConfiguration>Implementations§
Source§impl SurfaceWrapper
impl SurfaceWrapper
Sourcefn pre_adapter(&mut self, instance: &Instance, window: Arc<Window>)
fn pre_adapter(&mut self, instance: &Instance, window: Arc<Window>)
Called after the instance is created, but before we request an adapter.
On wasm, we need to create the surface here, as the WebGL backend needs a surface (and hence a canvas) to be present to create the adapter.
We cannot unconditionally create a surface here, as Android requires
us to wait until we receive the Resumed event to do so.
Sourcefn resume(&mut self, context: &ExampleContext, window: Arc<Window>, srgb: bool)
fn resume(&mut self, context: &ExampleContext, window: Arc<Window>, srgb: bool)
Called on resume to create (on native) and configure the surface.
On all native platforms, this is where we create the surface.
On wasm, the surface was already created in Self::pre_adapter.
Additionally, we configure the surface based on the (now valid) window size.
Sourcefn resize(&mut self, context: &ExampleContext, size: PhysicalSize<u32>)
fn resize(&mut self, context: &ExampleContext, size: PhysicalSize<u32>)
Resize the surface, making sure to not resize to zero.
Sourcefn acquire(
&mut self,
context: &ExampleContext,
window: Arc<Window>,
) -> Option<SurfaceTexture>
fn acquire( &mut self, context: &ExampleContext, window: Arc<Window>, ) -> Option<SurfaceTexture>
Acquire the next surface texture.
Returns None on failure.
Sourcefn suspend(&mut self)
fn suspend(&mut self)
On suspend on android, we drop the surface, as it’s no longer valid.
A suspend event is always followed by at least one resume event.
fn get(&self) -> Option<&Surface<'static>>
fn config(&self) -> &SurfaceConfiguration
Auto Trait Implementations§
impl !Freeze for SurfaceWrapper
impl !RefUnwindSafe for SurfaceWrapper
impl Send for SurfaceWrapper
impl Sync for SurfaceWrapper
impl Unpin for SurfaceWrapper
impl !UnwindSafe for SurfaceWrapper
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more