diff options
author | 2024-01-18 10:52:25 +0100 | |
---|---|---|
committer | 2024-01-18 10:52:25 +0100 | |
commit | 3cf8f77d6537f9d864f4a554b2fff46676a761f6 (patch) | |
tree | c937d2f3240cb938d7dc6dbe64e6ac4d39c4c3b5 /tiny_skia | |
parent | 150ce65e209414847ae133a70c833addd3086e15 (diff) | |
download | iced-3cf8f77d6537f9d864f4a554b2fff46676a761f6.tar.gz iced-3cf8f77d6537f9d864f4a554b2fff46676a761f6.tar.bz2 iced-3cf8f77d6537f9d864f4a554b2fff46676a761f6.zip |
Resize surface in `configure_surface` in `iced_tiny_skia`
Diffstat (limited to 'tiny_skia')
-rw-r--r-- | tiny_skia/src/window/compositor.rs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/tiny_skia/src/window/compositor.rs b/tiny_skia/src/window/compositor.rs index 08a49bc5..17d21100 100644 --- a/tiny_skia/src/window/compositor.rs +++ b/tiny_skia/src/window/compositor.rs @@ -57,14 +57,18 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> { ) .expect("Create softbuffer surface for window"); - Surface { + let mut surface = Surface { window, clip_mask: tiny_skia::Mask::new(width, height) .expect("Create clip mask"), primitive_stack: VecDeque::new(), background_color: Color::BLACK, max_age: 0, - } + }; + + self.configure_surface(&mut surface, width, height); + + surface } fn configure_surface( @@ -73,6 +77,14 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> { width: u32, height: u32, ) { + surface + .window + .resize( + NonZeroU32::new(width).expect("Non-zero width"), + NonZeroU32::new(height).expect("Non-zero height"), + ) + .expect("Resize surface"); + surface.clip_mask = tiny_skia::Mask::new(width, height).expect("Create clip mask"); surface.primitive_stack.clear(); @@ -152,14 +164,6 @@ pub fn present<T: AsRef<str>>( let physical_size = viewport.physical_size(); let scale_factor = viewport.scale_factor() as f32; - surface - .window - .resize( - NonZeroU32::new(physical_size.width).unwrap(), - NonZeroU32::new(physical_size.height).unwrap(), - ) - .unwrap(); - let mut buffer = surface .window .buffer_mut() |