DmabufTextureBuilder

open class DmabufTextureBuilder(pointer: <Error class: unknown class><<Error class: unknown class>>)

GdkDmabufTextureBuilder is a builder used to construct class@Gdk.Texture objects from DMA buffers.

DMA buffers are commonly called dma-bufs.

DMA buffers are a feature of the Linux kernel to enable efficient buffer and memory sharing between hardware such as codecs, GPUs, displays, cameras and the kernel drivers controlling them. For example, a decoder may want its output to be directly shared with the display server for rendering without a copy.

Any device driver which participates in DMA buffer sharing, can do so as either the exporter or importer of buffers (or both).

The memory that is shared via DMA buffers is usually stored in non-system memory (maybe in device's local memory or something else not directly accessible by the CPU), and accessing this memory from the CPU may have higher-than-usual overhead.

In particular for graphics data, it is not uncommon that data consists of multiple separate blocks of memory, for example one block for each of the red, green and blue channels. These blocks are called planes. DMA buffers can have up to four planes. Even if the memory is a single block, the data can be organized in multiple planes, by specifying offsets from the beginning of the data.

DMA buffers are exposed to user-space as file descriptors allowing to pass them between processes. If a DMA buffer has multiple planes, there is one file descriptor per plane.

The format of the data (for graphics data, essentially its colorspace) is described by a 32-bit integer. These format identifiers are defined in the header file drm_fourcc.h and commonly referred to as fourcc values, since they are identified by 4 ASCII characters. Additionally, each DMA buffer has a modifier, which is a 64-bit integer that describes driver-specific details of the memory layout, such as tiling or compression.

For historical reasons, some producers of dma-bufs don't provide an explicit modifier, but instead return DMA_FORMAT_MOD_INVALID to indicate that their modifier is implicit. GTK tries to accommodate this situation by accepting DMA_FORMAT_MOD_INVALID as modifier.

The operation of GdkDmabufTextureBuilder is quite simple: Create a texture builder, set all the necessary properties, and then call method@Gdk.DmabufTextureBuilder.build to create the new texture.

The required properties for a dma-buf texture are

  • The width and height in pixels

  • The fourcc code and modifier which identify the format and memory layout of the dma-buf

  • The file descriptor, offset and stride for each of the planes

GdkDmabufTextureBuilder can be used for quick one-shot construction of textures as well as kept around and reused to construct multiple textures.

For further information, see

Skipped during bindings generation

  • parameter destroy: GLib.DestroyNotify

  • method get_update_region: Return type cairo.Region is unsupported

  • parameter region: cairo.Region

  • method update-region: Property has no getter nor setter

Since

4.14

Constructors

Link copied to clipboard
constructor()

Creates a new texture builder.

constructor(pointer: <Error class: unknown class><<Error class: unknown class>>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The color state of the texture.

Link copied to clipboard
open var display: Display

The display that this texture will be used on.

Link copied to clipboard
open var fourcc: <Error class: unknown class>

The format of the texture, as a fourcc value.

Link copied to clipboard
val gdkDmabufTextureBuilderPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open var height: <Error class: unknown class>

The height of the texture.

Link copied to clipboard
open var modifier: <Error class: unknown class>

The modifier.

Link copied to clipboard
open var nPlanes: <Error class: unknown class>

The number of planes of the texture.

Link copied to clipboard

Whether the alpha channel is premultiplied into the others.

Link copied to clipboard

The texture property@Gdk.DmabufTextureBuilder:update-region is an update for.

Link copied to clipboard
open var width: <Error class: unknown class>

The width of the texture.

Functions

Link copied to clipboard
open fun getFd(plane: <Error class: unknown class>): <Error class: unknown class>

Gets the file descriptor for a plane.

Link copied to clipboard
open fun getOffset(plane: <Error class: unknown class>): <Error class: unknown class>

Gets the offset value for a plane.

Link copied to clipboard
open fun getStride(plane: <Error class: unknown class>): <Error class: unknown class>

Gets the stride value for a plane.

Link copied to clipboard
open fun setFd(plane: <Error class: unknown class>, fd: <Error class: unknown class>)

Sets the file descriptor for a plane.

Link copied to clipboard
open fun setOffset(plane: <Error class: unknown class>, offset: <Error class: unknown class>)

Sets the offset for a plane.

Link copied to clipboard
open fun setStride(plane: <Error class: unknown class>, stride: <Error class: unknown class>)

Sets the stride for a plane.