Trait Compositor

pub trait Compositor: Sized {
    type Renderer;
    type Surface;

    // Required methods
    fn with_backend(
        settings: Settings,
        display: impl Display + Clone,
        compatible_window: impl Window + Clone,
        shell: Shell,
        backend: Option<&str>,
    ) -> impl Future<Output = Result<Self, Error>>;
    fn create_renderer(&self) -> Self::Renderer;
    fn create_surface<W>(
        &mut self,
        window: W,
        width: u32,
        height: u32,
    ) -> Self::Surface
       where W: Window + Clone;
    fn configure_surface(
        &mut self,
        surface: &mut Self::Surface,
        width: u32,
        height: u32,
    );
    fn information(&self) -> Information;
    fn present(
        &mut self,
        renderer: &mut Self::Renderer,
        surface: &mut Self::Surface,
        viewport: &Viewport,
        background_color: Color,
        on_pre_present: impl FnOnce(),
    ) -> Result<(), SurfaceError>;
    fn screenshot(
        &mut self,
        renderer: &mut Self::Renderer,
        viewport: &Viewport,
        background_color: Color,
    ) -> Vec<u8> ;

    // Provided methods
    fn new(
        settings: Settings,
        display: impl Display + Clone,
        compatible_window: impl Window + Clone,
        shell: Shell,
    ) -> impl Future<Output = Result<Self, Error>> { ... }
    fn load_font(&mut self, font: Cow<'static, [u8]>) { ... }
}
Expand description

A graphics compositor that can draw to windows.

Required Associated Types§

type Renderer

The iced renderer of the backend.

type Surface

The surface of the backend.

Required Methods§

fn with_backend( settings: Settings, display: impl Display + Clone, compatible_window: impl Window + Clone, shell: Shell, backend: Option<&str>, ) -> impl Future<Output = Result<Self, Error>>

Creates a new Compositor with a backend preference.

If the backend does not match the preference, it will return Error::GraphicsAdapterNotFound.

fn create_renderer(&self) -> Self::Renderer

Creates a Self::Renderer for the Compositor.

fn create_surface<W>( &mut self, window: W, width: u32, height: u32, ) -> Self::Surface
where W: Window + Clone,

Crates a new Surface for the given window.

fn configure_surface( &mut self, surface: &mut Self::Surface, width: u32, height: u32, )

Configures a new Surface with the given dimensions.

fn information(&self) -> Information

Returns Information used by this Compositor.

fn present( &mut self, renderer: &mut Self::Renderer, surface: &mut Self::Surface, viewport: &Viewport, background_color: Color, on_pre_present: impl FnOnce(), ) -> Result<(), SurfaceError>

Presents the Renderer primitives to the next frame of the given Surface.

fn screenshot( &mut self, renderer: &mut Self::Renderer, viewport: &Viewport, background_color: Color, ) -> Vec<u8>

Screenshots the current Renderer primitives to an offscreen texture, and returns the bytes of the texture ordered as RGBA in the sRGB color space.

Provided Methods§

fn new( settings: Settings, display: impl Display + Clone, compatible_window: impl Window + Clone, shell: Shell, ) -> impl Future<Output = Result<Self, Error>>

Creates a new Compositor.

fn load_font(&mut self, font: Cow<'static, [u8]>)

Loads a font from its bytes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

§

impl Compositor for ()

§

type Renderer = ()

§

type Surface = ()

§

async fn with_backend( _settings: Settings, _display: impl Display, _compatible_window: impl Window + Clone, _shell: Shell, _preferred_backend: Option<&str>, ) -> Result<(), Error>

§

fn create_renderer(&self) -> <() as Compositor>::Renderer

§

fn create_surface<W>( &mut self, _window: W, _width: u32, _height: u32, ) -> <() as Compositor>::Surface
where W: Window + Clone,

§

fn configure_surface( &mut self, _surface: &mut <() as Compositor>::Surface, _width: u32, _height: u32, )

§

fn load_font(&mut self, _font: Cow<'static, [u8]>)

§

fn information(&self) -> Information

§

fn present( &mut self, _renderer: &mut <() as Compositor>::Renderer, _surface: &mut <() as Compositor>::Surface, _viewport: &Viewport, _background_color: Color, _on_pre_present: impl FnOnce(), ) -> Result<(), SurfaceError>

§

fn screenshot( &mut self, _renderer: &mut <() as Compositor>::Renderer, _viewport: &Viewport, _background_color: Color, ) -> Vec<u8>

§

impl Compositor for Compositor

§

type Renderer = Renderer

§

type Surface = Surface

§

async fn with_backend( settings: Settings, display: impl Display, _compatible_window: impl Window, _shell: Shell, backend: Option<&str>, ) -> Result<Compositor, Error>

§

fn create_renderer(&self) -> <Compositor as Compositor>::Renderer

§

fn create_surface<W>( &mut self, window: W, width: u32, height: u32, ) -> <Compositor as Compositor>::Surface
where W: Window + Clone,

§

fn configure_surface( &mut self, surface: &mut <Compositor as Compositor>::Surface, width: u32, height: u32, )

§

fn information(&self) -> Information

§

fn present( &mut self, renderer: &mut <Compositor as Compositor>::Renderer, surface: &mut <Compositor as Compositor>::Surface, viewport: &Viewport, background_color: Color, on_pre_present: impl FnOnce(), ) -> Result<(), SurfaceError>

§

fn screenshot( &mut self, renderer: &mut <Compositor as Compositor>::Renderer, viewport: &Viewport, background_color: Color, ) -> Vec<u8>

§

impl<A, B> Compositor for Compositor<A, B>
where A: Compositor, B: Compositor,

§

type Renderer = Renderer<<A as Compositor>::Renderer, <B as Compositor>::Renderer>

§

type Surface = Surface<<A as Compositor>::Surface, <B as Compositor>::Surface>

§

async fn with_backend( settings: Settings, display: impl Display + Clone, compatible_window: impl Window + Clone, shell: Shell, backend: Option<&str>, ) -> Result<Compositor<A, B>, Error>

§

fn create_renderer(&self) -> <Compositor<A, B> as Compositor>::Renderer

§

fn create_surface<W>( &mut self, window: W, width: u32, height: u32, ) -> <Compositor<A, B> as Compositor>::Surface
where W: Window + Clone,

§

fn configure_surface( &mut self, surface: &mut <Compositor<A, B> as Compositor>::Surface, width: u32, height: u32, )

§

fn load_font(&mut self, font: Cow<'static, [u8]>)

§

fn information(&self) -> Information

§

fn present( &mut self, renderer: &mut <Compositor<A, B> as Compositor>::Renderer, surface: &mut <Compositor<A, B> as Compositor>::Surface, viewport: &Viewport, background_color: Color, on_pre_present: impl FnOnce(), ) -> Result<(), SurfaceError>

§

fn screenshot( &mut self, renderer: &mut <Compositor<A, B> as Compositor>::Renderer, viewport: &Viewport, background_color: Color, ) -> Vec<u8>

Implementors§