summaryrefslogtreecommitdiffstats
path: root/renderer
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2023-12-05 01:03:09 +0100
committerLibravatar GitHub <noreply@github.com>2023-12-05 01:03:09 +0100
commitfc285d3e461626408c56bbc1605fcf0c974b2f69 (patch)
tree8aca292516d9aa43b78a14f51dd90caf60c691d7 /renderer
parent8727b3fc50ec251d9c117c51ca1289be5ba9b117 (diff)
parent5c5e7653bed248ba63faa6563e4d673e4441415e (diff)
downloadiced-fc285d3e461626408c56bbc1605fcf0c974b2f69.tar.gz
iced-fc285d3e461626408c56bbc1605fcf0c974b2f69.tar.bz2
iced-fc285d3e461626408c56bbc1605fcf0c974b2f69.zip
Merge pull request #1964 from bungoboingo/feat/multi-window-support
[Feature] 🪟 Multi Window 🪟 .. redux!
Diffstat (limited to 'renderer')
-rw-r--r--renderer/src/compositor.rs48
1 files changed, 24 insertions, 24 deletions
diff --git a/renderer/src/compositor.rs b/renderer/src/compositor.rs
index d1500089..9d0ff9ab 100644
--- a/renderer/src/compositor.rs
+++ b/renderer/src/compositor.rs
@@ -26,7 +26,7 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
fn new<W: HasRawWindowHandle + HasRawDisplayHandle>(
settings: Self::Settings,
compatible_window: Option<&W>,
- ) -> Result<(Self, Self::Renderer), Error> {
+ ) -> Result<Self, Error> {
let candidates =
Candidate::list_from_env().unwrap_or(Candidate::default_list());
@@ -34,9 +34,7 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
for candidate in candidates {
match candidate.build(settings, compatible_window) {
- Ok((compositor, renderer)) => {
- return Ok((compositor, renderer))
- }
+ Ok(compositor) => return Ok(compositor),
Err(new_error) => {
error = new_error;
}
@@ -46,6 +44,18 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
Err(error)
}
+ fn create_renderer(&self) -> Self::Renderer {
+ match self {
+ Compositor::TinySkia(compositor) => {
+ Renderer::TinySkia(compositor.create_renderer())
+ }
+ #[cfg(feature = "wgpu")]
+ Compositor::Wgpu(compositor) => {
+ Renderer::Wgpu(compositor.create_renderer())
+ }
+ }
+ }
+
fn create_surface<W: HasRawWindowHandle + HasRawDisplayHandle>(
&mut self,
window: &W,
@@ -220,24 +230,21 @@ impl Candidate {
self,
settings: Settings,
_compatible_window: Option<&W>,
- ) -> Result<(Compositor<Theme>, Renderer<Theme>), Error> {
+ ) -> Result<Compositor<Theme>, Error> {
match self {
Self::TinySkia => {
- let (compositor, backend) =
- iced_tiny_skia::window::compositor::new();
+ let compositor = iced_tiny_skia::window::compositor::new(
+ iced_tiny_skia::Settings {
+ default_font: settings.default_font,
+ default_text_size: settings.default_text_size,
+ },
+ );
- Ok((
- Compositor::TinySkia(compositor),
- Renderer::TinySkia(iced_tiny_skia::Renderer::new(
- backend,
- settings.default_font,
- settings.default_text_size,
- )),
- ))
+ Ok(Compositor::TinySkia(compositor))
}
#[cfg(feature = "wgpu")]
Self::Wgpu => {
- let (compositor, backend) = iced_wgpu::window::compositor::new(
+ let compositor = iced_wgpu::window::compositor::new(
iced_wgpu::Settings {
default_font: settings.default_font,
default_text_size: settings.default_text_size,
@@ -247,14 +254,7 @@ impl Candidate {
_compatible_window,
)?;
- Ok((
- Compositor::Wgpu(compositor),
- Renderer::Wgpu(iced_wgpu::Renderer::new(
- backend,
- settings.default_font,
- settings.default_text_size,
- )),
- ))
+ Ok(Compositor::Wgpu(compositor))
}
#[cfg(not(feature = "wgpu"))]
Self::Wgpu => {