summaryrefslogtreecommitdiffstats
path: root/tiny_skia
diff options
context:
space:
mode:
authorLibravatar Ian Douglas Scott <idscott@system76.com>2024-11-21 16:26:17 -0800
committerLibravatar Ian Douglas Scott <idscott@system76.com>2024-11-21 16:26:17 -0800
commit3fc57b7d95f2cd1d8c7bef06547c55195d4e032a (patch)
treeb65138fc4913efa5c30f09e853fcfc0b2477e93f /tiny_skia
parent2a2e20b0a35bcf4da9ac34ab2f664485c4e1dbe3 (diff)
downloadiced-3fc57b7d95f2cd1d8c7bef06547c55195d4e032a.tar.gz
iced-3fc57b7d95f2cd1d8c7bef06547c55195d4e032a.tar.bz2
iced-3fc57b7d95f2cd1d8c7bef06547c55195d4e032a.zip
Remove `surface` argument of `Compositor::screenshot`
This argument was completely ignored by the wgpu renderer, and used only for the `clip_mask` by the `tiny_skia` renderer. I believe creating a new clip mask is correct. This way it's possible to render offscreen without needing a surface.
Diffstat (limited to 'tiny_skia')
-rw-r--r--tiny_skia/src/window/compositor.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/tiny_skia/src/window/compositor.rs b/tiny_skia/src/window/compositor.rs
index 153af6d5..6c144be0 100644
--- a/tiny_skia/src/window/compositor.rs
+++ b/tiny_skia/src/window/compositor.rs
@@ -121,12 +121,11 @@ impl crate::graphics::Compositor for Compositor {
fn screenshot<T: AsRef<str>>(
&mut self,
renderer: &mut Self::Renderer,
- surface: &mut Self::Surface,
viewport: &Viewport,
background_color: Color,
overlay: &[T],
) -> Vec<u8> {
- screenshot(renderer, surface, viewport, background_color, overlay)
+ screenshot(renderer, viewport, background_color, overlay)
}
}
@@ -212,7 +211,6 @@ pub fn present<T: AsRef<str>>(
pub fn screenshot<T: AsRef<str>>(
renderer: &mut Renderer,
- surface: &mut Surface,
viewport: &Viewport,
background_color: Color,
overlay: &[T],
@@ -222,6 +220,9 @@ pub fn screenshot<T: AsRef<str>>(
let mut offscreen_buffer: Vec<u32> =
vec![0; size.width as usize * size.height as usize];
+ let mut clip_mask = tiny_skia::Mask::new(size.width, size.height)
+ .expect("Create clip mask");
+
renderer.draw(
&mut tiny_skia::PixmapMut::from_bytes(
bytemuck::cast_slice_mut(&mut offscreen_buffer),
@@ -229,7 +230,7 @@ pub fn screenshot<T: AsRef<str>>(
size.height,
)
.expect("Create offscreen pixel map"),
- &mut surface.clip_mask,
+ &mut clip_mask,
viewport,
&[Rectangle::with_size(Size::new(
size.width as f32,