Resize surface in configure_surface in iced_tiny_skia
This commit is contained in:
parent
150ce65e20
commit
3cf8f77d65
1 changed files with 14 additions and 10 deletions
|
|
@ -57,14 +57,18 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
|
||||||
)
|
)
|
||||||
.expect("Create softbuffer surface for window");
|
.expect("Create softbuffer surface for window");
|
||||||
|
|
||||||
Surface {
|
let mut surface = Surface {
|
||||||
window,
|
window,
|
||||||
clip_mask: tiny_skia::Mask::new(width, height)
|
clip_mask: tiny_skia::Mask::new(width, height)
|
||||||
.expect("Create clip mask"),
|
.expect("Create clip mask"),
|
||||||
primitive_stack: VecDeque::new(),
|
primitive_stack: VecDeque::new(),
|
||||||
background_color: Color::BLACK,
|
background_color: Color::BLACK,
|
||||||
max_age: 0,
|
max_age: 0,
|
||||||
}
|
};
|
||||||
|
|
||||||
|
self.configure_surface(&mut surface, width, height);
|
||||||
|
|
||||||
|
surface
|
||||||
}
|
}
|
||||||
|
|
||||||
fn configure_surface(
|
fn configure_surface(
|
||||||
|
|
@ -73,6 +77,14 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
|
||||||
width: u32,
|
width: u32,
|
||||||
height: 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 =
|
surface.clip_mask =
|
||||||
tiny_skia::Mask::new(width, height).expect("Create clip mask");
|
tiny_skia::Mask::new(width, height).expect("Create clip mask");
|
||||||
surface.primitive_stack.clear();
|
surface.primitive_stack.clear();
|
||||||
|
|
@ -152,14 +164,6 @@ pub fn present<T: AsRef<str>>(
|
||||||
let physical_size = viewport.physical_size();
|
let physical_size = viewport.physical_size();
|
||||||
let scale_factor = viewport.scale_factor() as f32;
|
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
|
let mut buffer = surface
|
||||||
.window
|
.window
|
||||||
.buffer_mut()
|
.buffer_mut()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue