summaryrefslogtreecommitdiffstats
path: root/tiny_skia
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-01-18 10:06:30 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-01-18 10:06:30 +0100
commit5fc49edc55a0e64c4c46ca55eddafe9d4e8232e1 (patch)
treedef282b187be48e4b61cfd55cbe243a3dd1191f8 /tiny_skia
parent1701ec815d3f25ea8097e806081e7a3ac9ba4d82 (diff)
downloadiced-5fc49edc55a0e64c4c46ca55eddafe9d4e8232e1.tar.gz
iced-5fc49edc55a0e64c4c46ca55eddafe9d4e8232e1.tar.bz2
iced-5fc49edc55a0e64c4c46ca55eddafe9d4e8232e1.zip
Make `compatible_window` mandatory in `Compositor`
Diffstat (limited to 'tiny_skia')
-rw-r--r--tiny_skia/src/window/compositor.rs26
1 files changed, 10 insertions, 16 deletions
diff --git a/tiny_skia/src/window/compositor.rs b/tiny_skia/src/window/compositor.rs
index b5e9bcd8..86400aa0 100644
--- a/tiny_skia/src/window/compositor.rs
+++ b/tiny_skia/src/window/compositor.rs
@@ -9,7 +9,7 @@ use std::marker::PhantomData;
use std::num::NonZeroU32;
pub struct Compositor<Theme> {
- context: Option<softbuffer::Context<Box<dyn compositor::Window>>>,
+ context: softbuffer::Context<Box<dyn compositor::Window>>,
settings: Settings,
_theme: PhantomData<Theme>,
}
@@ -32,7 +32,7 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
fn new<W: compositor::Window>(
settings: Self::Settings,
- compatible_window: Option<W>,
+ compatible_window: W,
) -> Result<Self, Error> {
Ok(new(settings, compatible_window))
}
@@ -51,17 +51,11 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
width: u32,
height: u32,
) -> Surface {
- let window = if let Some(context) = self.context.as_ref() {
- softbuffer::Surface::new(context, Box::new(window.clone()) as _)
- .expect("Create softbuffer surface for window")
- } else {
- let context =
- softbuffer::Context::new(Box::new(window.clone()) as _)
- .expect("Create softbuffer context for window");
-
- softbuffer::Surface::new(&context, Box::new(window.clone()) as _)
- .expect("Create softbuffer surface for window")
- };
+ let window = softbuffer::Surface::new(
+ &self.context,
+ Box::new(window.clone()) as _,
+ )
+ .expect("Create softbuffer surface for window");
Surface {
window,
@@ -133,11 +127,11 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
pub fn new<W: compositor::Window, Theme>(
settings: Settings,
- compatible_window: Option<W>,
+ compatible_window: W,
) -> Compositor<Theme> {
#[allow(unsafe_code)]
- let context = compatible_window
- .and_then(|w| softbuffer::Context::new(Box::new(w) as _).ok());
+ let context = softbuffer::Context::new(Box::new(compatible_window) as _)
+ .expect("Create softbuffer context");
Compositor {
context,