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 start_condition(e: &Event<()>) -> bool
fn start_condition(e: &Event<()>) -> bool
Check if the event is the start condition for the surface.
Sourcefn resume(&mut self, context: &ExampleContext, window: Arc<Window>, srgb: bool)
fn resume(&mut self, context: &ExampleContext, window: Arc<Window>, srgb: bool)
Called when an event which matches Self::start_condition
is received.
On all native platforms, this is where we create the surface.
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) -> SurfaceTexture
fn acquire(&mut self, context: &ExampleContext) -> SurfaceTexture
Acquire the next surface texture.
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<'_>>
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.