Remove SwapChain associated type from Compositor
This commit is contained in:
parent
8a7c91bcb2
commit
fe0de182c5
3 changed files with 16 additions and 24 deletions
|
|
@ -16,9 +16,6 @@ pub trait Compositor: Sized {
|
||||||
/// The surface of the backend.
|
/// The surface of the backend.
|
||||||
type Surface;
|
type Surface;
|
||||||
|
|
||||||
/// The swap chain of the backend.
|
|
||||||
type SwapChain;
|
|
||||||
|
|
||||||
/// Creates a new [`Compositor`].
|
/// Creates a new [`Compositor`].
|
||||||
fn new<W: HasRawWindowHandle>(
|
fn new<W: HasRawWindowHandle>(
|
||||||
settings: Self::Settings,
|
settings: Self::Settings,
|
||||||
|
|
@ -37,12 +34,12 @@ pub trait Compositor: Sized {
|
||||||
///
|
///
|
||||||
/// [`SwapChain`]: Self::SwapChain
|
/// [`SwapChain`]: Self::SwapChain
|
||||||
/// [`Surface`]: Self::Surface
|
/// [`Surface`]: Self::Surface
|
||||||
fn create_swap_chain(
|
fn configure_surface(
|
||||||
&mut self,
|
&mut self,
|
||||||
surface: &Self::Surface,
|
surface: &mut Self::Surface,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Self::SwapChain;
|
);
|
||||||
|
|
||||||
/// Draws the output primitives to the next frame of the given [`SwapChain`].
|
/// Draws the output primitives to the next frame of the given [`SwapChain`].
|
||||||
///
|
///
|
||||||
|
|
@ -50,7 +47,6 @@ pub trait Compositor: Sized {
|
||||||
fn draw<T: AsRef<str>>(
|
fn draw<T: AsRef<str>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
renderer: &mut Self::Renderer,
|
renderer: &mut Self::Renderer,
|
||||||
swap_chain: &mut Self::SwapChain,
|
|
||||||
surface: &mut Self::Surface,
|
surface: &mut Self::Surface,
|
||||||
viewport: &Viewport,
|
viewport: &Viewport,
|
||||||
background_color: Color,
|
background_color: Color,
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,6 @@ impl iced_graphics::window::Compositor for Compositor {
|
||||||
type Settings = Settings;
|
type Settings = Settings;
|
||||||
type Renderer = Renderer;
|
type Renderer = Renderer;
|
||||||
type Surface = wgpu::Surface;
|
type Surface = wgpu::Surface;
|
||||||
type SwapChain = ();
|
|
||||||
|
|
||||||
fn new<W: HasRawWindowHandle>(
|
fn new<W: HasRawWindowHandle>(
|
||||||
settings: Self::Settings,
|
settings: Self::Settings,
|
||||||
|
|
@ -115,12 +114,12 @@ impl iced_graphics::window::Compositor for Compositor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_swap_chain(
|
fn configure_surface(
|
||||||
&mut self,
|
&mut self,
|
||||||
surface: &Self::Surface,
|
surface: &mut Self::Surface,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Self::SwapChain {
|
) {
|
||||||
surface.configure(
|
surface.configure(
|
||||||
&self.device,
|
&self.device,
|
||||||
&wgpu::SurfaceConfiguration {
|
&wgpu::SurfaceConfiguration {
|
||||||
|
|
@ -130,13 +129,12 @@ impl iced_graphics::window::Compositor for Compositor {
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
},
|
},
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw<T: AsRef<str>>(
|
fn draw<T: AsRef<str>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
renderer: &mut Self::Renderer,
|
renderer: &mut Self::Renderer,
|
||||||
_swap_chain: &mut Self::SwapChain,
|
|
||||||
surface: &mut Self::Surface,
|
surface: &mut Self::Surface,
|
||||||
viewport: &Viewport,
|
viewport: &Viewport,
|
||||||
background_color: Color,
|
background_color: Color,
|
||||||
|
|
|
||||||
|
|
@ -232,15 +232,14 @@ async fn run_instance<A, E, C>(
|
||||||
|
|
||||||
let mut state = State::new(&application, &window);
|
let mut state = State::new(&application, &window);
|
||||||
let mut viewport_version = state.viewport_version();
|
let mut viewport_version = state.viewport_version();
|
||||||
let mut swap_chain = {
|
|
||||||
let physical_size = state.physical_size();
|
|
||||||
|
|
||||||
compositor.create_swap_chain(
|
let physical_size = state.physical_size();
|
||||||
&surface,
|
|
||||||
physical_size.width,
|
compositor.configure_surface(
|
||||||
physical_size.height,
|
&mut surface,
|
||||||
)
|
physical_size.width,
|
||||||
};
|
physical_size.height,
|
||||||
|
);
|
||||||
|
|
||||||
let mut user_interface = ManuallyDrop::new(build_user_interface(
|
let mut user_interface = ManuallyDrop::new(build_user_interface(
|
||||||
&mut application,
|
&mut application,
|
||||||
|
|
@ -358,8 +357,8 @@ async fn run_instance<A, E, C>(
|
||||||
.draw(&mut renderer, state.cursor_position());
|
.draw(&mut renderer, state.cursor_position());
|
||||||
debug.draw_finished();
|
debug.draw_finished();
|
||||||
|
|
||||||
swap_chain = compositor.create_swap_chain(
|
compositor.configure_surface(
|
||||||
&surface,
|
&mut surface,
|
||||||
physical_size.width,
|
physical_size.width,
|
||||||
physical_size.height,
|
physical_size.height,
|
||||||
);
|
);
|
||||||
|
|
@ -369,7 +368,6 @@ async fn run_instance<A, E, C>(
|
||||||
|
|
||||||
match compositor.draw(
|
match compositor.draw(
|
||||||
&mut renderer,
|
&mut renderer,
|
||||||
&mut swap_chain,
|
|
||||||
&mut surface,
|
&mut surface,
|
||||||
state.viewport(),
|
state.viewport(),
|
||||||
state.background_color(),
|
state.background_color(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue