About all my projects
Gnome::Gsk4::Renderer

Gnome::Gsk4::Renderer

Description

Gnome::Gsk4::Renderer is a class that renders a scene graph defined via a tree of Gnome::Gsk4::RenderNode instances.

Typically you will use a Gnome::Gsk4::Renderer instance to repeatedly call .render() to update the contents of its associated Gnome::Gdk4::Surface.

It is necessary to realize a Gnome::Gsk4::Renderer instance using .realize() before calling .render(), in order to create the appropriate windowing system resources needed to render the scene.

Class initialization

new

:native-object

Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.

multi method new ( N-Object :$native-object! )

new-for-surface

Creates an appropriate Gnome::Gsk4::Renderer instance for the given $surface.

If the GSK_RENDERER environment variable is set, GSK will try that renderer first, before trying the backend-specific default. The ultimate fallback is the cairo renderer.

The renderer will be realized before it is returned.

method new-for-surface ( N-Object() $surface --> Gnome::Gsk4::Renderer \)
  • $surface; a Gnome::Gdk4::Surface.

Methods

get-surface

Retrieves the Gnome::Gdk4::Surface set using gsk_enderer_realize().

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

method get-surface (--> N-Object )

Return value; a Gnome::Gdk4::Surface.

is-realized

Checks whether the $renderer is realized or not.

method is-realized (--> Bool )

Return value; True if the Gnome::Gsk4::Renderer was realized, and False otherwise.

realize

Creates the resources needed by the $renderer to render the scene graph.

Since GTK 4.6, the surface may be undefined, which allows using renderers without having to create a surface.

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

method realize ( N-Object() $surface, CArray[N-Error] $err --> Bool )
  • $surface; the Gnome::Gdk4::Surface renderer will be used on.

  • $err; Error object. When defined, an error can be returned when there is one. Use Pointer when you want to ignore the error. .

Return value; Whether the renderer was successfully realized.

render

Renders the scene graph, described by a tree of Gnome::Gsk4::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 Gnome::Gsk4::RenderNode tree while the rendering is in progress.

method render ( N-Object() $root, N-Object $region )
  • $root; a Gnome::Gsk4::RenderNode.

  • $region; the Gnome::Cairo::N-Context that must be redrawn or undefined for the whole window

render-texture

Renders the scene graph, described by a tree of Gnome::Gsk4::RenderNode instances, to a Gnome::Gdk4::Texture.

The $renderer will acquire a reference on the Gnome::Gsk4::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.

method render-texture ( N-Object() $root, N-Object $viewport --> N-Object )
  • $root; a Gnome::Gsk4::RenderNode.

  • $viewport; the section to draw or undefined to use $root's bounds

Return value; a Gnome::Gdk4::Texture with the rendered contents of $root..

unrealize

Releases all the resources created by .realize().

method unrealize ( )