Added offscreen rendering support for wgpu & tiny-skia exposed with the window::screenshot command.

This commit is contained in:
Bingus 2023-03-25 10:45:39 -07:00 committed by Héctor Ramón Jiménez
parent c15f1b5f65
commit 233196eb14
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
16 changed files with 893 additions and 24 deletions

View file

@ -1,6 +1,7 @@
use crate::core::window::{Icon, Level, Mode, UserAttention};
use crate::futures::MaybeSend;
use crate::screenshot::Screenshot;
use std::fmt;
/// An operation to be performed on some window.
@ -89,6 +90,8 @@ pub enum Action<T> {
/// - **X11:** Has no universal guidelines for icon sizes, so you're at the whims of the WM. That
/// said, it's usually in the same ballpark as on Windows.
ChangeIcon(Icon),
/// Screenshot the viewport of the window.
Screenshot(Box<dyn FnOnce(Screenshot) -> T + 'static>),
}
impl<T> Action<T> {
@ -118,6 +121,11 @@ impl<T> Action<T> {
Self::ChangeLevel(level) => Action::ChangeLevel(level),
Self::FetchId(o) => Action::FetchId(Box::new(move |s| f(o(s)))),
Self::ChangeIcon(icon) => Action::ChangeIcon(icon),
Self::Screenshot(tag) => {
Action::Screenshot(Box::new(move |screenshot| {
f(tag(screenshot))
}))
}
}
}
}
@ -155,6 +163,7 @@ impl<T> fmt::Debug for Action<T> {
Self::ChangeIcon(_icon) => {
write!(f, "Action::ChangeIcon(icon)")
}
Self::Screenshot(_) => write!(f, "Action::Screenshot"),
}
}
}