Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: DmabufTextureBuilderMeta

[514:14] static extends: object

Generated metadata helpers for DmabufTextureBuilder class surfaces.

Methods

  • properties ()

    Returns property metadata for DmabufTextureBuilder.

    • @r A list.

class: DmabufTextureBuilder

[53:7] extends: object

Constructs [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, more than one file descriptor may be present, up to the number of planes. If the number of file descriptors is less than the number of planes, the remaining ones should be set to -1. 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 * The Linux kernel documentation * The header file drm_fourcc.h

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • DmabufTextureBuilder ()

    Creates a new texture builder.

  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • asObject ()

    Wraps this handle as Object.

    • @r A Object object.
  • getProperty (string Name)

    Reads one generated property by name.

  • setProperty (string Name, Value)

    Writes one generated property by name.

  • setColorstate (object Value)

    The color state of the texture.

    • @p Value is the new property value.
    • @r None.
  • setDisplay (object Value)

    The display that this texture will be used on.

    • @p Value is the new property value.
    • @r None.
  • setFourcc (int Value)

    The format of the texture, as a fourcc value.

    • @p Value is the new property value.
    • @r None.
  • setHeight (int Value)

    The height of the texture.

    • @p Value is the new property value.
    • @r None.
  • setNplanes (int Value)

    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.

    • @p Value is the new property value.
    • @r None.
  • setPremultiplied (bool Value)

    Whether the alpha channel is premultiplied into the others. Only relevant if the format has alpha.

    • @p Value is the new property value.
    • @r None.
  • setUpdateregion (object Value)

    The update region for [property@Gdk.DmabufTextureBuilder:update-texture].

    • @p Value is the new property value.
    • @r None.
  • setUpdatetexture (object Value)

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

    • @p Value is the new property value.
    • @r None.
  • setWidth (int Value)

    The width of the texture.

    • @p Value is the new property value.
    • @r None.
  • get_color_state ()

    Gets the color state previously set via gdk_dmabuf_texture_builder_set_color_state().

  • get_display ()

    Returns the display that this texture builder is associated with.

  • get_fd (int plane)

    Gets the file descriptor for a plane or -1 if none.

    • @p plane is the plane to get the fd for.
  • get_height ()

    Gets the height previously set via gdk_dmabuf_texture_builder_set_height() or 0 if the height wasn't set.

  • get_n_planes ()

    Gets the number of planes.

  • get_offset (int plane)

    Gets the offset value for a plane.

    • @p plane is the plane to get the offset for.
  • get_premultiplied ()

    Whether the data is premultiplied.

  • get_stride (int plane)

    Gets the stride value for a plane.

    • @p plane is the plane to get the stride for.
  • get_update_region ()

    Gets the region previously set via gdk_dmabuf_texture_builder_set_update_region() or %NULL if none was set.

  • get_update_texture ()

    Gets the texture previously set via gdk_dmabuf_texture_builder_set_update_texture() or %NULL if none was set.

  • get_width ()

    Gets the width previously set via gdk_dmabuf_texture_builder_set_width() or 0 if the width wasn't set.

  • set_color_state (object color_state)

    Sets the color state for the texture. By default, the colorstate is NULL. In that case, GTK will choose the correct colorstate based on the format. If you don't know what colorstates are, this is probably the right thing.

    • @p color_state is a GdkColorState or NULL to unset the colorstate..
    • @r None.
  • set_display (object display)

    Sets the display that this texture builder is associated with. The display is used to determine the supported dma-buf formats.

    • @p display is the display.
    • @r None.
  • set_fd (int plane, int fd)

    Sets the file descriptor for a plane or to -1 to unset it.

    • @p plane is the plane to set the fd for.
    • @p fd is the file descriptor.
    • @r None.
  • set_height (int height)

    Sets the height of the texture. The height must be set before calling [method@Gdk.DmabufTextureBuilder.build].

    • @p height is the texture's height or 0 to unset.
    • @r None.
  • set_n_planes (int n_planes)

    Sets the number of planes of the texture.

    • @p n_planes is the number of planes.
    • @r None.
  • set_offset (int plane, int offset)

    Sets the offset for a plane.

    • @p plane is the plane to set the offset for.
    • @p offset is the offset value.
    • @r None.
  • set_premultiplied (bool premultiplied)

    Sets whether the data is premultiplied. Unless otherwise specified, all formats including alpha channels are assumed to be premultiplied.

    • @p premultiplied is whether the data is premultiplied.
    • @r None.
  • set_stride (int plane, int stride)

    Sets the stride for a plane. The stride must be set for all planes before calling [method@Gdk.DmabufTextureBuilder.build].

    • @p plane is the plane to set the stride for.
    • @p stride is the stride value.
    • @r None.
  • set_update_region (object region)

    Sets the region to be updated by this texture. Together with [property@Gdk.DmabufTextureBuilder: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.

    • @p region is the region to update.
    • @r None.
  • set_update_texture (object texture)

    Sets the texture to be updated by this texture. See [method@Gdk.DmabufTextureBuilder.set_update_region] for an explanation.

    • @p texture is the texture to update.
    • @r None.
  • set_width (int width)

    Sets the width of the texture. The width must be set before calling [method@Gdk.DmabufTextureBuilder.build].

    • @p width is The texture's width or 0 to unset.
    • @r None.