diff options
author | 2024-01-18 09:55:27 +0100 | |
---|---|---|
committer | 2024-01-18 09:55:27 +0100 | |
commit | 8bf238697226e827dc983f9d89afbd0e252c5254 (patch) | |
tree | 3594e998d60b130ab6b161aa00159e2311cbde0a /wgpu | |
parent | 7289b6091b61b0aa448a756cfe32211c78a4cce0 (diff) | |
download | iced-8bf238697226e827dc983f9d89afbd0e252c5254.tar.gz iced-8bf238697226e827dc983f9d89afbd0e252c5254.tar.bz2 iced-8bf238697226e827dc983f9d89afbd0e252c5254.zip |
Remove `Compositor` window generic
And update `glyphon` and `window_clipboard`
Diffstat (limited to '')
-rw-r--r-- | wgpu/Cargo.toml | 1 | ||||
-rw-r--r-- | wgpu/src/window/compositor.rs | 40 |
2 files changed, 13 insertions, 28 deletions
diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index a460c127..1d3b57a7 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -32,7 +32,6 @@ glyphon.workspace = true guillotiere.workspace = true log.workspace = true once_cell.workspace = true -raw-window-handle.workspace = true wgpu.workspace = true lyon.workspace = true diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs index e2dc4901..0c063d0b 100644 --- a/wgpu/src/window/compositor.rs +++ b/wgpu/src/window/compositor.rs @@ -6,13 +6,11 @@ use crate::graphics::compositor; use crate::graphics::{Error, Viewport}; use crate::{Backend, Primitive, Renderer, Settings}; -use raw_window_handle::{HasDisplayHandle, HasWindowHandle}; - use std::marker::PhantomData; /// A window graphics backend for iced powered by `wgpu`. #[allow(missing_debug_implementations)] -pub struct Compositor<W, Theme> { +pub struct Compositor<Theme> { settings: Settings, instance: wgpu::Instance, adapter: wgpu::Adapter, @@ -20,16 +18,13 @@ pub struct Compositor<W, Theme> { queue: wgpu::Queue, format: wgpu::TextureFormat, theme: PhantomData<Theme>, - w: PhantomData<W>, } -impl<W: HasWindowHandle + HasDisplayHandle + wgpu::WasmNotSendSync, Theme> - Compositor<W, Theme> -{ +impl<Theme> Compositor<Theme> { /// Requests a new [`Compositor`] with the given [`Settings`]. /// /// Returns `None` if no compatible graphics adapter could be found. - pub async fn request( + pub async fn request<W: compositor::Window>( settings: Settings, compatible_window: Option<W>, ) -> Option<Self> { @@ -45,7 +40,7 @@ impl<W: HasWindowHandle + HasDisplayHandle + wgpu::WasmNotSendSync, Theme> let available_adapters: Vec<_> = instance .enumerate_adapters(settings.internal_backend) .iter() - .map(|adapter| adapter.get_info()) + .map(wgpu::Adapter::get_info) .collect(); log::info!("Available adapters: {available_adapters:#?}"); } @@ -129,7 +124,6 @@ impl<W: HasWindowHandle + HasDisplayHandle + wgpu::WasmNotSendSync, Theme> queue, format, theme: PhantomData, - w: PhantomData, }) } @@ -141,13 +135,10 @@ impl<W: HasWindowHandle + HasDisplayHandle + wgpu::WasmNotSendSync, Theme> /// Creates a [`Compositor`] and its [`Backend`] for the given [`Settings`] and /// window. -pub fn new< - Theme, - W: HasWindowHandle + HasDisplayHandle + wgpu::WasmNotSendSync, ->( +pub fn new<W: compositor::Window, Theme>( settings: Settings, compatible_window: Option<W>, -) -> Result<Compositor<W, Theme>, Error> { +) -> Result<Compositor<Theme>, Error> { let compositor = futures::executor::block_on(Compositor::request( settings, compatible_window, @@ -158,8 +149,8 @@ pub fn new< } /// Presents the given primitives with the given [`Compositor`] and [`Backend`]. -pub fn present<W, Theme, T: AsRef<str>>( - compositor: &mut Compositor<W, Theme>, +pub fn present<Theme, T: AsRef<str>>( + compositor: &mut Compositor<Theme>, backend: &mut Backend, surface: &mut wgpu::Surface<'static>, primitives: &[Primitive], @@ -212,17 +203,12 @@ pub fn present<W, Theme, T: AsRef<str>>( } } -impl< - W: HasDisplayHandle + HasWindowHandle + wgpu::WasmNotSendSync + 'static, - Theme, - > graphics::Compositor<W> for Compositor<W, Theme> -{ +impl<Theme> graphics::Compositor for Compositor<Theme> { type Settings = Settings; type Renderer = Renderer<Theme>; - // XXX generic instead of 'static type Surface = wgpu::Surface<'static>; - fn new( + fn new<W: compositor::Window>( settings: Self::Settings, compatible_window: Option<W>, ) -> Result<Self, Error> { @@ -237,7 +223,7 @@ impl< ) } - fn create_surface( + fn create_surface<W: compositor::Window>( &mut self, window: W, width: u32, @@ -328,8 +314,8 @@ impl< /// Renders the current surface to an offscreen buffer. /// /// Returns RGBA bytes of the texture data. -pub fn screenshot<W, Theme, T: AsRef<str>>( - compositor: &Compositor<W, Theme>, +pub fn screenshot<Theme, T: AsRef<str>>( + compositor: &Compositor<Theme>, backend: &mut Backend, primitives: &[Primitive], viewport: &Viewport, |