GskRenderer

GskRenderer — Renders a scene

Properties

GdkDisplay * display Read / Write / Construct Only
GdkDrawingContext * drawing-context Read
gint scale-factor Read / Write
GrapheneRect * viewport Read / Write
GdkWindow * window Read / Write / Construct Only

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 with a GdkDrawingContext associated to a GdkWindow, and call gsk_renderer_render() with the drawing context and the scene to be rendered.

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_new_for_window ()

GskRenderer *
gsk_renderer_new_for_window (GdkWindow *window);

Creates an appropriate GskRenderer instance for the given window .

The renderer will be realized when it is returned.

Parameters

window

a GdkWindow

 

Since: 3.90


gsk_renderer_set_viewport ()

void
gsk_renderer_set_viewport (GskRenderer *renderer,
                           const graphene_rect_t *viewport);

Sets the visible rectangle to be used as the viewport for the rendering.

Parameters

renderer

a GskRenderer

 

viewport

the viewport rectangle used by the renderer .

[nullable]

Since: 3.90


gsk_renderer_get_viewport ()

void
gsk_renderer_get_viewport (GskRenderer *renderer,
                           graphene_rect_t *viewport);

Retrieves the viewport of the GskRenderer.

Parameters

renderer

a GskRenderer

 

viewport

return location for the viewport rectangle.

[out caller-allocates]

Since: 3.90


gsk_renderer_set_scale_factor ()

void
gsk_renderer_set_scale_factor (GskRenderer *renderer,
                               int scale_factor);

Sets the scale factor for the renderer.

Parameters

renderer

a GskRenderer

 

scale_factor

the new scale factor

 

Since: 3.90


gsk_renderer_get_scale_factor ()

int
gsk_renderer_get_scale_factor (GskRenderer *renderer);

Gets the scale factor for the renderer .

Parameters

renderer

a GskRenderer

 

Returns

the scale factor

Since: 3.90


gsk_renderer_get_window ()

GdkWindow *
gsk_renderer_get_window (GskRenderer *renderer);

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

Parameters

renderer

a GskRenderer

 

Since: 3.90


gsk_renderer_get_display ()

GdkDisplay *
gsk_renderer_get_display (GskRenderer *renderer);

Retrieves the GdkDisplay used when creating the GskRenderer.

Parameters

renderer

a GskRenderer

 

Returns

a GdkDisplay.

[transfer none]

Since: 3.90


gsk_renderer_realize ()

gboolean
gsk_renderer_realize (GskRenderer *renderer,
                      GdkWindow *window,
                      GError **error);

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

Parameters

renderer

a GskRenderer

 

window

the GdkWindow renderer will be used on

 

error

return location for an error

 

Since: 3.90


gsk_renderer_unrealize ()

void
gsk_renderer_unrealize (GskRenderer *renderer);

Releases all the resources created by gsk_renderer_realize().

Parameters

renderer

a GskRenderer

 

Since: 3.90


gsk_renderer_begin_draw_frame ()

GdkDrawingContext *
gsk_renderer_begin_draw_frame (GskRenderer *renderer,
                               const cairo_region_t *region);

Indicates that you are beginning the process of redrawing region using renderer , and provides you with a GdkDrawingContext to use for this.

Parameters

renderer

a GskRenderer

 

region

the cairo_region_t that you wish to draw

 

Returns

a GdkDrawingContext context that should be used to draw the contents of the renderer . This context is owned by GDK.

[transfer none]

Since: 3.90


gsk_renderer_end_draw_frame ()

void
gsk_renderer_end_draw_frame (GskRenderer *renderer,
                             GdkDrawingContext *context);

gsk_renderer_render ()

void
gsk_renderer_render (GskRenderer *renderer,
                     GskRenderNode *root,
                     GdkDrawingContext *context);

Renders the scene graph, described by a tree of GskRenderNode instances, using the given GdkDrawingContext.

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

Parameters

renderer

a GskRenderer

 

root

a GskRenderNode

 

context

The drawing context created via gsk_renderer_begin_draw_frame()

 

Since: 3.90


gsk_renderer_render_texture ()

GskTexture *
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 GskTexture.

The renderer will acquire a reference on the GskRenderNode tree while the rendering is in progress, and will make the tree immutable.

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 GdkRenderer

 

root

a GskRenderNode

 

viewport

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

[allow-none]

Returns

a GskTexture with the rendered contents of root .

[transfer full]

Since: 3.90

Types and Values

Property Details

The “display” property

  “display”                  GdkDisplay *

The GdkDisplay used by the GskRenderer.

Flags: Read / Write / Construct Only

Since: 3.90


The “drawing-context” property

  “drawing-context”          GdkDrawingContext *

The drawing context used when rendering.

Flags: Read

Since: 3.90


The “scale-factor” property

  “scale-factor”             gint

The scale factor used when rendering.

Flags: Read / Write

Allowed values: >= 1

Default value: 1

Since: 3.90


The “viewport” property

  “viewport”                 GrapheneRect *

The visible area used by the GskRenderer to render its contents.

Flags: Read / Write

Since: 3.90


The “window” property

  “window”                   GdkWindow *

The window associated to the renderer.

Flags: Read / Write / Construct Only