1.91 <GtkGraphicsOffload>

Class: <GtkGraphicsOffload>

It derives from <GtkWidget>.

Bypasses gsk rendering by passing the content of its child directly to the compositor.

Graphics offload is an optimization to reduce overhead and battery use that is most useful for video content. It only works on some platforms and in certain situations. GTK will automatically fall back to normal rendering if it doesn’t.

Graphics offload is most efficient if there are no controls drawn on top of the video content.

You should consider using graphics offload for your main widget if it shows frequently changing content (such as a video, or a VM display) and you provide the content in the form of dmabuf textures (see <GdkDmabufTextureBuilder>), in particular if it may be fullscreen.

Numerous factors can prohibit graphics offload:

  • Unsupported platforms. Currently, graphics offload only works on Linux with Wayland.
  • Clipping, such as rounded corners that cause the video content to not be rectangular
  • Translucent video content (content with an alpha channel, even if it isn’t used)
  • Transforms that are more complex than translations and scales
  • Filters such as opacity, grayscale or similar

To investigate problems related graphics offload, GTK offers debug flags to print out information about graphics offload and dmabuf use:

GDK_DEBUG=offload GDK_DEBUG=dmabuf

The GTK inspector provides a visual debugging tool for graphics offload.

Properties

Property: graphics-offload:black-background self

Whether to draw a black background.

Its value is a boolean.

Set it with (set! (graphics-offload:black-background self) value).

Property: graphics-offload:child self

The child widget.

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

Set it with (set! (graphics-offload:child self) value).

Property: graphics-offload:enabled self

Whether graphics offload is enabled.

Its value is a <GtkGraphicsOffloadEnabled> (or, to set it, one of its symbols).

Set it with (set! (graphics-offload:enabled self) value).

Procedures

Method: graphics-offload:get-black-background? self ⇒ %return
Method: get-black-background? self ⇒ %return

Returns whether the widget draws a black background.

See graphics-offload:set-black-background.

self

Passed: a <GtkGraphicsOffload>.

a <GtkGraphicsOffload>

%return

Returned: a boolean.

TRUE if black background is drawn

Method: graphics-offload:get-child self ⇒ %return
Method: get-child self ⇒ %return

Gets the child of self.

self

Passed: a <GtkGraphicsOffload>.

a <GtkGraphicsOffload>

%return

Returned: a <GtkWidget>, or #f.

the child widget

Method: graphics-offload:get-enabled self ⇒ %return
Method: get-enabled self ⇒ %return

Returns whether offload is enabled for self.

self

Passed: a <GtkGraphicsOffload>.

a <GtkGraphicsOffload>

%return

Returned: a <GtkGraphicsOffloadEnabled>.

whether offload is enabled

Procedure: graphics-offload:new [child] ⇒ %return

Creates a new GtkGraphicsOffload widget.

child

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

the child widget

%return

Returned: a <GtkWidget>.

the new widget

Method: graphics-offload:set-black-background self value
Method: set-black-background self value

Sets whether this GtkGraphicsOffload widget will draw a black background.

A main use case for this is _letterboxing_ where black bars are visible next to the content if the aspect ratio of the content does not match the dimensions of the monitor.

Using this property for letterboxing instead of CSS allows compositors to show content with maximum efficiency, using direct scanout to avoid extra copies in the compositor.

On Wayland, this is implemented using the single-pixel buffer protocol.

self

Passed: a <GtkGraphicsOffload>.

a <GtkGraphicsOffload>

value

Passed: a boolean.

whether to draw a black background behind the content

Method: graphics-offload:set-child self [child]
Method: set-child self [child]

Sets the child of self.

self

Passed: a <GtkGraphicsOffload>.

a <GtkGraphicsOffload>

child

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

the child widget

Method: graphics-offload:set-enabled self enabled
Method: set-enabled self enabled

Sets whether this GtkGraphicsOffload widget will attempt to offload the content of its child widget.

self

Passed: a <GtkGraphicsOffload>.

a <GtkGraphicsOffload>

enabled

Passed: a <GtkGraphicsOffloadEnabled>, or one of its symbols.

whether to enable offload