diff options
author | 2024-01-19 20:28:45 +0100 | |
---|---|---|
committer | 2024-01-19 20:28:45 +0100 | |
commit | 7ae7fcb89855002519bab752fd3686106ce448db (patch) | |
tree | ac717dbd031e243519b446ab45e5008adef4f5dc /graphics | |
parent | 61e3d8502fec7e83c584218e598fa20c79363be3 (diff) | |
parent | 9df7bf8ec30ca76016018bc758b4323760e231b0 (diff) | |
download | iced-7ae7fcb89855002519bab752fd3686106ce448db.tar.gz iced-7ae7fcb89855002519bab752fd3686106ce448db.tar.bz2 iced-7ae7fcb89855002519bab752fd3686106ce448db.zip |
Merge pull request #2191 from ids1024/raw-window-handle-0.6
Update `wgpu` to `0.19`, `glyphon` to `0.5`, `softbuffer` to `0.4`, `window-clipboard` to `0.4`, and `raw-window-handle` to `0.6`
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/Cargo.toml | 1 | ||||
-rw-r--r-- | graphics/src/compositor.rs | 27 | ||||
-rw-r--r-- | graphics/src/lib.rs | 1 |
3 files changed, 23 insertions, 6 deletions
diff --git a/graphics/Cargo.toml b/graphics/Cargo.toml index 6741d7cf..4f323f9e 100644 --- a/graphics/Cargo.toml +++ b/graphics/Cargo.toml @@ -21,6 +21,7 @@ web-colors = [] [dependencies] iced_core.workspace = true +iced_futures.workspace = true bitflags.workspace = true bytemuck.workspace = true diff --git a/graphics/src/compositor.rs b/graphics/src/compositor.rs index b8b575b4..0188f4d8 100644 --- a/graphics/src/compositor.rs +++ b/graphics/src/compositor.rs @@ -2,9 +2,10 @@ //! surfaces. use crate::{Error, Viewport}; -use iced_core::Color; +use crate::core::Color; +use crate::futures::{MaybeSend, MaybeSync}; -use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle}; +use raw_window_handle::{HasDisplayHandle, HasWindowHandle}; use thiserror::Error; /// A graphics compositor that can draw to windows. @@ -19,9 +20,9 @@ pub trait Compositor: Sized { type Surface; /// Creates a new [`Compositor`]. - fn new<W: HasRawWindowHandle + HasRawDisplayHandle>( + fn new<W: Window + Clone>( settings: Self::Settings, - compatible_window: Option<&W>, + compatible_window: W, ) -> Result<Self, Error>; /// Creates a [`Self::Renderer`] for the [`Compositor`]. @@ -30,9 +31,9 @@ pub trait Compositor: Sized { /// Crates a new [`Surface`] for the given window. /// /// [`Surface`]: Self::Surface - fn create_surface<W: HasRawWindowHandle + HasRawDisplayHandle>( + fn create_surface<W: Window + Clone>( &mut self, - window: &W, + window: W, width: u32, height: u32, ) -> Self::Surface; @@ -77,6 +78,20 @@ pub trait Compositor: Sized { ) -> Vec<u8>; } +/// A window that can be used in a [`Compositor`]. +/// +/// This is just a convenient super trait of the `raw-window-handle` +/// traits. +pub trait Window: + HasWindowHandle + HasDisplayHandle + MaybeSend + MaybeSync + 'static +{ +} + +impl<T> Window for T where + T: HasWindowHandle + HasDisplayHandle + MaybeSend + MaybeSync + 'static +{ +} + /// Result of an unsuccessful call to [`Compositor::present`]. #[derive(Clone, PartialEq, Eq, Debug, Error)] pub enum SurfaceError { diff --git a/graphics/src/lib.rs b/graphics/src/lib.rs index 7a213909..76de56bf 100644 --- a/graphics/src/lib.rs +++ b/graphics/src/lib.rs @@ -50,3 +50,4 @@ pub use transformation::Transformation; pub use viewport::Viewport; pub use iced_core as core; +pub use iced_futures as futures; |