mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-26 22:53:15 -04:00
* Use requestAnimationFrame for polling wasm * Implement `requestAnimationFrame` for stdweb Co-authored-by: Ryan G <ryanisaacg@users.noreply.github.com>
41 lines
853 B
Rust
41 lines
853 B
Rust
use super::backend;
|
|
use crate::event_loop::ControlFlow;
|
|
|
|
use instant::Instant;
|
|
|
|
#[derive(Debug)]
|
|
pub enum State {
|
|
Init,
|
|
WaitUntil {
|
|
timeout: backend::Timeout,
|
|
start: Instant,
|
|
end: Instant,
|
|
},
|
|
Wait {
|
|
start: Instant,
|
|
},
|
|
Poll {
|
|
request: backend::AnimationFrameRequest,
|
|
},
|
|
Exit,
|
|
}
|
|
|
|
impl State {
|
|
pub fn is_exit(&self) -> bool {
|
|
match self {
|
|
State::Exit => true,
|
|
_ => false,
|
|
}
|
|
}
|
|
|
|
pub fn control_flow(&self) -> ControlFlow {
|
|
match self {
|
|
State::Init => ControlFlow::Poll,
|
|
State::WaitUntil { end, .. } => ControlFlow::WaitUntil(*end),
|
|
State::Wait { .. } => ControlFlow::Wait,
|
|
State::Poll { .. } => ControlFlow::Poll,
|
|
State::Exit => ControlFlow::Exit,
|
|
}
|
|
}
|
|
}
|