GskRenderer

GskRenderer — Renders a scene

Properties

gboolean realized Read
GdkSurface * surface Read

Types and Values

Object Hierarchy

    GObject
    ╰── GskRenderer

Description

GskRenderer is a class that renders a scene graph defined via a tree of GskRenderNode instances.

Typically you will use a GskRenderer instance to repeatedly call gsk_renderer_render() to update the contents of its associated GdkSurface.

It is necessary to realize a GskRenderer instance using gsk_renderer_realize() before calling gsk_renderer_render(), in order to create the appropriate windowing system resources needed to render the scene.

Functions

gsk_renderer_get_surface ()

GdkSurface *
gsk_renderer_get_surface (GskRenderer *renderer);

Retrieves the GdkSurface set using gsk_renderer_realize(). If the renderer has not been realized yet, NULL will be returned.

Parameters

renderer

a GskRenderer

 

Returns

a GdkSurface.

[transfer none][nullable]


gsk_renderer_realize ()

gboolean
gsk_renderer_realize (GskRenderer *renderer,
                      GdkSurface *surface,
                      GError **error);

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

Parameters

renderer

a GskRenderer

 

surface

the GdkSurface renderer will be used on

 

error

return location for an error

 

gsk_renderer_unrealize ()

void
gsk_renderer_unrealize (GskRenderer *renderer);

Releases all the resources created by gsk_renderer_realize().

Parameters

renderer

a GskRenderer

 

gsk_renderer_is_realized ()

gboolean
gsk_renderer_is_realized (GskRenderer *renderer);

Checks whether the renderer is realized or not.

Parameters

renderer

a GskRenderer

 

Returns

TRUE if the GskRenderer was realized, and FALSE otherwise


gsk_renderer_render ()

void
gsk_renderer_render (GskRenderer *renderer,
                     GskRenderNode *root,
                     const cairo_region_t *region);

Renders the scene graph, described by a tree of GskRenderNode instances, ensuring that the given region gets redrawn.

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.

Parameters

renderer

a GskRenderer

 

root

a GskRenderNode

 

region

the cairo_region_t that must be redrawn or NULL for the whole window.

[nullable]

gsk_renderer_render_texture ()

GdkTexture *
gsk_renderer_render_texture (GskRenderer *renderer,
                             GskRenderNode *root,
                             const graphene_rect_t *viewport);

Renders the scene graph, described by a tree of GskRenderNode instances, to a GdkTexture.

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.

Parameters

renderer

a realized GskRenderer

 

root

a GskRenderNode

 

viewport

the section to draw or NULL to use root 's bounds.

[allow-none]

Returns

a GdkTexture with the rendered contents of root .

[transfer full]


gsk_renderer_new_for_surface ()

GskRenderer *
gsk_renderer_new_for_surface (GdkSurface *surface);

Creates an appropriate GskRenderer instance for the given surface .

The renderer will be realized when it is returned.

Parameters

surface

a GdkSurface

 

Returns

a GskRenderer.

[transfer full][nullable]


gsk_gl_renderer_new ()

GskRenderer *
gsk_gl_renderer_new (void);

Creates a new GskRenderer using OpenGL. This is the default renderer used by GTK.

Returns

a new GL renderer


gsk_cairo_renderer_new ()

GskRenderer *
gsk_cairo_renderer_new (void);

Creates a new Cairo renderer.

The Cairo renderer is the fallback renderer drawing in ways similar to how GTK 3 drew its content. Its primary use is as comparison tool.

The Cairo renderer is incomplete. It cannot render 3D transformed content and will instead render an error marker. Its usage should be avoided.

Returns

a new Cairo renderer.


gsk_vulkan_renderer_new ()

GskRenderer *
gsk_vulkan_renderer_new (void);

Creates a new Vulkan renderer.

The Vulkan renderer is a renderer that uses the Vulkan library for rendering.

This function is only available when GTK was compiled with Vulkan support.

Returns

a new Vulkan renderer


gsk_broadway_renderer_new ()

GskRenderer *
gsk_broadway_renderer_new (void);

Creates a new Broadway renderer.

The Broadway renderer is the default renderer for the broadway backend. It will only work with broadway surfaces, otherwise it will fail the call to gsk_renderer_realize().

This function is only available when GTK was compiled with Broadway support.

Returns

a new Broadway renderer.

Types and Values

GskRenderer

typedef struct _GskRenderer GskRenderer;

Property Details

The “realized” property

  “realized”                 gboolean

The renderer has been associated with a surface.

Owner: GskRenderer

Flags: Read

Default value: FALSE


The “surface” property

  “surface”                  GdkSurface *

The surface associated to the renderer.

Owner: GskRenderer

Flags: Read