gi-gdk-4.0.9: Gdk bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.Gdk.Objects.DmabufTextureBuilder

Description

GdkDmabufTextureBuilder is a builder used to construct 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 GdkDmabufTextureBuilder is quite simple: Create a texture builder, set all the necessary properties, and then call dmabufTextureBuilderBuild 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

Since: 4.14

Synopsis

Exported types

class (GObject o, IsDescendantOf DmabufTextureBuilder o) => IsDmabufTextureBuilder o Source #

Type class for types which can be safely cast to DmabufTextureBuilder, for instance with toDmabufTextureBuilder.

Instances

Instances details
(GObject o, IsDescendantOf DmabufTextureBuilder o) => IsDmabufTextureBuilder o Source # 
Instance details

Defined in GI.Gdk.Objects.DmabufTextureBuilder

toDmabufTextureBuilder :: (MonadIO m, IsDmabufTextureBuilder o) => o -> m DmabufTextureBuilder Source #

Cast to DmabufTextureBuilder, for types for which this is known to be safe. For general casts, use castTo.

Methods

build

dmabufTextureBuilderBuild Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> Maybe DestroyNotify

destroy: destroy function to be called when the texture is released

-> Ptr ()

data: user data to pass to the destroy function

-> m (Maybe Texture)

Returns: a newly built GdkTexture or NULL if the format is not supported (Can throw GError)

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.

If the dmabuf is not supported by GTK, Nothing will be returned and error will be set.

The destroy function 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 destroy notify).

Not all formats defined in the drm_fourcc.h header are supported. You can use displayGetDmabufFormats to get a list of supported formats.

Since: 4.14

getDisplay

dmabufTextureBuilderGetDisplay Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a `GdkDmabufTextureBuilder

-> m Display

Returns: the display

Returns the display that this texture builder is associated with.

Since: 4.14

getFd

dmabufTextureBuilderGetFd Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> Word32

plane: the plane to get the fd for

-> m Int32

Returns: the file descriptor

Gets the file descriptor for a plane.

Since: 4.14

getFourcc

dmabufTextureBuilderGetFourcc Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> m Word32

Returns: The format

Gets the format previously set via dmabufTextureBuilderSetFourcc or 0 if the format wasn't set.

The format is specified as a fourcc code.

Since: 4.14

getHeight

dmabufTextureBuilderGetHeight Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> m Word32

Returns: The height

Gets the height previously set via dmabufTextureBuilderSetHeight or 0 if the height wasn't set.

Since: 4.14

getModifier

dmabufTextureBuilderGetModifier Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> m Word64

Returns: the modifier

Gets the modifier value.

Since: 4.14

getNPlanes

dmabufTextureBuilderGetNPlanes Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> m Word32

Returns: The number of planes

Gets the number of planes.

Since: 4.14

getOffset

dmabufTextureBuilderGetOffset Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> Word32

plane: the plane to get the offset for

-> m Word32

Returns: the offset

Gets the offset value for a plane.

Since: 4.14

getPremultiplied

dmabufTextureBuilderGetPremultiplied Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> m Bool

Returns: whether the data is premultiplied

Whether the data is premultiplied.

Since: 4.14

getStride

dmabufTextureBuilderGetStride Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> Word32

plane: the plane to get the stride for

-> m Word32

Returns: the stride

Gets the stride value for a plane.

Since: 4.14

getUpdateRegion

dmabufTextureBuilderGetUpdateRegion Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> m (Maybe Region)

Returns: The region

Gets the region previously set via dmabufTextureBuilderSetUpdateRegion or Nothing if none was set.

Since: 4.14

getUpdateTexture

dmabufTextureBuilderGetUpdateTexture Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> m (Maybe Texture)

Returns: The texture

Gets the texture previously set via dmabufTextureBuilderSetUpdateTexture or Nothing if none was set.

Since: 4.14

getWidth

dmabufTextureBuilderGetWidth Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> m Word32

Returns: The width

Gets the width previously set via dmabufTextureBuilderSetWidth or 0 if the width wasn't set.

Since: 4.14

new

dmabufTextureBuilderNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m DmabufTextureBuilder

Returns: the new GdkTextureBuilder

Creates a new texture builder.

Since: 4.14

setDisplay

dmabufTextureBuilderSetDisplay Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a, IsDisplay b) 
=> a

self: a `GdkDmabufTextureBuilder

-> b

display: the display

-> m () 

Sets the display that this texture builder is associated with.

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

Since: 4.14

setFd

dmabufTextureBuilderSetFd Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> Word32

plane: the plane to set the fd for

-> Int32

fd: the file descriptor

-> m () 

Sets the file descriptor for a plane.

Since: 4.14

setFourcc

dmabufTextureBuilderSetFourcc Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> Word32

fourcc: the texture's format or 0 to unset

-> m () 

Sets the format of the texture.

The format is specified as a fourcc code.

The format must be set before calling gLTextureBuilderBuild.

Since: 4.14

setHeight

dmabufTextureBuilderSetHeight Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> Word32

height: the texture's height or 0 to unset

-> m () 

Sets the height of the texture.

The height must be set before calling gLTextureBuilderBuild.

Since: 4.14

setModifier

dmabufTextureBuilderSetModifier Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> Word64

modifier: the modifier value

-> m () 

Sets the modifier.

Since: 4.14

setNPlanes

dmabufTextureBuilderSetNPlanes Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> Word32

nPlanes: the number of planes

-> m () 

Sets the number of planes of the texture.

Since: 4.14

setOffset

dmabufTextureBuilderSetOffset Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> Word32

plane: the plane to set the offset for

-> Word32

offset: the offset value

-> m () 

Sets the offset for a plane.

Since: 4.14

setPremultiplied

dmabufTextureBuilderSetPremultiplied Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> Bool

premultiplied: whether the data is premultiplied

-> m () 

Sets whether the data is premultiplied.

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

Since: 4.14

setStride

dmabufTextureBuilderSetStride Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> Word32

plane: the plane to set the stride for

-> Word32

stride: the stride value

-> m () 

Sets the stride for a plane.

The stride must be set for all planes before calling gLTextureBuilderBuild.

Since: 4.14

setUpdateRegion

dmabufTextureBuilderSetUpdateRegion Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> Maybe Region

region: the region to update

-> m () 

Sets the region to be updated by this texture. Together with DmabufTextureBuilder:updateTexture 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: 4.14

setUpdateTexture

dmabufTextureBuilderSetUpdateTexture Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a, IsTexture b) 
=> a

self: a GdkDmabufTextureBuilder

-> Maybe b

texture: the texture to update

-> m () 

Sets the texture to be updated by this texture. See dmabufTextureBuilderSetUpdateRegion for an explanation.

Since: 4.14

setWidth

dmabufTextureBuilderSetWidth Source #

Arguments

:: (HasCallStack, MonadIO m, IsDmabufTextureBuilder a) 
=> a

self: a GdkDmabufTextureBuilder

-> Word32

width: The texture's width or 0 to unset

-> m () 

Sets the width of the texture.

The width must be set before calling gLTextureBuilderBuild.

Since: 4.14

Properties

display

The display that this texture will be used on.

Since: 4.14

constructDmabufTextureBuilderDisplay :: (IsDmabufTextureBuilder o, MonadIO m, IsDisplay a) => a -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “display” property. This is rarely needed directly, but it is used by new.

getDmabufTextureBuilderDisplay :: (MonadIO m, IsDmabufTextureBuilder o) => o -> m Display Source #

Get the value of the “display” property. When overloading is enabled, this is equivalent to

get dmabufTextureBuilder #display

setDmabufTextureBuilderDisplay :: (MonadIO m, IsDmabufTextureBuilder o, IsDisplay a) => o -> a -> m () Source #

Set the value of the “display” property. When overloading is enabled, this is equivalent to

set dmabufTextureBuilder [ #display := value ]

fourcc

The format of the texture, as a fourcc value.

Since: 4.14

constructDmabufTextureBuilderFourcc :: (IsDmabufTextureBuilder o, MonadIO m) => Word32 -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “fourcc” property. This is rarely needed directly, but it is used by new.

getDmabufTextureBuilderFourcc :: (MonadIO m, IsDmabufTextureBuilder o) => o -> m Word32 Source #

Get the value of the “fourcc” property. When overloading is enabled, this is equivalent to

get dmabufTextureBuilder #fourcc

setDmabufTextureBuilderFourcc :: (MonadIO m, IsDmabufTextureBuilder o) => o -> Word32 -> m () Source #

Set the value of the “fourcc” property. When overloading is enabled, this is equivalent to

set dmabufTextureBuilder [ #fourcc := value ]

height

The height of the texture.

Since: 4.14

constructDmabufTextureBuilderHeight :: (IsDmabufTextureBuilder o, MonadIO m) => Word32 -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “height” property. This is rarely needed directly, but it is used by new.

getDmabufTextureBuilderHeight :: (MonadIO m, IsDmabufTextureBuilder o) => o -> m Word32 Source #

Get the value of the “height” property. When overloading is enabled, this is equivalent to

get dmabufTextureBuilder #height

setDmabufTextureBuilderHeight :: (MonadIO m, IsDmabufTextureBuilder o) => o -> Word32 -> m () Source #

Set the value of the “height” property. When overloading is enabled, this is equivalent to

set dmabufTextureBuilder [ #height := value ]

modifier

The modifier.

Since: 4.14

constructDmabufTextureBuilderModifier :: (IsDmabufTextureBuilder o, MonadIO m) => Word64 -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “modifier” property. This is rarely needed directly, but it is used by new.

getDmabufTextureBuilderModifier :: (MonadIO m, IsDmabufTextureBuilder o) => o -> m Word64 Source #

Get the value of the “modifier” property. When overloading is enabled, this is equivalent to

get dmabufTextureBuilder #modifier

setDmabufTextureBuilderModifier :: (MonadIO m, IsDmabufTextureBuilder o) => o -> Word64 -> m () Source #

Set the value of the “modifier” property. When overloading is enabled, this is equivalent to

set dmabufTextureBuilder [ #modifier := value ]

nPlanes

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

constructDmabufTextureBuilderNPlanes :: (IsDmabufTextureBuilder o, MonadIO m) => Word32 -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “n-planes” property. This is rarely needed directly, but it is used by new.

getDmabufTextureBuilderNPlanes :: (MonadIO m, IsDmabufTextureBuilder o) => o -> m Word32 Source #

Get the value of the “n-planes” property. When overloading is enabled, this is equivalent to

get dmabufTextureBuilder #nPlanes

setDmabufTextureBuilderNPlanes :: (MonadIO m, IsDmabufTextureBuilder o) => o -> Word32 -> m () Source #

Set the value of the “n-planes” property. When overloading is enabled, this is equivalent to

set dmabufTextureBuilder [ #nPlanes := value ]

premultiplied

Whether the alpha channel is premultiplied into the others.

Only relevant if the format has alpha.

Since: 4.14

constructDmabufTextureBuilderPremultiplied :: (IsDmabufTextureBuilder o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “premultiplied” property. This is rarely needed directly, but it is used by new.

getDmabufTextureBuilderPremultiplied :: (MonadIO m, IsDmabufTextureBuilder o) => o -> m Bool Source #

Get the value of the “premultiplied” property. When overloading is enabled, this is equivalent to

get dmabufTextureBuilder #premultiplied

setDmabufTextureBuilderPremultiplied :: (MonadIO m, IsDmabufTextureBuilder o) => o -> Bool -> m () Source #

Set the value of the “premultiplied” property. When overloading is enabled, this is equivalent to

set dmabufTextureBuilder [ #premultiplied := value ]

updateRegion

The update region for GLTextureBuilder:updateTexture.

Since: 4.14

clearDmabufTextureBuilderUpdateRegion :: (MonadIO m, IsDmabufTextureBuilder o) => o -> m () Source #

Set the value of the “update-region” property to Nothing. When overloading is enabled, this is equivalent to

clear #updateRegion

constructDmabufTextureBuilderUpdateRegion :: (IsDmabufTextureBuilder o, MonadIO m) => Region -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “update-region” property. This is rarely needed directly, but it is used by new.

getDmabufTextureBuilderUpdateRegion :: (MonadIO m, IsDmabufTextureBuilder o) => o -> m (Maybe Region) Source #

Get the value of the “update-region” property. When overloading is enabled, this is equivalent to

get dmabufTextureBuilder #updateRegion

setDmabufTextureBuilderUpdateRegion :: (MonadIO m, IsDmabufTextureBuilder o) => o -> Region -> m () Source #

Set the value of the “update-region” property. When overloading is enabled, this is equivalent to

set dmabufTextureBuilder [ #updateRegion := value ]

updateTexture

The texture DmabufTextureBuilder:updateRegion is an update for.

Since: 4.14

clearDmabufTextureBuilderUpdateTexture :: (MonadIO m, IsDmabufTextureBuilder o) => o -> m () Source #

Set the value of the “update-texture” property to Nothing. When overloading is enabled, this is equivalent to

clear #updateTexture

constructDmabufTextureBuilderUpdateTexture :: (IsDmabufTextureBuilder o, MonadIO m, IsTexture a) => a -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “update-texture” property. This is rarely needed directly, but it is used by new.

getDmabufTextureBuilderUpdateTexture :: (MonadIO m, IsDmabufTextureBuilder o) => o -> m (Maybe Texture) Source #

Get the value of the “update-texture” property. When overloading is enabled, this is equivalent to

get dmabufTextureBuilder #updateTexture

setDmabufTextureBuilderUpdateTexture :: (MonadIO m, IsDmabufTextureBuilder o, IsTexture a) => o -> a -> m () Source #

Set the value of the “update-texture” property. When overloading is enabled, this is equivalent to

set dmabufTextureBuilder [ #updateTexture := value ]

width

The width of the texture.

Since: 4.14

constructDmabufTextureBuilderWidth :: (IsDmabufTextureBuilder o, MonadIO m) => Word32 -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “width” property. This is rarely needed directly, but it is used by new.

getDmabufTextureBuilderWidth :: (MonadIO m, IsDmabufTextureBuilder o) => o -> m Word32 Source #

Get the value of the “width” property. When overloading is enabled, this is equivalent to

get dmabufTextureBuilder #width

setDmabufTextureBuilderWidth :: (MonadIO m, IsDmabufTextureBuilder o) => o -> Word32 -> m () Source #

Set the value of the “width” property. When overloading is enabled, this is equivalent to

set dmabufTextureBuilder [ #width := value ]