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
DmabufTextureBuilder self()Returns `this`, for use in `with` statements.DmabufTextureBuilderGidBuilder builder()Get builder for [gdk.dmabuftexturebuilder.DmabufTextureBuilder] Returns: New builder objectgdk.display.Display display() @propertyGet `display` property. Returns: The display that this texture will be used on.void display(gdk.display.Display propval) @propertySet `display` property. Params: propval = The display that this texture will be used on.uint fourcc() @propertyGet `fourcc` property. Returns: The format of the texture, as a fourcc value.void fourcc(uint propval) @propertySet `fourcc` property. Params: propval = The format of the texture, as a fourcc value.void height(uint propval) @propertySet `height` property. Params: propval = The height of the texture.void nPlanes(uint propval) @propertySet `nPlanes` property. Params: propval = The number of planes of the texture.bool premultiplied() @propertyGet `premultiplied` property. Returns: Whether the alpha channel is premultiplied into the others.void premultiplied(bool propval) @propertySet `premultiplied` property. Params: propval = Whether the alpha channel is premultiplied into the others.cairo.region.Region updateRegion() @propertyGet `updateRegion` property. Returns: The update region for `property@Gdk.GLTextureBuilder:update-texture`.void updateRegion(cairo.region.Region propval) @propertySet `updateRegion` property. Params: propval = The update region for `property@Gdk.GLTextureBuilder:update-texture`.gdk.texture.Texture updateTexture() @propertyGet `updateTexture` property. Returns: The texture `property@Gdk.DmabufTextureBuilder:update-region` is an update for.void updateTexture(gdk.texture.Texture propval) @propertySet `updateTexture` property. Params: propval = The texture `property@Gdk.DmabufTextureBuilder:update-region` is an update for.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()Returns the display that this texture builder is associated with. Returns: the displayint getFd(uint plane)Gets the file descriptor for a plane.uint getFourcc()Gets the format previously set via [gdk.dmabuftexturebuilder.DmabufTextureBuilder.setFourcc] or 0 if the format wasn't set.uint getHeight()Gets the height previously set via [gdk.dmabuftexturebuilder.DmabufTextureBuilder.setHeight] or 0 if the height wasn't set. Returns: The heightulong getModifier()Gets the modifier value. Returns: the modifieruint getNPlanes()Gets the number of planes. Returns: The number of planesuint getOffset(uint plane)Gets the offset value for a plane.bool getPremultiplied()Whether the data is premultiplied. Returns: whether the data is premultiplieduint getStride(uint plane)Gets the stride value for a plane.cairo.region.Region getUpdateRegion()Gets the region previously set via [gdk.dmabuftexturebuilder.DmabufTextureBuilder.setUpdateRegion] or null if none was set. Returns: The regiongdk.texture.Texture getUpdateTexture()Gets the texture previously set via [gdk.dmabuftexturebuilder.DmabufTextureBuilder.setUpdateTexture] or null if none was set. Returns: The textureuint getWidth()Gets the width previously set via [gdk.dmabuftexturebuilder.DmabufTextureBuilder.setWidth] or 0 if the width wasn't set. Returns: The widthvoid setDisplay(gdk.display.Display display)Sets the display that this texture builder is associated with.void setFd(uint plane, int fd)Sets the file descriptor for a plane.void setFourcc(uint fourcc)Sets the format of the texture.void setHeight(uint height)Sets the height of the texture.void setModifier(ulong modifier)Sets the modifier.void setNPlanes(uint nPlanes)Sets the number of planes of the texture.void setOffset(uint plane, uint offset)Sets the offset for a plane.void setPremultiplied(bool premultiplied)Sets whether the data is premultiplied.void setStride(uint plane, uint stride)Sets the stride for a plane.void setUpdateRegion(cairo.region.Region region = null)Sets the region to be updated by this texture. Together with `propertyGdk.DmabufTextureBuilder:update-texture` this describes an update of a previous texture.void setUpdateTexture(gdk.texture.Texture texture = null)Sets the texture to be updated by this texture. See [gdk.dmabuftexturebuilder.DmabufTextureBuilder.setUpdateRegion] for an explanation.void setWidth(uint width)Sets the width of the texture.T display(gdk.display.Display propval)Set `display` property. Params: propval = The display that this texture will be used on. Returns: Builder instance for fluent chainingT fourcc(uint propval)Set `fourcc` property. Params: propval = The format of the texture, as a fourcc value. Returns: Builder instance for fluent chainingT height(uint propval)Set `height` property. Params: propval = The height of the texture. Returns: Builder instance for fluent chainingT modifier(ulong propval)Set `modifier` property. Params: propval = The modifier. Returns: Builder instance for fluent chainingT nPlanes(uint propval)Set `nPlanes` property. Params: propval = The number of planes of the texture.T premultiplied(bool propval)Set `premultiplied` property. Params: propval = Whether the alpha channel is premultiplied into the others.T updateRegion(cairo.region.Region propval)Set `updateRegion` property. Params: propval = The update region for `property@Gdk.GLTextureBuilder:update-texture`. Returns: Builder instance for fluent chainingT updateTexture(gdk.texture.Texture propval)Set `updateTexture` property. Params: propval = The texture `property@Gdk.DmabufTextureBuilder:update-region` is an update for. Returns: Builder instance for fluent chainingT width(uint propval)Set `width` property. Params: propval = The width of the texture. Returns: Builder instance for fluent chainingFluent builder for [gdk.dmabuf_texture_builder.DmabufTextureBuilder]