pebble/rendering/
window.rs1use raw_window_handle::{HasDisplayHandle, HasWindowHandle};
2
3pub trait GPUSurfaceHandle:
4 HasWindowHandle + HasDisplayHandle + Send + Sync + Clone + 'static
5{
6}
7
8impl<T> GPUSurfaceHandle for T where
9 T: HasWindowHandle + HasDisplayHandle + Send + Sync + Clone + 'static
10{
11}
12
13pub struct WindowConfig {
14 pub title: &'static str,
15 pub width: u32,
16 pub height: u32,
17}
18
19pub trait WindowProvider: 'static {
20 type Handle: GPUSurfaceHandle;
21 type Exposed: Clone + Send + Sync + 'static;
22
23 fn create(config: &WindowConfig) -> Self;
24 fn size(handle: &Self::Handle) -> (u32, u32);
25 fn exposed(&self) -> Self::Exposed;
26 fn handle(&self) -> &Self::Handle;
27}
28
29pub trait PresentableWindow: WindowProvider
30where
31 Self::Handle: GPUSurfaceHandle,
32{
33}
34
35pub trait WindowRunner: WindowProvider {
36 fn run(self, on_frame: impl FnMut() + 'static);
37}
38
39pub struct WindowResource<W: WindowProvider> {
40 pub handle: W::Handle,
41 pub exposed: W::Exposed,
42}