gdk.dmabuf_texture_builder
Module for [DmabufTextureBuilder] class
Types 3
gdk.dmabuf_texture_builder.DmabufTextureBuilder is a builder used to construct gdk.texture.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 gdk.dmabuf_texture_builder.DmabufTextureBuilder is quite simple: Create a texture builder, set all the necessary properties, and then call gdk.dmabuf_texture_builder.DmabufTextureBuilder.build to create the new texture.
The required properties for a dma-buf texture are
- The width and height in pixels
- The
fourcccode andmodifierwhich identify the format and memory layout of the dma-buf - The file descriptor, offset and stride for each of the planes
gdk.dmabuf_texture_builder.DmabufTextureBuilder 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
- The Linux kernel documentation
- The header file drm_fourcc.h
DmabufTextureBuilderGidBuilder builder() static nothrowGet builder for [gdk.dmabuf_texture_builder.DmabufTextureBuilder] Returns: New builder objectgdk.display.Display display() @property nothrowGet `display` property. Returns: The display that this texture will be used on.void display(gdk.display.Display propval) @property nothrowSet `display` property. Params: propval = The display that this texture will be used on.uint fourcc() @property nothrowGet `fourcc` property. Returns: The format of the texture, as a fourcc value.void fourcc(uint propval) @property nothrowSet `fourcc` property. Params: propval = The format of the texture, as a fourcc value.void height(uint propval) @property nothrowSet `height` property. Params: propval = The height of the texture.void modifier(ulong propval) @property nothrowSet `modifier` property. Params: propval = The modifier.uint nPlanes() @property nothrowGet `nPlanes` property. Returns: The number of planes of the texture.void nPlanes(uint propval) @property nothrowSet `nPlanes` property. Params: propval = The number of planes of the texture.bool premultiplied() @property nothrowGet `premultiplied` property. Returns: Whether the alpha channel is premultiplied into the others.void premultiplied(bool propval) @property nothrowSet `premultiplied` property. Params: propval = Whether the alpha channel is premultiplied into the others.cairo.region.Region updateRegion() @property nothrowGet `updateRegion` property. Returns: The update region for [gdk.gltexture_builder.GLTextureBuilder.updateTexture].void updateRegion(cairo.region.Region propval) @property nothrowSet `updateRegion` property. Params: propval = The update region for [gdk.gltexture_builder.GLTextureBuilder.updateTexture].gdk.texture.Texture updateTexture() @property nothrowGet `updateTexture` property. Returns: The texture [gdk.dmabuf_texture_builder.DmabufTextureBuilder.updateRegion] is an update for.void updateTexture(gdk.texture.Texture propval) @property nothrowSet `updateTexture` property. Params: propval = The texture [gdk.dmabuf_texture_builder.DmabufTextureBuilder.updateRegion] is an update for.void width(uint propval) @property nothrowSet `width` property. Params: propval = The width of the texture.gdk.texture.Texture build(glib.types.DestroyNotify destroy = null, void * data = null)Builds a new [gdk.texture.Texture] with the values set up in the builder.gdk.display.Display getDisplay() nothrowReturns the display that this texture builder is associated with. Returns: the displayuint getFourcc() nothrowGets the format previously set via [gdk.dmabuf_texture_builder.DmabufTextureBuilder.setFourcc] or 0 if the format wasn't set.uint getHeight() nothrowGets the height previously set via [gdk.dmabuf_texture_builder.DmabufTextureBuilder.setHeight] or 0 if the height wasn't set. Returns: The heightbool getPremultiplied() nothrowWhether the data is premultiplied. Returns: whether the data is premultipliedcairo.region.Region getUpdateRegion() nothrowGets the region previously set via [gdk.dmabuf_texture_builder.DmabufTextureBuilder.setUpdateRegion] or null if none was set. Returns: The regiongdk.texture.Texture getUpdateTexture() nothrowGets the texture previously set via [gdk.dmabuf_texture_builder.DmabufTextureBuilder.setUpdateTexture] or null if none was set. Returns: The textureuint getWidth() nothrowGets the width previously set via [gdk.dmabuf_texture_builder.DmabufTextureBuilder.setWidth] or 0 if the width wasn't set. Returns: The widthvoid setDisplay(gdk.display.Display display) nothrowSets the display that this texture builder is associated with.void setUpdateRegion(cairo.region.Region region = null) nothrowSets the region to be updated by this texture. Together with [gdk.dmabuf_texture_builder.DmabufTextureBuilder.updateTexture] this describes an update of a previous texture.void setUpdateTexture(gdk.texture.Texture texture = null) nothrowSets the texture to be updated by this texture. See [gdk.dmabuf_texture_builder.DmabufTextureBuilder.setUpdateRegion] for an explanation.Fluent builder implementation template for gdk.dmabuf_texture_builder.DmabufTextureBuilder
T display(gdk.display.Display propval) nothrowSet `display` property. Params: propval = The display that this texture will be used on. Returns: Builder instance for fluent chainingT fourcc(uint propval) nothrowSet `fourcc` property. Params: propval = The format of the texture, as a fourcc value. Returns: Builder instance for fluent chainingT height(uint propval) nothrowSet `height` property. Params: propval = The height of the texture. Returns: Builder instance for fluent chainingT modifier(ulong propval) nothrowSet `modifier` property. Params: propval = The modifier. Returns: Builder instance for fluent chainingT nPlanes(uint propval) nothrowSet `nPlanes` property. Params: propval = The number of planes of the texture.T premultiplied(bool propval) nothrowSet `premultiplied` property. Params: propval = Whether the alpha channel is premultiplied into the others.T updateRegion(cairo.region.Region propval) nothrowSet `updateRegion` property. Params: propval = The update region for [gdk.gltexture_builder.GLTextureBuilder.updateTexture]. Returns: Builder instance for fluent chainingT updateTexture(gdk.texture.Texture propval) nothrowSet `updateTexture` property. Params: propval = The texture [gdk.dmabuf_texture_builder.DmabufTextureBuilder.updateRegion] is an update for. Returns: Builder instance for fluent chainingT width(uint propval) nothrowSet `width` property. Params: propval = The width of the texture. Returns: Builder instance for fluent chaining