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 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

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

Methods
GType _getGType() static nothrow
GType _gType() @property nothrow
DmabufTextureBuilder self() nothrowReturns `this`, for use in `with` statements.
DmabufTextureBuilderGidBuilder builder() static nothrowGet builder for [gdk.dmabuf_texture_builder.DmabufTextureBuilder] Returns: New builder object
gdk.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.
uint height() @property nothrowGet `height` property. Returns: The height of the texture.
void height(uint propval) @property nothrowSet `height` property. Params: propval = The height of the texture.
ulong modifier() @property nothrowGet `modifier` property. Returns: The modifier.
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.
uint width() @property nothrowGet `width` property. Returns: The width of the texture.
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 display
int getFd(uint plane) nothrowGets the file descriptor for a plane.
uint 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 height
ulong getModifier() nothrowGets the modifier value. Returns: the modifier
uint getNPlanes() nothrowGets the number of planes. Returns: The number of planes
uint getOffset(uint plane) nothrowGets the offset value for a plane.
bool getPremultiplied() nothrowWhether the data is premultiplied. Returns: whether the data is premultiplied
uint getStride(uint plane) nothrowGets the stride value for a plane.
cairo.region.Region getUpdateRegion() nothrowGets the region previously set via [gdk.dmabuf_texture_builder.DmabufTextureBuilder.setUpdateRegion] or null if none was set. Returns: The region
gdk.texture.Texture getUpdateTexture() nothrowGets the texture previously set via [gdk.dmabuf_texture_builder.DmabufTextureBuilder.setUpdateTexture] or null if none was set. Returns: The texture
uint getWidth() nothrowGets the width previously set via [gdk.dmabuf_texture_builder.DmabufTextureBuilder.setWidth] or 0 if the width wasn't set. Returns: The width
void setDisplay(gdk.display.Display display) nothrowSets the display that this texture builder is associated with.
void setFd(uint plane, int fd) nothrowSets the file descriptor for a plane.
void setFourcc(uint fourcc) nothrowSets the format of the texture.
void setHeight(uint height) nothrowSets the height of the texture.
void setModifier(ulong modifier) nothrowSets the modifier.
void setNPlanes(uint nPlanes) nothrowSets the number of planes of the texture.
void setOffset(uint plane, uint offset) nothrowSets the offset for a plane.
void setPremultiplied(bool premultiplied) nothrowSets whether the data is premultiplied.
void setStride(uint plane, uint stride) nothrowSets the stride for a plane.
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.
void setWidth(uint width) nothrowSets the width of the texture.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new texture builder. Returns: the new `GdkTextureBuilder`

Fluent builder implementation template for gdk.dmabuf_texture_builder.DmabufTextureBuilder

Methods
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 chaining
T fourcc(uint propval) nothrowSet `fourcc` property. Params: propval = The format of the texture, as a fourcc value. Returns: Builder instance for fluent chaining
T height(uint propval) nothrowSet `height` property. Params: propval = The height of the texture. Returns: Builder instance for fluent chaining
T modifier(ulong propval) nothrowSet `modifier` property. Params: propval = The modifier. Returns: Builder instance for fluent chaining
T 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 chaining
T 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 chaining
T width(uint propval) nothrowSet `width` property. Params: propval = The width of the texture. Returns: Builder instance for fluent chaining