@@ -3,37 +3,44 @@ use crate::graphics::compositor::{Information, SurfaceError};
33use crate :: graphics:: { Error , Viewport } ;
44use crate :: { Renderer , Settings } ;
55
6- use raw_window_handle:: { HasRawDisplayHandle , HasRawWindowHandle } ;
6+ use raw_window_handle:: { HasDisplayHandle , HasWindowHandle } ;
77use std:: env;
88
9- pub enum Compositor < Theme > {
10- TinySkia ( iced_tiny_skia:: window:: Compositor < Theme > ) ,
9+ pub enum Compositor < W : HasWindowHandle + HasDisplayHandle , Theme > {
10+ TinySkia ( iced_tiny_skia:: window:: Compositor < W , Theme > ) ,
1111 #[ cfg( feature = "wgpu" ) ]
12- Wgpu ( iced_wgpu:: window:: Compositor < Theme > ) ,
12+ Wgpu ( iced_wgpu:: window:: Compositor < W , Theme > ) ,
1313}
1414
15- pub enum Surface {
16- TinySkia ( iced_tiny_skia:: window:: Surface ) ,
15+ pub enum Surface < W : HasWindowHandle + HasDisplayHandle > {
16+ TinySkia ( iced_tiny_skia:: window:: Surface < W > ) ,
1717 #[ cfg( feature = "wgpu" ) ]
18- Wgpu ( iced_wgpu:: window:: Surface ) ,
18+ Wgpu ( iced_wgpu:: window:: Surface < ' static > ) ,
1919}
2020
21- impl < Theme > crate :: graphics:: Compositor for Compositor < Theme > {
21+ // XXX Clone bound
22+ // XXX Send/Sync?
23+ // 'static?
24+ impl <
25+ W : Clone + Send + Sync + HasWindowHandle + HasDisplayHandle + ' static ,
26+ Theme ,
27+ > crate :: graphics:: Compositor < W > for Compositor < W , Theme >
28+ {
2229 type Settings = Settings ;
2330 type Renderer = Renderer < Theme > ;
24- type Surface = Surface ;
31+ type Surface = Surface < W > ;
2532
26- fn new < W : HasRawWindowHandle + HasRawDisplayHandle > (
33+ fn new (
2734 settings : Self :: Settings ,
28- compatible_window : Option < & W > ,
35+ compatible_window : Option < W > ,
2936 ) -> Result < Self , Error > {
3037 let candidates =
3138 Candidate :: list_from_env ( ) . unwrap_or ( Candidate :: default_list ( ) ) ;
3239
3340 let mut error = Error :: GraphicsAdapterNotFound ;
3441
3542 for candidate in candidates {
36- match candidate. build ( settings, compatible_window) {
43+ match candidate. build ( settings, compatible_window. clone ( ) ) {
3744 Ok ( compositor) => return Ok ( compositor) ,
3845 Err ( new_error) => {
3946 error = new_error;
@@ -56,12 +63,12 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
5663 }
5764 }
5865
59- fn create_surface < W : HasRawWindowHandle + HasRawDisplayHandle > (
66+ fn create_surface (
6067 & mut self ,
61- window : & W ,
68+ window : W ,
6269 width : u32 ,
6370 height : u32 ,
64- ) -> Surface {
71+ ) -> Surface < W > {
6572 match self {
6673 Self :: TinySkia ( compositor) => Surface :: TinySkia (
6774 compositor. create_surface ( window, width, height) ,
@@ -75,7 +82,7 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
7582
7683 fn configure_surface (
7784 & mut self ,
78- surface : & mut Surface ,
85+ surface : & mut Surface < W > ,
7986 width : u32 ,
8087 height : u32 ,
8188 ) {
@@ -114,7 +121,7 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
114121 (
115122 Self :: TinySkia ( _compositor) ,
116123 crate :: Renderer :: TinySkia ( renderer) ,
117- Surface :: TinySkia ( surface) ,
124+ Surface :: TinySkia ( ref mut surface) ,
118125 ) => renderer. with_primitives ( |backend, primitives| {
119126 iced_tiny_skia:: window:: compositor:: present (
120127 backend,
@@ -129,7 +136,7 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
129136 (
130137 Self :: Wgpu ( compositor) ,
131138 crate :: Renderer :: Wgpu ( renderer) ,
132- Surface :: Wgpu ( surface) ,
139+ Surface :: Wgpu ( ref mut surface) ,
133140 ) => renderer. with_primitives ( |backend, primitives| {
134141 iced_wgpu:: window:: compositor:: present (
135142 compositor,
@@ -161,7 +168,7 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
161168 (
162169 Self :: TinySkia ( _compositor) ,
163170 Renderer :: TinySkia ( renderer) ,
164- Surface :: TinySkia ( surface) ,
171+ Surface :: TinySkia ( ref mut surface) ,
165172 ) => renderer. with_primitives ( |backend, primitives| {
166173 iced_tiny_skia:: window:: compositor:: screenshot (
167174 surface,
@@ -226,11 +233,11 @@ impl Candidate {
226233 )
227234 }
228235
229- fn build < Theme , W : HasRawWindowHandle + HasRawDisplayHandle > (
236+ fn build < Theme , W : HasWindowHandle + HasDisplayHandle + Send + Sync > (
230237 self ,
231238 settings : Settings ,
232- _compatible_window : Option < & W > ,
233- ) -> Result < Compositor < Theme > , Error > {
239+ _compatible_window : Option < W > ,
240+ ) -> Result < Compositor < W , Theme > , Error > {
234241 match self {
235242 Self :: TinySkia => {
236243 let compositor = iced_tiny_skia:: window:: compositor:: new (
0 commit comments