summaryrefslogtreecommitdiffstats
path: root/graphics/src/window/compositor.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-05-29 02:00:28 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-05-29 02:00:28 +0200
commit0cde20b3550ede81bc7ddef628b91eec225aa8af (patch)
tree56920437979012cceb49718f2dd4ce27d5ba5d40 /graphics/src/window/compositor.rs
parent67b6f044e870df41be92cdc79f571682b97a5d0d (diff)
parente11b5c614f5bf73c137b8b4f24f56047617527eb (diff)
downloadiced-0cde20b3550ede81bc7ddef628b91eec225aa8af.tar.gz
iced-0cde20b3550ede81bc7ddef628b91eec225aa8af.tar.bz2
iced-0cde20b3550ede81bc7ddef628b91eec225aa8af.zip
Merge branch 'master' into improvement/update-wgpu_glyph
Diffstat (limited to 'graphics/src/window/compositor.rs')
-rw-r--r--graphics/src/window/compositor.rs55
1 files changed, 55 insertions, 0 deletions
diff --git a/graphics/src/window/compositor.rs b/graphics/src/window/compositor.rs
new file mode 100644
index 00000000..d5920c95
--- /dev/null
+++ b/graphics/src/window/compositor.rs
@@ -0,0 +1,55 @@
+use crate::Viewport;
+use iced_native::mouse;
+use raw_window_handle::HasRawWindowHandle;
+
+/// A graphics compositor that can draw to windows.
+pub trait Compositor: Sized {
+ /// The settings of the backend.
+ type Settings: Default;
+
+ /// The iced renderer of the backend.
+ type Renderer: iced_native::Renderer;
+
+ /// The surface of the backend.
+ type Surface;
+
+ /// The swap chain of the backend.
+ type SwapChain;
+
+ /// Creates a new [`Backend`].
+ ///
+ /// [`Backend`]: trait.Backend.html
+ fn new(settings: Self::Settings) -> (Self, Self::Renderer);
+
+ /// Crates a new [`Surface`] for the given window.
+ ///
+ /// [`Surface`]: #associatedtype.Surface
+ fn create_surface<W: HasRawWindowHandle>(
+ &mut self,
+ window: &W,
+ ) -> Self::Surface;
+
+ /// Crates a new [`SwapChain`] for the given [`Surface`].
+ ///
+ /// [`SwapChain`]: #associatedtype.SwapChain
+ /// [`Surface`]: #associatedtype.Surface
+ fn create_swap_chain(
+ &mut self,
+ surface: &Self::Surface,
+ width: u32,
+ height: u32,
+ ) -> Self::SwapChain;
+
+ /// Draws the output primitives to the next frame of the given [`SwapChain`].
+ ///
+ /// [`SwapChain`]: #associatedtype.SwapChain
+ /// [`Surface`]: #associatedtype.Surface
+ fn draw<T: AsRef<str>>(
+ &mut self,
+ renderer: &mut Self::Renderer,
+ swap_chain: &mut Self::SwapChain,
+ viewport: &Viewport,
+ output: &<Self::Renderer as iced_native::Renderer>::Output,
+ overlay: &[T],
+ ) -> mouse::Interaction;
+}