Skip to main content

pebble/rendering/
window.rs

1use 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;
21
22    fn create(config: &WindowConfig) -> Self;
23    fn size(handle: &Self::Handle) -> (u32, u32);
24    fn handle(&self) -> &Self::Handle;
25}
26
27pub trait PresentableWindow: WindowProvider
28where
29    Self::Handle: GPUSurfaceHandle,
30{
31}
32
33pub trait WindowRunner: WindowProvider {
34    fn run(self, on_frame: impl FnMut() + 'static);
35}
36
37pub struct WindowResource<W: WindowProvider> {
38    pub handle: W::Handle,
39}