1.30 <GskRenderer>

Class: <GskRenderer>

It derives from <GObject>.

Renders a scene graph defined via a tree of <GskRenderNode> instances.

Typically you will use a <GskRenderer> instance to repeatedly call renderer:render to update the contents of its associated <GdkSurface>.

It is necessary to realize a <GskRenderer> instance using renderer:realize? before calling renderer:render, in order to create the appropriate windowing system resources needed to render the scene.

Properties

Property: renderer:realized self

Whether the renderer has been associated with a surface or draw context.

Its value is a boolean.

It is read only.

Property: renderer:surface self

The surface associated with renderer.

Its value is a <GdkSurface>, or #f.

It is read only.

Procedures

Method: renderer:get-surface self ⇒ %return
Method: get-surface self ⇒ %return

Retrieves the surface that the renderer is associated with.

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

self

Passed: a <GskRenderer>.

a renderer

%return

Returned: a <GdkSurface>, or #f.

the surface

Method: renderer:is-realized? self ⇒ %return
Method: is-realized? self ⇒ %return

Checks whether the renderer is realized or not.

self

Passed: a <GskRenderer>.

a renderer

%return

Returned: a boolean.

true if the renderer was realized, false otherwise

Procedure: renderer:new-for-surface surface ⇒ %return

Creates an appropriate <GskRenderer> 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.

surface

Passed: a <GdkSurface>.

a surface

%return

Returned: a <GskRenderer>, or #f.

the realized renderer

Method: renderer:realize-for-display? self display ⇒ %return
Method: realize-for-display? self display ⇒ %return

Creates the resources needed by the renderer.

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

self

Passed: a <GskRenderer>.

a renderer

display

Passed: a <GdkDisplay>.

the display that the renderer will be used on

%return

Returned: a boolean.

whether the renderer was successfully realized

Method: renderer:realize? self [surface] ⇒ %return
Method: realize? self [surface] ⇒ %return

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 renderer:realize-for-display? for this case.

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

self

Passed: a <GskRenderer>.

a renderer

surface

Passed, or left out: a <GdkSurface>, or #f.

the surface that renderer will be used on

%return

Returned: a boolean.

whether the renderer was successfully realized

Method: renderer:render self root [region]
Method: render self root [region]

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

self

Passed: a <GskRenderer>.

a realized renderer

root

Passed: a <GskRenderNode>.

the render node to render

region

Passed, or left out: a <CairoRegion>, or #f.

the <CairoRegion> that must be redrawn or NULL for the whole surface

Method: renderer:render-texture self root [viewport] ⇒ %return
Method: render-texture self root [viewport] ⇒ %return

Renders a scene graph, described by a tree of <GskRenderNode> instances, to a texture.

The renderer will acquire a reference on the <GskRenderNode> 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.

self

Passed: a <GskRenderer>.

a realized renderer

root

Passed: a <GskRenderNode>.

the render node to render

viewport

Passed, or left out: a <GrapheneRect>, or #f.

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

%return

Returned: a <GdkTexture>.

a texture with the rendered contents of root

Method: renderer:unrealize self
Method: unrealize self

Releases all the resources created by renderer:realize?.

self

Passed: a <GskRenderer>.

a renderer