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 GdkSurface

Instance Method Details

#is_realizedBoolean

Checks whether the renderer is realized or not.

Returns:

  • (Boolean)

    true if the GskRenderer was realized, and false otherwise

#realize(surface) ⇒ Boolean

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

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] instead.

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

Parameters:

  • surface (Gdk::Surface)

    the GdkSurface 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 to render the scene graph.

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

Parameters:

  • display (Gdk::Display)

    the GdkDisplay 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)

    a GskRenderNode

  • region (cairo::Region)

    the cairo_region_t that must be redrawn or nil for the whole window

Returns:

  • (nil)

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

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:

  • root (Gsk::RenderNode)

    a GskRenderNode

  • viewport (Graphene::Rect)

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

Returns:

  • (Gdk::Texture)

    a GdkTexture with the rendered contents of root.

#surfaceGdk::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

#unrealizenil

Releases all the resources created by gsk_renderer_realize().

Returns:

  • (nil)