diff options
author | 2023-06-27 20:37:19 +0200 | |
---|---|---|
committer | 2023-06-27 20:37:19 +0200 | |
commit | f6966268bb6d58b4b03ba61fc5732e1bf016e2a1 (patch) | |
tree | c8e79670b59fdd19103cb1a3a6d18783136e2294 /graphics/src | |
parent | ef18ecf4ef0fe654578380059b467fe2fb34aa0a (diff) | |
parent | 5b6e205e998cbb20b3c8aaff8b515d78315d6703 (diff) | |
download | iced-f6966268bb6d58b4b03ba61fc5732e1bf016e2a1.tar.gz iced-f6966268bb6d58b4b03ba61fc5732e1bf016e2a1.tar.bz2 iced-f6966268bb6d58b4b03ba61fc5732e1bf016e2a1.zip |
Merge pull request #1845 from bungoboingo/feat/offscreen-rendering
Feat: Offscreen Rendering & Screenshots
Diffstat (limited to 'graphics/src')
-rw-r--r-- | graphics/src/compositor.rs | 15 |
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. |