2020-05-20 20:28:35 +02:00
|
|
|
use crate::Viewport;
|
|
|
|
|
use iced_native::mouse;
|
2020-02-09 03:25:13 +01:00
|
|
|
use raw_window_handle::HasRawWindowHandle;
|
|
|
|
|
|
2020-05-19 20:01:55 +02:00
|
|
|
/// A graphics compositor that can draw to windows.
|
|
|
|
|
pub trait Compositor: Sized {
|
2020-02-09 03:25:13 +01:00
|
|
|
/// The settings of the backend.
|
2020-05-21 04:27:31 +02:00
|
|
|
type Settings: Default;
|
2020-02-09 03:25:13 +01:00
|
|
|
|
|
|
|
|
/// The iced renderer of the backend.
|
2020-05-20 20:28:35 +02:00
|
|
|
type Renderer: iced_native::Renderer;
|
2020-02-09 03:25:13 +01:00
|
|
|
|
|
|
|
|
/// The surface of the backend.
|
|
|
|
|
type Surface;
|
|
|
|
|
|
|
|
|
|
/// The swap chain of the backend.
|
|
|
|
|
type SwapChain;
|
|
|
|
|
|
2020-05-19 14:23:28 +02:00
|
|
|
/// Creates a new [`Backend`].
|
2020-02-09 03:25:13 +01:00
|
|
|
///
|
|
|
|
|
/// [`Backend`]: trait.Backend.html
|
2020-05-21 04:27:31 +02:00
|
|
|
fn new(settings: Self::Settings) -> (Self, Self::Renderer);
|
2020-02-09 03:25:13 +01:00
|
|
|
|
|
|
|
|
/// 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,
|
2020-05-20 20:28:35 +02:00
|
|
|
viewport: &Viewport,
|
|
|
|
|
output: &<Self::Renderer as iced_native::Renderer>::Output,
|
2020-02-09 03:25:13 +01:00
|
|
|
overlay: &[T],
|
2020-04-30 08:16:38 +02:00
|
|
|
) -> mouse::Interaction;
|
2020-02-09 03:25:13 +01:00
|
|
|
}
|