diff options
author | 2021-08-05 14:44:32 +0700 | |
---|---|---|
committer | 2021-08-05 14:44:32 +0700 | |
commit | 45778ed598c0d202f8e86c47a444fd671fb3abce (patch) | |
tree | f0d7cd40b34bf4dca465fb6fd8fdeec5b0209e72 /graphics/src | |
parent | 63bdbf817e0ecd8ce9162f2b8cc5eaefb5b42e68 (diff) | |
parent | 3e03a42bc69562639784a1b560978bf184576824 (diff) | |
download | iced-45778ed598c0d202f8e86c47a444fd671fb3abce.tar.gz iced-45778ed598c0d202f8e86c47a444fd671fb3abce.tar.bz2 iced-45778ed598c0d202f8e86c47a444fd671fb3abce.zip |
Merge pull request #667 from BillyDM/wgpu_outdatedframe
Don't panic when wgpu swapchain frame is outdated
Diffstat (limited to 'graphics/src')
-rw-r--r-- | graphics/src/window.rs | 2 | ||||
-rw-r--r-- | graphics/src/window/compositor.rs | 26 |
2 files changed, 26 insertions, 2 deletions
diff --git a/graphics/src/window.rs b/graphics/src/window.rs index 3e74db5f..365ddfbc 100644 --- a/graphics/src/window.rs +++ b/graphics/src/window.rs @@ -4,7 +4,7 @@ mod compositor; #[cfg(feature = "opengl")] mod gl_compositor; -pub use compositor::Compositor; +pub use compositor::{Compositor, SwapChainError}; #[cfg(feature = "opengl")] pub use gl_compositor::GLCompositor; diff --git a/graphics/src/window/compositor.rs b/graphics/src/window/compositor.rs index 7d5d789b..de2a6990 100644 --- a/graphics/src/window/compositor.rs +++ b/graphics/src/window/compositor.rs @@ -1,6 +1,9 @@ use crate::{Color, Error, Viewport}; + use iced_native::mouse; + use raw_window_handle::HasRawWindowHandle; +use thiserror::Error; /// A graphics compositor that can draw to windows. pub trait Compositor: Sized { @@ -52,5 +55,26 @@ pub trait Compositor: Sized { background_color: Color, output: &<Self::Renderer as iced_native::Renderer>::Output, overlay: &[T], - ) -> mouse::Interaction; + ) -> Result<mouse::Interaction, SwapChainError>; +} + +/// Result of an unsuccessful call to [`Compositor::draw`]. +#[derive(Clone, PartialEq, Eq, Debug, Error)] +pub enum SwapChainError { + /// A timeout was encountered while trying to acquire the next frame. + #[error( + "A timeout was encountered while trying to acquire the next frame" + )] + Timeout, + /// The underlying surface has changed, and therefore the swap chain must be updated. + #[error( + "The underlying surface has changed, and therefore the swap chain must be updated." + )] + Outdated, + /// The swap chain has been lost and needs to be recreated. + #[error("The swap chain has been lost and needs to be recreated")] + Lost, + /// There is no more memory left to allocate a new frame. + #[error("There is no more memory left to allocate a new frame")] + OutOfMemory, } |