DmabufTextureBuilder

Added in version 4.14.

class DmabufTextureBuilder(**properties: Any)

Superclasses: Object

Constructors:

DmabufTextureBuilder(**properties)
new() -> Gdk.DmabufTextureBuilder

Constructors

class DmabufTextureBuilder
classmethod new() DmabufTextureBuilder

Creates a new texture builder.

Added in version 4.14.

Methods

class DmabufTextureBuilder
build(destroy: Callable[[None], None] | None, data: None) Texture | None

Builds a new GdkTexture with the values set up in the builder.

It is a programming error to call this function if any mandatory property has not been set.

If the dmabuf is not supported by GTK, None will be returned and error will be set.

The destroy function gets called when the returned texture gets released.

It is possible to call this function multiple times to create multiple textures, possibly with changing properties in between.

It is the responsibility of the caller to keep the file descriptors for the planes open until the created texture is no longer used, and close them afterwards (possibly using the destroy notify).

Not all formats defined in the drm_fourcc.h header are supported. You can use get_dmabuf_formats to get a list of supported formats.

Added in version 4.14.

Parameters:
  • destroy – destroy function to be called when the texture is released

  • data – user data to pass to the destroy function

get_display() Display

Returns the display that this texture builder is associated with.

Added in version 4.14.

get_fd(plane: int) int

Gets the file descriptor for a plane.

Added in version 4.14.

Parameters:

plane – the plane to get the fd for

get_fourcc() int

Gets the format previously set via set_fourcc() or 0 if the format wasn’t set.

The format is specified as a fourcc code.

Added in version 4.14.

get_height() int

Gets the height previously set via set_height() or 0 if the height wasn’t set.

Added in version 4.14.

get_modifier() int

Gets the modifier value.

Added in version 4.14.

get_n_planes() int

Gets the number of planes.

Added in version 4.14.

get_offset(plane: int) int

Gets the offset value for a plane.

Added in version 4.14.

Parameters:

plane – the plane to get the offset for

get_premultiplied() bool

Whether the data is premultiplied.

Added in version 4.14.

get_stride(plane: int) int

Gets the stride value for a plane.

Added in version 4.14.

Parameters:

plane – the plane to get the stride for

get_update_region() Region | None

Gets the region previously set via set_update_region() or None if none was set.

Added in version 4.14.

get_update_texture() Texture | None

Gets the texture previously set via set_update_texture() or None if none was set.

Added in version 4.14.

get_width() int

Gets the width previously set via set_width() or 0 if the width wasn’t set.

Added in version 4.14.

set_display(display: Display) None

Sets the display that this texture builder is associated with.

The display is used to determine the supported dma-buf formats.

Added in version 4.14.

Parameters:

display – the display

set_fd(plane: int, fd: int) None

Sets the file descriptor for a plane.

Added in version 4.14.

Parameters:
  • plane – the plane to set the fd for

  • fd – the file descriptor

set_fourcc(fourcc: int) None

Sets the format of the texture.

The format is specified as a fourcc code.

The format must be set before calling build.

Added in version 4.14.

Parameters:

fourcc – the texture’s format or 0 to unset

set_height(height: int) None

Sets the height of the texture.

The height must be set before calling build.

Added in version 4.14.

Parameters:

height – the texture’s height or 0 to unset

set_modifier(modifier: int) None

Sets the modifier.

Added in version 4.14.

Parameters:

modifier – the modifier value

set_n_planes(n_planes: int) None

Sets the number of planes of the texture.

Added in version 4.14.

Parameters:

n_planes – the number of planes

set_offset(plane: int, offset: int) None

Sets the offset for a plane.

Added in version 4.14.

Parameters:
  • plane – the plane to set the offset for

  • offset – the offset value

set_premultiplied(premultiplied: bool) None

Sets whether the data is premultiplied.

Unless otherwise specified, all formats including alpha channels are assumed to be premultiplied.

Added in version 4.14.

Parameters:

premultiplied – whether the data is premultiplied

set_stride(plane: int, stride: int) None

Sets the stride for a plane.

The stride must be set for all planes before calling build.

Added in version 4.14.

Parameters:
  • plane – the plane to set the stride for

  • stride – the stride value

set_update_region(region: Region | None = None) None

Sets the region to be updated by this texture. Together with update_texture this describes an update of a previous texture.

When rendering animations of large textures, it is possible that consecutive textures are only updating contents in parts of the texture. It is then possible to describe this update via these two properties, so that GTK can avoid rerendering parts that did not change.

An example would be a screen recording where only the mouse pointer moves.

Added in version 4.14.

Parameters:

region – the region to update

set_update_texture(texture: Texture | None = None) None

Sets the texture to be updated by this texture. See set_update_region for an explanation.

Added in version 4.14.

Parameters:

texture – the texture to update

set_width(width: int) None

Sets the width of the texture.

The width must be set before calling build.

Added in version 4.14.

Parameters:

width – The texture’s width or 0 to unset

Properties

class DmabufTextureBuilder
props.display: Display

The display that this texture will be used on.

Added in version 4.14.

props.fourcc: int

The format of the texture, as a fourcc value.

Added in version 4.14.

props.height: int

The height of the texture.

Added in version 4.14.

props.modifier: int

The modifier.

Added in version 4.14.

props.n_planes: int

The number of planes of the texture.

Note that you can set properties for other planes, but they will be ignored when constructing the texture.

Added in version 4.14.

props.premultiplied: bool

Whether the alpha channel is premultiplied into the others.

Only relevant if the format has alpha.

Added in version 4.14.

props.update_region: Region

The update region for update_texture.

Added in version 4.14.

props.update_texture: Texture

The texture update_region is an update for.

Added in version 4.14.

props.width: int

The width of the texture.

Added in version 4.14.