Class: Gsk::Renderer

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Constructor Details

#initialize(surface) ⇒ Gsk::Renderer

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.

Parameters:

  • surface (Gdk::Surface) —

    a surface

Instance Method Details

#is_realized ⇒ Boolean

Checks whether the renderer is realized or not.

Returns:

  • (Boolean) —

    true if the renderer was realized, false otherwise

#realize(surface) ⇒ Boolean

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 [methodGsk.Renderer.realize_for_display]
for this case.

Note that it is mandatory to call [methodGsk.Renderer.unrealize]
before destroying the renderer.

Parameters:

  • surface (Gdk::Surface) —

    the surface that renderer will be used on

Returns:

  • (Boolean) —

    whether the renderer was successfully realized

#realize_for_display(display) ⇒ Boolean

Creates the resources needed by the renderer.

Note that it is mandatory to call [methodGsk.Renderer.unrealize]
before destroying the renderer.

Parameters:

  • display (Gdk::Display) —

    the display that the renderer will be used on

Returns:

  • (Boolean) —

    whether the renderer was successfully realized

#realized=(realized) ⇒ Boolean

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

Parameters:

  • realized (Boolean)

Returns:

  • (Boolean) —

    realized

  • (Boolean) —

    realized

#realized? ⇒ Boolean

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

Returns:

  • (Boolean) —

    realized

#render(root, region) ⇒ nil

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.

Parameters:

  • root (Gsk::RenderNode) —

    the render node to render

  • region (cairo::Region) —

    the cairo_region_t that must be redrawn or NULL
    for the whole surface

Returns:

  • (nil)

#render_texture(root, viewport) ⇒ Gdk::Texture

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.

Parameters:

  • root (Gsk::RenderNode) —

    the render node to render

  • viewport (Graphene::Rect) —

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

Returns:

  • (Gdk::Texture) —

    a texture with the rendered contents of root

#surface ⇒ Gdk::Surface

The surface associated with renderer.

Returns:

  • (Gdk::Surface) —

    surface

#surface=(surface) ⇒ Gdk::Surface

The surface associated with renderer.

Parameters:

  • surface (Gdk::Surface)

Returns:

  • (Gdk::Surface) —

    surface

  • (Gdk::Surface) —

    surface

#unrealize ⇒ nil

Releases all the resources created by [methodGsk.Renderer.realize].

Returns:

  • (nil)