From d53ccc857da4d4cda769904342aeb5a82a64f146 Mon Sep 17 00:00:00 2001 From: Bingus Date: Wed, 12 Jul 2023 19:21:05 -0700 Subject: refactored window storage; new helper window events (Destroyed, Created); clippy + fmt; --- tiny_skia/src/window/compositor.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tiny_skia/src') diff --git a/tiny_skia/src/window/compositor.rs b/tiny_skia/src/window/compositor.rs index 775cf9e5..1aaba2c9 100644 --- a/tiny_skia/src/window/compositor.rs +++ b/tiny_skia/src/window/compositor.rs @@ -8,6 +8,7 @@ use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle}; use std::marker::PhantomData; pub struct Compositor { + settings: Settings, _theme: PhantomData, } @@ -33,6 +34,10 @@ impl crate::graphics::Compositor for Compositor { Ok((compositor, Renderer::new(backend))) } + fn renderer(&self) -> Self::Renderer { + Renderer::new(Backend::new(self.settings)) + } + fn create_surface( &mut self, window: &W, @@ -116,6 +121,7 @@ impl crate::graphics::Compositor for Compositor { pub fn new(settings: Settings) -> (Compositor, Backend) { ( Compositor { + settings, _theme: PhantomData, }, Backend::new(settings), -- cgit From b152ecda63238136f77b6eda3c582fa1eff99737 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 2 Dec 2023 20:49:47 +0100 Subject: Separate `Compositor::new` from `Compositor::create_renderer` --- tiny_skia/src/window/compositor.rs | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'tiny_skia/src') diff --git a/tiny_skia/src/window/compositor.rs b/tiny_skia/src/window/compositor.rs index 32095e23..87ded746 100644 --- a/tiny_skia/src/window/compositor.rs +++ b/tiny_skia/src/window/compositor.rs @@ -28,20 +28,11 @@ impl crate::graphics::Compositor for Compositor { fn new( settings: Self::Settings, _compatible_window: Option<&W>, - ) -> Result<(Self, Self::Renderer), Error> { - let (compositor, backend) = new(settings); - - Ok(( - compositor, - Renderer::new( - backend, - settings.default_font, - settings.default_text_size, - ), - )) + ) -> Result { + Ok(new(settings)) } - fn renderer(&self) -> Self::Renderer { + fn create_renderer(&self) -> Self::Renderer { Renderer::new( Backend::new(), self.settings.default_font, @@ -130,14 +121,11 @@ impl crate::graphics::Compositor for Compositor { } } -pub fn new(settings: Settings) -> (Compositor, Backend) { - ( - Compositor { - settings, - _theme: PhantomData, - }, - Backend::new(), - ) +pub fn new(settings: Settings) -> Compositor { + Compositor { + settings, + _theme: PhantomData, + } } pub fn present>( -- cgit