gtkmm 4.14.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Symbols | List of all members
Gdk::DmabufTextureBuilder Class Reference

Gdk::DmabufTextureBuilder is a builder used to construct Gdk::Texture objects from DMA buffers. More...

#include <gdkmm/dmabuftexturebuilder.h>

Inheritance diagram for Gdk::DmabufTextureBuilder:
Inheritance graph
[legend]

Public Types

using SlotDmabufTextureReleased = sigc::slot< void()>
 For instance, void on_dmabuf_texture_released();.
 

Public Member Functions

 DmabufTextureBuilder (DmabufTextureBuilder && src) noexcept
 
DmabufTextureBuilderoperator= (DmabufTextureBuilder && src) noexcept
 
 ~DmabufTextureBuilder () noexcept override
 
GdkDmabufTextureBuilder * gobj ()
 Provides access to the underlying C GObject.
 
const GdkDmabufTextureBuilder * gobj () const
 Provides access to the underlying C GObject.
 
GdkDmabufTextureBuilder * gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
 
Glib::RefPtr< Displayget_display ()
 Returns the display that this texture builder is associated with.
 
Glib::RefPtr< const Displayget_display () const
 Returns the display that this texture builder is associated with.
 
void set_display (const Glib::RefPtr< Display > & display)
 Sets the display that this texture builder is associated with.
 
unsigned int get_width () const
 Gets the width previously set via set_width() or 0 if the width wasn't set.
 
void set_width (unsigned int width)
 Sets the width of the texture.
 
unsigned int get_height () const
 Gets the height previously set via set_height() or 0 if the height wasn't set.
 
void set_height (unsigned int height)
 Sets the height of the texture.
 
guint32 get_fourcc () const
 Gets the format previously set via set_fourcc() or 0 if the format wasn't set.
 
void set_fourcc (guint32 fourcc)
 Sets the format of the texture.
 
guint64 get_modifier () const
 Gets the modifier value.
 
void set_modifier (guint64 modifier)
 Sets the modifier.
 
bool get_premultiplied () const
 Whether the data is premultiplied.
 
void set_premultiplied (bool premultiplied=true)
 Sets whether the data is premultiplied.
 
unsigned int get_n_planes () const
 Gets the number of planes.
 
void set_n_planes (unsigned int n_planes)
 Sets the number of planes of the texture.
 
int get_fd (unsigned int plane) const
 Gets the file descriptor for a plane.
 
void set_fd (unsigned int plane, int fd)
 Sets the file descriptor for a plane.
 
unsigned int get_stride (unsigned int plane) const
 Gets the stride value for a plane.
 
void set_stride (unsigned int plane, unsigned int stride)
 Sets the stride for a plane.
 
unsigned int get_offset (unsigned int plane) const
 Gets the offset value for a plane.
 
void set_offset (unsigned int plane, unsigned int offset)
 Sets the offset for a plane.
 
Glib::RefPtr< Textureget_update_texture ()
 Gets the texture previously set via set_update_texture() or nullptr if none was set.
 
Glib::RefPtr< const Textureget_update_texture () const
 Gets the texture previously set via set_update_texture() or nullptr if none was set.
 
void set_update_texture (const Glib::RefPtr< Texture > & texture)
 Sets the texture to be updated by this texture.
 
::Cairo::RefPtr< ::Cairo::Region > get_update_region ()
 Gets the region previously set via set_update_region() or nullptr if none was set.
 
::Cairo::RefPtr< const ::Cairo::Region > get_update_region () const
 Gets the region previously set via set_update_region() or nullptr if none was set.
 
void set_update_region (const ::Cairo::RefPtr< ::Cairo::Region > & region)
 Sets the region to be updated by this texture.
 
Glib::RefPtr< Texturebuild (const SlotDmabufTextureReleased & slot={})
 Builds a new Gdk::Texture with the values set up in the builder.
 
Glib::PropertyProxy< Glib::RefPtr< Display > > property_display ()
 The display that this texture will be used on.
 
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Display > > property_display () const
 The display that this texture will be used on.
 
Glib::PropertyProxy< unsigned int > property_width ()
 The width of the texture.
 
Glib::PropertyProxy_ReadOnly< unsigned int > property_width () const
 The width of the texture.
 
Glib::PropertyProxy< unsigned int > property_height ()
 The height of the texture.
 
Glib::PropertyProxy_ReadOnly< unsigned int > property_height () const
 The height of the texture.
 
Glib::PropertyProxy< unsigned int > property_fourcc ()
 The format of the texture, as a fourcc value.
 
Glib::PropertyProxy_ReadOnly< unsigned int > property_fourcc () const
 The format of the texture, as a fourcc value.
 
Glib::PropertyProxy< guint64 > property_modifier ()
 The modifier.
 
Glib::PropertyProxy_ReadOnly< guint64 > property_modifier () const
 The modifier.
 
Glib::PropertyProxy< bool > property_premultiplied ()
 Whether the alpha channel is premultiplied into the others.
 
Glib::PropertyProxy_ReadOnly< bool > property_premultiplied () const
 Whether the alpha channel is premultiplied into the others.
 
Glib::PropertyProxy< unsigned int > property_n_planes ()
 The number of planes of the texture.
 
Glib::PropertyProxy_ReadOnly< unsigned int > property_n_planes () const
 The number of planes of the texture.
 
Glib::PropertyProxy< ::Cairo::RefPtr< ::Cairo::Region > > property_update_region ()
 The update region for Gdk::GLTextureBuilder::property_update_texture().
 
Glib::PropertyProxy_ReadOnly< ::Cairo::RefPtr< ::Cairo::Region > > property_update_region () const
 The update region for Gdk::GLTextureBuilder::property_update_texture().
 
Glib::PropertyProxy< Glib::RefPtr< Texture > > property_update_texture ()
 The texture property_update_region() is an update for.
 
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Texture > > property_update_texture () const
 The texture property_update_region() is an update for.
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system.
 
static Glib::RefPtr< DmabufTextureBuildercreate ()
 

Protected Member Functions

 DmabufTextureBuilder ()
 

Related Symbols

(Note that these are not member symbols.)

Glib::RefPtr< Gdk::DmabufTextureBuilderwrap (GdkDmabufTextureBuilder * object, bool take_copy=false)
 A Glib::wrap() method for this object.
 

Detailed Description

Gdk::DmabufTextureBuilder is a builder used to construct Gdk::Texture objects from DMA buffers.

DMA buffers are commonly called dma-bufs.

DMA buffers is 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/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.

The operation of Gdk::DmabufTextureBuilder is quite simple: Create a texture builder, set all the necessary properties, and then call build() to create the new texture.

The required properties for a dma-buf texture are

Gdk::DmabufTextureBuilder can be used for quick one-shot construction of textures as well as kept around and reused to construct multiple textures.

Since gtkmm 4.14:

Member Typedef Documentation

◆ SlotDmabufTextureReleased

For instance, void on_dmabuf_texture_released();.

Constructor & Destructor Documentation

◆ DmabufTextureBuilder() [1/2]

Gdk::DmabufTextureBuilder::DmabufTextureBuilder ( DmabufTextureBuilder &&  src)
noexcept

◆ ~DmabufTextureBuilder()

Gdk::DmabufTextureBuilder::~DmabufTextureBuilder ( )
overridenoexcept

◆ DmabufTextureBuilder() [2/2]

Gdk::DmabufTextureBuilder::DmabufTextureBuilder ( )
protected

Member Function Documentation

◆ build()

Glib::RefPtr< Texture > Gdk::DmabufTextureBuilder::build ( const SlotDmabufTextureReleased slot = {})

Builds a new Gdk::Texture 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.

If the dmabuf is not supported by GTK, an exception will be thrown.

The slot gets called when the returned texture gets released.

It is possible to call this function multiple times to create multiple textures, possibly with changing properties in between.

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 slot notify).

Not all formats defined in the drm_fourcc.h header are supported. You can use Gdk::Display::get_dmabuf_formats() to get a list of supported formats.

Since gtkmm 4.14:
Parameters
slotDestroy function to be called when the texture is released.
Returns
A newly built Gdk::Texture or an empty RefPtr if the format is not supported, or any mandatory property has not been set.
Exceptions
Glib::Error

◆ create()

static Glib::RefPtr< DmabufTextureBuilder > Gdk::DmabufTextureBuilder::create ( )
static

◆ get_display() [1/2]

Glib::RefPtr< Display > Gdk::DmabufTextureBuilder::get_display ( )

Returns the display that this texture builder is associated with.

Since gtkmm 4.14:
Returns
The display.

◆ get_display() [2/2]

Glib::RefPtr< const Display > Gdk::DmabufTextureBuilder::get_display ( ) const

Returns the display that this texture builder is associated with.

Since gtkmm 4.14:
Returns
The display.

◆ get_fd()

int Gdk::DmabufTextureBuilder::get_fd ( unsigned int  plane) const

Gets the file descriptor for a plane.

Since gtkmm 4.14:
Parameters
planeThe plane to get the fd for.
Returns
The file descriptor.

◆ get_fourcc()

guint32 Gdk::DmabufTextureBuilder::get_fourcc ( ) const

Gets the format previously set via set_fourcc() or 0 if the format wasn't set.

The format is specified as a fourcc code.

Since gtkmm 4.14:
Returns
The format.

◆ get_height()

unsigned int Gdk::DmabufTextureBuilder::get_height ( ) const

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

Since gtkmm 4.14:
Returns
The height.

◆ get_modifier()

guint64 Gdk::DmabufTextureBuilder::get_modifier ( ) const

Gets the modifier value.

Since gtkmm 4.14:
Returns
The modifier.

◆ get_n_planes()

unsigned int Gdk::DmabufTextureBuilder::get_n_planes ( ) const

Gets the number of planes.

Since gtkmm 4.14:
Returns
The number of planes.

◆ get_offset()

unsigned int Gdk::DmabufTextureBuilder::get_offset ( unsigned int  plane) const

Gets the offset value for a plane.

Since gtkmm 4.14:
Parameters
planeThe plane to get the offset for.
Returns
The offset.

◆ get_premultiplied()

bool Gdk::DmabufTextureBuilder::get_premultiplied ( ) const

Whether the data is premultiplied.

Since gtkmm 4.14:
Returns
Whether the data is premultiplied.

◆ get_stride()

unsigned int Gdk::DmabufTextureBuilder::get_stride ( unsigned int  plane) const

Gets the stride value for a plane.

Since gtkmm 4.14:
Parameters
planeThe plane to get the stride for.
Returns
The stride.

◆ get_type()

static GType Gdk::DmabufTextureBuilder::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ get_update_region() [1/2]

::Cairo::RefPtr< ::Cairo::Region > Gdk::DmabufTextureBuilder::get_update_region ( )

Gets the region previously set via set_update_region() or nullptr if none was set.

Since gtkmm 4.14:
Returns
The region.

◆ get_update_region() [2/2]

::Cairo::RefPtr< const ::Cairo::Region > Gdk::DmabufTextureBuilder::get_update_region ( ) const

Gets the region previously set via set_update_region() or nullptr if none was set.

Since gtkmm 4.14:
Returns
The region.

◆ get_update_texture() [1/2]

Glib::RefPtr< Texture > Gdk::DmabufTextureBuilder::get_update_texture ( )

Gets the texture previously set via set_update_texture() or nullptr if none was set.

Since gtkmm 4.14:
Returns
The texture.

◆ get_update_texture() [2/2]

Glib::RefPtr< const Texture > Gdk::DmabufTextureBuilder::get_update_texture ( ) const

Gets the texture previously set via set_update_texture() or nullptr if none was set.

Since gtkmm 4.14:
Returns
The texture.

◆ get_width()

unsigned int Gdk::DmabufTextureBuilder::get_width ( ) const

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

Since gtkmm 4.14:
Returns
The width.

◆ gobj() [1/2]

GdkDmabufTextureBuilder * Gdk::DmabufTextureBuilder::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GdkDmabufTextureBuilder * Gdk::DmabufTextureBuilder::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ gobj_copy()

GdkDmabufTextureBuilder * Gdk::DmabufTextureBuilder::gobj_copy ( )

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

◆ operator=()

DmabufTextureBuilder & Gdk::DmabufTextureBuilder::operator= ( DmabufTextureBuilder &&  src)
noexcept

◆ property_display() [1/2]

Glib::PropertyProxy< Glib::RefPtr< Display > > Gdk::DmabufTextureBuilder::property_display ( )

The display that this texture will be used on.

Since gtkmm 4.14:
Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_display() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Display > > Gdk::DmabufTextureBuilder::property_display ( ) const

The display that this texture will be used on.

Since gtkmm 4.14:
Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_fourcc() [1/2]

Glib::PropertyProxy< unsigned int > Gdk::DmabufTextureBuilder::property_fourcc ( )

The format of the texture, as a fourcc value.

Since gtkmm 4.14:

Default value: 0

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_fourcc() [2/2]

Glib::PropertyProxy_ReadOnly< unsigned int > Gdk::DmabufTextureBuilder::property_fourcc ( ) const

The format of the texture, as a fourcc value.

Since gtkmm 4.14:

Default value: 0

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_height() [1/2]

Glib::PropertyProxy< unsigned int > Gdk::DmabufTextureBuilder::property_height ( )

The height of the texture.

Since gtkmm 4.14:

Default value: 0

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_height() [2/2]

Glib::PropertyProxy_ReadOnly< unsigned int > Gdk::DmabufTextureBuilder::property_height ( ) const

The height of the texture.

Since gtkmm 4.14:

Default value: 0

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_modifier() [1/2]

Glib::PropertyProxy< guint64 > Gdk::DmabufTextureBuilder::property_modifier ( )

The modifier.

Since gtkmm 4.14:

Default value: 0

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_modifier() [2/2]

Glib::PropertyProxy_ReadOnly< guint64 > Gdk::DmabufTextureBuilder::property_modifier ( ) const

The modifier.

Since gtkmm 4.14:

Default value: 0

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_n_planes() [1/2]

Glib::PropertyProxy< unsigned int > Gdk::DmabufTextureBuilder::property_n_planes ( )

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.

Since gtkmm 4.14:

Default value: 1

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_n_planes() [2/2]

Glib::PropertyProxy_ReadOnly< unsigned int > Gdk::DmabufTextureBuilder::property_n_planes ( ) const

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.

Since gtkmm 4.14:

Default value: 1

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_premultiplied() [1/2]

Glib::PropertyProxy< bool > Gdk::DmabufTextureBuilder::property_premultiplied ( )

Whether the alpha channel is premultiplied into the others.

Only relevant if the format has alpha.

Since gtkmm 4.14:

Default value: true

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_premultiplied() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gdk::DmabufTextureBuilder::property_premultiplied ( ) const

Whether the alpha channel is premultiplied into the others.

Only relevant if the format has alpha.

Since gtkmm 4.14:

Default value: true

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_update_region() [1/2]

Glib::PropertyProxy< ::Cairo::RefPtr< ::Cairo::Region > > Gdk::DmabufTextureBuilder::property_update_region ( )

The update region for Gdk::GLTextureBuilder::property_update_texture().

Since gtkmm 4.14:
Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_update_region() [2/2]

Glib::PropertyProxy_ReadOnly< ::Cairo::RefPtr< ::Cairo::Region > > Gdk::DmabufTextureBuilder::property_update_region ( ) const

The update region for Gdk::GLTextureBuilder::property_update_texture().

Since gtkmm 4.14:
Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_update_texture() [1/2]

Glib::PropertyProxy< Glib::RefPtr< Texture > > Gdk::DmabufTextureBuilder::property_update_texture ( )

The texture property_update_region() is an update for.

Since gtkmm 4.14:
Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_update_texture() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Texture > > Gdk::DmabufTextureBuilder::property_update_texture ( ) const

The texture property_update_region() is an update for.

Since gtkmm 4.14:
Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_width() [1/2]

Glib::PropertyProxy< unsigned int > Gdk::DmabufTextureBuilder::property_width ( )

The width of the texture.

Since gtkmm 4.14:

Default value: 0

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_width() [2/2]

Glib::PropertyProxy_ReadOnly< unsigned int > Gdk::DmabufTextureBuilder::property_width ( ) const

The width of the texture.

Since gtkmm 4.14:

Default value: 0

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ set_display()

void Gdk::DmabufTextureBuilder::set_display ( const Glib::RefPtr< Display > &  display)

Sets the display that this texture builder is associated with.

The display is used to determine the supported dma-buf formats.

Since gtkmm 4.14:
Parameters
displayThe display.

◆ set_fd()

void Gdk::DmabufTextureBuilder::set_fd ( unsigned int  plane,
int  fd 
)

Sets the file descriptor for a plane.

Since gtkmm 4.14:
Parameters
planeThe plane to set the fd for.
fdThe file descriptor.

◆ set_fourcc()

void Gdk::DmabufTextureBuilder::set_fourcc ( guint32  fourcc)

Sets the format of the texture.

The format is specified as a fourcc code.

The format must be set before calling Gdk::GLTextureBuilder::build().

Since gtkmm 4.14:
Parameters
fourccThe texture's format or 0 to unset.

◆ set_height()

void Gdk::DmabufTextureBuilder::set_height ( unsigned int  height)

Sets the height of the texture.

The height must be set before calling Gdk::GLTextureBuilder::build().

Since gtkmm 4.14:
Parameters
heightThe texture's height or 0 to unset.

◆ set_modifier()

void Gdk::DmabufTextureBuilder::set_modifier ( guint64  modifier)

Sets the modifier.

Since gtkmm 4.14:
Parameters
modifierThe modifier value.

◆ set_n_planes()

void Gdk::DmabufTextureBuilder::set_n_planes ( unsigned int  n_planes)

Sets the number of planes of the texture.

Since gtkmm 4.14:
Parameters
n_planesThe number of planes.

◆ set_offset()

void Gdk::DmabufTextureBuilder::set_offset ( unsigned int  plane,
unsigned int  offset 
)

Sets the offset for a plane.

Since gtkmm 4.14:
Parameters
planeThe plane to set the offset for.
offsetThe offset value.

◆ set_premultiplied()

void Gdk::DmabufTextureBuilder::set_premultiplied ( bool  premultiplied = true)

Sets whether the data is premultiplied.

Unless otherwise specified, all formats including alpha channels are assumed to be premultiplied.

Since gtkmm 4.14:
Parameters
premultipliedWhether the data is premultiplied.

◆ set_stride()

void Gdk::DmabufTextureBuilder::set_stride ( unsigned int  plane,
unsigned int  stride 
)

Sets the stride for a plane.

The stride must be set for all planes before calling Gdk::GLTextureBuilder::build().

Since gtkmm 4.14:
Parameters
planeThe plane to set the stride for.
strideThe stride value.

◆ set_update_region()

void Gdk::DmabufTextureBuilder::set_update_region ( const ::Cairo::RefPtr< ::Cairo::Region > &  region)

Sets the region to be updated by this texture.

Together with property_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.

Since gtkmm 4.14:
Parameters
regionThe region to update.

◆ set_update_texture()

void Gdk::DmabufTextureBuilder::set_update_texture ( const Glib::RefPtr< Texture > &  texture)

Sets the texture to be updated by this texture.

See set_update_region() for an explanation.

Since gtkmm 4.14:
Parameters
textureThe texture to update.

◆ set_width()

void Gdk::DmabufTextureBuilder::set_width ( unsigned int  width)

Sets the width of the texture.

The width must be set before calling Gdk::GLTextureBuilder::build().

Since gtkmm 4.14:
Parameters
widthThe texture's width or 0 to unset.

Friends And Related Symbol Documentation

◆ wrap()

Glib::RefPtr< Gdk::DmabufTextureBuilder > wrap ( GdkDmabufTextureBuilder *  object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.