gsk4::prelude

Trait GskRendererExt

Source
pub trait GskRendererExt:
    IsA<Renderer>
    + Sealed
    + 'static {
    // Provided methods
    fn surface(&self) -> Option<Surface> { ... }
    fn is_realized(&self) -> bool { ... }
    fn realize(&self, surface: Option<&Surface>) -> Result<(), Error> { ... }
    fn realize_for_display(&self, display: &Display) -> Result<(), Error> { ... }
    fn render(&self, root: impl AsRef<RenderNode>, region: Option<&Region>) { ... }
    fn render_texture(
        &self,
        root: impl AsRef<RenderNode>,
        viewport: Option<&Rect>,
    ) -> Texture { ... }
    fn unrealize(&self) { ... }
    fn connect_realized_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId { ... }
    fn connect_surface_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId { ... }
}
Expand description

Trait containing all Renderer methods.

§Implementors

BroadwayRenderer, CairoRenderer, GLRenderer, NglRenderer, Renderer, VulkanRenderer

Provided Methods§

Source

fn surface(&self) -> Option<Surface>

Retrieves the surface that the renderer is associated with.

If the renderer has not been realized yet, NULL will be returned.

§Returns

the surface

Source

fn is_realized(&self) -> bool

Checks whether the renderer is realized or not.

§Returns

true if the renderer was realized, false otherwise

Source

fn realize(&self, surface: Option<&Surface>) -> Result<(), Error>

Creates the resources needed by the renderer.

Since GTK 4.6, the surface may be NULL, which allows using renderers without having to create a surface. Since GTK 4.14, it is recommended to use realize_for_display() for this case.

Note that it is mandatory to call unrealize() before destroying the renderer.

§surface

the surface that renderer will be used on

§Returns

whether the renderer was successfully realized

Source

fn realize_for_display(&self, display: &Display) -> Result<(), Error>

Available on crate feature v4_14 only.

Creates the resources needed by the renderer.

Note that it is mandatory to call unrealize() before destroying the renderer.

§display

the display that the renderer will be used on

§Returns

whether the renderer was successfully realized

Source

fn render(&self, root: impl AsRef<RenderNode>, region: Option<&Region>)

Renders the scene graph, described by a tree of RenderNode instances to the renderer’s surface, ensuring that the given region gets redrawn.

If the renderer has no associated surface, this function does nothing.

Renderers must ensure that changes of the contents given by the @root node as well as the area given by @region are redrawn. They are however free to not redraw any pixel outside of @region if they can guarantee that it didn’t change.

The renderer will acquire a reference on the RenderNode tree while the rendering is in progress.

§root

the render node to render

§region

the cairo::Region that must be redrawn or NULL for the whole surface

Source

fn render_texture( &self, root: impl AsRef<RenderNode>, viewport: Option<&Rect>, ) -> Texture

Renders a scene graph, described by a tree of RenderNode instances, to a texture.

The renderer will acquire a reference on the RenderNode tree while the rendering is in progress.

If you want to apply any transformations to @root, you should put it into a transform node and pass that node instead.

§root

the render node to render

§viewport

the section to draw or NULL to use @root’s bounds

§Returns

a texture with the rendered contents of @root

Source

fn unrealize(&self)

Releases all the resources created by realize().

Source

fn connect_realized_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

fn connect_surface_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

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.

Implementors§