summaryrefslogtreecommitdiffstats
path: root/graphics/src/compositor.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--graphics/src/compositor.rs (renamed from graphics/src/window/compositor.rs)23
1 files changed, 20 insertions, 3 deletions
diff --git a/graphics/src/window/compositor.rs b/graphics/src/compositor.rs
index db4ba45d..f7b86045 100644
--- a/graphics/src/window/compositor.rs
+++ b/graphics/src/compositor.rs
@@ -1,6 +1,8 @@
//! A compositor is responsible for initializing a renderer and managing window
//! surfaces.
-use crate::{Color, Error, Viewport};
+use crate::{Error, Viewport};
+
+use iced_core::Color;
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
use thiserror::Error;
@@ -11,7 +13,7 @@ pub trait Compositor: Sized {
type Settings: Default;
/// The iced renderer of the backend.
- type Renderer: iced_native::Renderer;
+ type Renderer: iced_core::Renderer;
/// The surface of the backend.
type Surface;
@@ -28,6 +30,8 @@ pub trait Compositor: Sized {
fn create_surface<W: HasRawWindowHandle + HasRawDisplayHandle>(
&mut self,
window: &W,
+ width: u32,
+ height: u32,
) -> Self::Surface;
/// Configures a new [`Surface`] with the given dimensions.
@@ -55,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`].
@@ -78,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.