summaryrefslogtreecommitdiffstats
path: root/graphics/src/compositor.rs
diff options
context:
space:
mode:
authorLibravatar Bingus <shankern@protonmail.com>2023-03-25 10:45:39 -0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-06-06 15:37:30 +0200
commit233196eb14b40f8bd5201ea0262571f82136ad53 (patch)
tree410cf71cda98bdcb55ecc384f7fbc2f4ef669edd /graphics/src/compositor.rs
parentc15f1b5f6575792cc89bb5fba2e613428397e46a (diff)
downloadiced-233196eb14b40f8bd5201ea0262571f82136ad53.tar.gz
iced-233196eb14b40f8bd5201ea0262571f82136ad53.tar.bz2
iced-233196eb14b40f8bd5201ea0262571f82136ad53.zip
Added offscreen rendering support for wgpu & tiny-skia exposed with the window::screenshot command.
Diffstat (limited to 'graphics/src/compositor.rs')
-rw-r--r--graphics/src/compositor.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/graphics/src/compositor.rs b/graphics/src/compositor.rs
index d55e801a..f7b86045 100644
--- a/graphics/src/compositor.rs
+++ b/graphics/src/compositor.rs
@@ -59,6 +59,19 @@ pub trait Compositor: Sized {
background_color: Color,
overlay: &[T],
) -> Result<(), SurfaceError>;
+
+ /// Screenshots the current [`Renderer`] primitives to an offscreen texture, and returns the bytes of
+ /// the texture ordered as `RGBA` in the sRGB color space.
+ ///
+ /// [`Renderer`]: Self::Renderer;
+ fn screenshot<T: AsRef<str>>(
+ &mut self,
+ renderer: &mut Self::Renderer,
+ surface: &mut Self::Surface,
+ viewport: &Viewport,
+ background_color: Color,
+ overlay: &[T],
+ ) -> Vec<u8>;
}
/// Result of an unsuccessful call to [`Compositor::present`].
@@ -82,7 +95,7 @@ pub enum SurfaceError {
OutOfMemory,
}
-/// Contains informations about the graphics (e.g. graphics adapter, graphics backend).
+/// Contains information about the graphics (e.g. graphics adapter, graphics backend).
#[derive(Debug)]
pub struct Information {
/// Contains the graphics adapter.