It derives from <GObject>.
Constructs <GdkTexture> 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 dmabuf-texture-builder:build to create the new texture.
The required properties for a dma-buf texture are
fourcc code and modifier which identify the format and
memory layout of the dma-buf
<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 color state of the texture.
Its value is a <GdkColorState>, or #f.
Set it with (set! (dmabuf-texture-builder:color-state self)
value).
The display that this texture will be used on.
Its value is a <GdkDisplay>, or #f.
Set it with (set! (dmabuf-texture-builder:display self) value).
The format of the texture, as a fourcc value.
Its value is an unsigned 32-bit integer.
Set it with (set! (dmabuf-texture-builder:fourcc self) value).
The height of the texture.
Its value is an unsigned 32-bit integer.
Set it with (set! (dmabuf-texture-builder:height self) value).
The modifier.
Its value is an unsigned 64-bit integer.
Set it with (set! (dmabuf-texture-builder:modifier self) 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.
Its value is an unsigned 32-bit integer.
Set it with (set! (dmabuf-texture-builder:n-planes self) value).
Whether the alpha channel is premultiplied into the others.
Only relevant if the format has alpha.
Its value is a boolean.
Set it with (set! (dmabuf-texture-builder:premultiplied self)
value).
The update region for dmabuf-texture-builder:update-texture.
Its value is a <CairoRegion>, or #f.
Set it with (set! (dmabuf-texture-builder:update-region self)
value).
The texture dmabuf-texture-builder:update-region is an update for.
Its value is a <GdkTexture>, or #f.
Set it with (set! (dmabuf-texture-builder:update-texture self)
value).
The width of the texture.
Its value is an unsigned 32-bit integer.
Set it with (set! (dmabuf-texture-builder:width self) value).
Builds a new <GdkTexture> with the values set up
in the builder.
It is a programming error to call this function if any mandatory property has not been set.
Not all formats defined in the drm_fourcc.h header are supported.
You can use display:get-dmabuf-formats to get a list of
supported formats. If the format is not supported by GTK, #f
will be returned and error will be set.
The destroy function gets called when the returned texture gets
released.
It is the responsibility of the caller to keep the file descriptors for the planes open until the created texture is no longer used, and close them afterwards (possibly using the destroy notify).
It is possible to call this function multiple times to create multiple textures, possibly with changing properties in between.
Passed: a <GdkDmabufTextureBuilder>.
Passed, or left out: a procedure, or #f.
destroy function to be called when the texture is released
See GDestroyNotify for how it is
called.
Passed, or left out: a foreign pointer, or a bytevector, or #f.
user data to pass to the destroy function
Returned: a <GdkTexture>, or #f.
a newly built <GdkTexture> or NULL if the
format is not supported
Gets the color state previously set via dmabuf-texture-builder:set-color-state.
Passed: a <GdkDmabufTextureBuilder>.
Returned: a <GdkColorState>, or #f.
the color state
Returns the display that this texture builder is associated with.
Passed: a <GdkDmabufTextureBuilder>.
a ‘GdkDmabufTextureBuilder
Returned: a <GdkDisplay>.
the display
Gets the file descriptor for a plane or -1 if none.
Passed: a <GdkDmabufTextureBuilder>.
Passed: an unsigned 32-bit integer.
the plane to get the fd for
Returned: a 32-bit integer.
the file descriptor
Gets the format previously set via dmabuf-texture-builder:set-fourcc or 0 if the format
wasn’t set.
The format is specified as a fourcc code.
Passed: a <GdkDmabufTextureBuilder>.
Returned: an unsigned 32-bit integer.
The format
Gets the height previously set via dmabuf-texture-builder:set-height or 0 if the height
wasn’t set.
Passed: a <GdkDmabufTextureBuilder>.
Returned: an unsigned 32-bit integer.
The height
Gets the modifier value.
Passed: a <GdkDmabufTextureBuilder>.
Returned: an unsigned 64-bit integer.
the modifier
Gets the number of planes.
Passed: a <GdkDmabufTextureBuilder>.
Returned: an unsigned 32-bit integer.
The number of planes
Gets the offset value for a plane.
Passed: a <GdkDmabufTextureBuilder>.
Passed: an unsigned 32-bit integer.
the plane to get the offset for
Returned: an unsigned 32-bit integer.
the offset
Whether the data is premultiplied.
Passed: a <GdkDmabufTextureBuilder>.
Returned: a boolean.
whether the data is premultiplied
Gets the stride value for a plane.
Passed: a <GdkDmabufTextureBuilder>.
Passed: an unsigned 32-bit integer.
the plane to get the stride for
Returned: an unsigned 32-bit integer.
the stride
Gets the region previously set via dmabuf-texture-builder:set-update-region or
#f if none was set.
Passed: a <GdkDmabufTextureBuilder>.
Returned: a <CairoRegion>, or #f.
The region
Gets the texture previously set via dmabuf-texture-builder:set-update-texture or
#f if none was set.
Passed: a <GdkDmabufTextureBuilder>.
Returned: a <GdkTexture>, or #f.
The texture
Gets the width previously set via dmabuf-texture-builder:set-width or 0 if the width wasn’t
set.
Passed: a <GdkDmabufTextureBuilder>.
Returned: an unsigned 32-bit integer.
The width
Creates a new texture builder.
Returned: a
<GdkDmabufTextureBuilder>.
the new GdkTextureBuilder
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.
Passed: a <GdkDmabufTextureBuilder>.
Passed, or left out: a <GdkColorState>, or
#f.
a <GdkColorState> or NULL to unset the
colorstate.
Sets the display that this texture builder is associated with.
The display is used to determine the supported dma-buf formats.
Passed: a <GdkDmabufTextureBuilder>.
a ‘GdkDmabufTextureBuilder
Passed: a <GdkDisplay>.
the display
Sets the file descriptor for a plane or to -1 to unset it.
Passed: a <GdkDmabufTextureBuilder>.
Passed: an unsigned 32-bit integer.
the plane to set the fd for
Passed: a 32-bit integer.
the file descriptor
Sets the format of the texture.
The format is specified as a fourcc code.
The format must be set before calling dmabuf-texture-builder:build.
Passed: a <GdkDmabufTextureBuilder>.
Passed: an unsigned 32-bit integer.
the texture’s format or 0 to unset
Sets the height of the texture.
The height must be set before calling dmabuf-texture-builder:build.
Passed: a <GdkDmabufTextureBuilder>.
Passed: an unsigned 32-bit integer.
the texture’s height or 0 to unset
Sets the modifier.
Passed: a <GdkDmabufTextureBuilder>.
Passed: an unsigned 64-bit integer.
the modifier value
Sets the number of planes of the texture.
Passed: a <GdkDmabufTextureBuilder>.
Passed: an unsigned 32-bit integer.
the number of planes
Sets the offset for a plane.
Passed: a <GdkDmabufTextureBuilder>.
Passed: an unsigned 32-bit integer.
the plane to set the offset for
Passed: an unsigned 32-bit integer.
the offset value
Sets whether the data is premultiplied.
Unless otherwise specified, all formats including alpha channels are assumed to be premultiplied.
Passed: a <GdkDmabufTextureBuilder>.
Passed: a boolean.
whether the data is premultiplied
Sets the stride for a plane.
The stride must be set for all planes before calling
dmabuf-texture-builder:build.
Passed: a <GdkDmabufTextureBuilder>.
Passed: an unsigned 32-bit integer.
the plane to set the stride for
Passed: an unsigned 32-bit integer.
the stride value
Sets the region to be updated by this texture. Together with
dmabuf-texture-builder: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.
Passed: a <GdkDmabufTextureBuilder>.
Passed, or left out: a <CairoRegion>, or
#f.
the region to update
Sets the texture to be updated by this texture. See
dmabuf-texture-builder:set-update-region for an
explanation.
Passed: a <GdkDmabufTextureBuilder>.
Passed, or left out: a <GdkTexture>, or #f.
the texture to update
Sets the width of the texture.
The width must be set before calling dmabuf-texture-builder:build.
Passed: a <GdkDmabufTextureBuilder>.
Passed: an unsigned 32-bit integer.
The texture’s width or 0 to unset