iced_graphics::compositor

Trait Compositor

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

    // Required methods
    fn with_backend<W: Window + Clone>(
        _settings: Settings,
        _compatible_window: W,
        _backend: Option<&str>,
    ) -> impl Future<Output = Result<Self, Error>>;
    fn create_renderer(&self) -> Self::Renderer;
    fn create_surface<W: Window + Clone>(
        &mut self,
        window: W,
        width: u32,
        height: u32,
    ) -> Self::Surface;
    fn configure_surface(
        &mut self,
        surface: &mut Self::Surface,
        width: u32,
        height: u32,
    );
    fn fetch_information(&self) -> Information;
    fn present<T: AsRef<str>>(
        &mut self,
        renderer: &mut Self::Renderer,
        surface: &mut Self::Surface,
        viewport: &Viewport,
        background_color: Color,
        overlay: &[T],
    ) -> Result<(), SurfaceError>;
    fn screenshot<T: AsRef<str>>(
        &mut self,
        renderer: &mut Self::Renderer,
        surface: &mut Self::Surface,
        viewport: &Viewport,
        background_color: Color,
        overlay: &[T],
    ) -> Vec<u8>;

    // Provided methods
    fn new<W: Window + Clone>(
        settings: Settings,
        compatible_window: W,
    ) -> 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§

Source

type Renderer

The iced renderer of the backend.

Source

type Surface

The surface of the backend.

Required Methods§

Source

fn with_backend<W: Window + Clone>( _settings: Settings, _compatible_window: W, _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.

Source

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

Creates a Self::Renderer for the Compositor.

Source

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

Crates a new Surface for the given window.

Source

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

Configures a new Surface with the given dimensions.

Source

fn fetch_information(&self) -> Information

Returns Information used by this Compositor.

Source

fn present<T: AsRef<str>>( &mut self, renderer: &mut Self::Renderer, surface: &mut Self::Surface, viewport: &Viewport, background_color: Color, overlay: &[T], ) -> Result<(), SurfaceError>

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

Source

fn screenshot<T: AsRef<str>>( &mut self, renderer: &mut Self::Renderer, surface: &mut Self::Surface, viewport: &Viewport, background_color: Color, overlay: &[T], ) -> 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§

Source

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

Creates a new Compositor.

Source

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§

Source§

impl Compositor for ()

Available on debug-assertions enabled only.
Source§

type Renderer = ()

Source§

type Surface = ()

Source§

async fn with_backend<W: Window + Clone>( _settings: Settings, _compatible_window: W, _preferred_backend: Option<&str>, ) -> Result<Self, Error>

Source§

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

Source§

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

Source§

fn configure_surface( &mut self, _surface: &mut Self::Surface, _width: u32, _height: u32, )

Source§

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

Source§

fn fetch_information(&self) -> Information

Source§

fn present<T: AsRef<str>>( &mut self, _renderer: &mut Self::Renderer, _surface: &mut Self::Surface, _viewport: &Viewport, _background_color: Color, _overlay: &[T], ) -> Result<(), SurfaceError>

Source§

fn screenshot<T: AsRef<str>>( &mut self, _renderer: &mut Self::Renderer, _surface: &mut Self::Surface, _viewport: &Viewport, _background_color: Color, _overlay: &[T], ) -> Vec<u8>

Implementors§