Gdk.GLTextureBuilder

g GObject.Object GObject.Object Gdk.GLTextureBuilder Gdk.GLTextureBuilder GObject.Object->Gdk.GLTextureBuilder

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

build (destroy, data)

get_context ()

get_format ()

get_has_mipmap ()

get_height ()

get_id ()

get_sync ()

get_update_region ()

get_update_texture ()

get_width ()

set_context (context)

set_format (format)

set_has_mipmap (has_mipmap)

set_height (height)

set_id (id)

set_sync (sync)

set_update_region (region)

set_update_texture (texture)

set_width (width)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

context

Gdk.GLContext

r/w/en

format

Gdk.MemoryFormat

r/w/en

has-mipmap

bool

r/w/en

height

int

r/w/en

id

int

r/w/en

sync

int

r/w/en

update-region

cairo.Region

r/w/en

update-texture

Gdk.Texture

r/w/en

width

int

r/w/en

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Gdk.GLTextureBuilder(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Gdk.GLTextureBuilderClass

GdkGLTextureBuilder is a buider used to construct [class`Gdk`.Texture] objects from GL textures.

The operation is quite simple: Create a texture builder, set all the necessary properties - keep in mind that the properties [property`Gdk`.GLTextureBuilder:context], [property`Gdk`.GLTextureBuilder:id], [property`Gdk`.GLTextureBuilder:width], and [property`Gdk`.GLTextureBuilder:height] are mandatory - and then call [method`Gdk`.GLTextureBuilder.build] to create the new texture.

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

New in version 4.12.

classmethod new()[source]
Returns:

the new GdkTextureBuilder

Return type:

Gdk.GLTextureBuilder

Creates a new texture builder.

New in version 4.12.

build(destroy, data)[source]
Parameters:
  • destroy (GLib.DestroyNotify or None) – destroy function to be called when the texture is released

  • data (object or None) – user data to pass to the destroy function

Returns:

a newly built GdkTexture

Return type:

Gdk.Texture

Builds a new GdkTexture with the values set up in the builder.

The destroy function gets called when the returned texture gets released; either when the texture is finalized or by an explicit call to [method`Gdk`.GLTexture.release]. It should release all GL resources associated with the texture, such as the [property`Gdk`.GLTextureBuilder:id] and the [property`Gdk`.GLTextureBuilder:sync].

Note that it is a programming error to call this function if any mandatory property has not been set.

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

New in version 4.12.

get_context()[source]
Returns:

The context

Return type:

Gdk.GLContext or None

Gets the context previously set via Gdk.GLTextureBuilder.set_context() or None if none was set.

New in version 4.12.

get_format()[source]
Returns:

The format

Return type:

Gdk.MemoryFormat

Gets the format previously set via Gdk.GLTextureBuilder.set_format().

New in version 4.12.

get_has_mipmap()[source]
Returns:

Whether the texture has a mipmap

Return type:

bool

Gets whether the texture has a mipmap.

New in version 4.12.

get_height()[source]
Returns:

The height

Return type:

int

Gets the height previously set via Gdk.GLTextureBuilder.set_height() or 0 if the height wasn’t set.

New in version 4.12.

get_id()[source]
Returns:

The id

Return type:

int

Gets the texture id previously set via Gdk.GLTextureBuilder.set_id() or 0 if the id wasn’t set.

New in version 4.12.

get_sync()[source]
Returns:

the GLSync

Return type:

object or None

Gets the GLsync previously set via Gdk.GLTextureBuilder.set_sync().

New in version 4.12.

get_update_region()[source]
Returns:

The region

Return type:

cairo.Region or None

Gets the region previously set via Gdk.GLTextureBuilder.set_update_region() or None if none was set.

New in version 4.12.

get_update_texture()[source]
Returns:

The texture

Return type:

Gdk.Texture or None

Gets the texture previously set via Gdk.GLTextureBuilder.set_update_texture() or None if none was set.

New in version 4.12.

get_width()[source]
Returns:

The width

Return type:

int

Gets the width previously set via Gdk.GLTextureBuilder.set_width() or 0 if the width wasn’t set.

New in version 4.12.

set_context(context)[source]
Parameters:

context (Gdk.GLContext or None) – The context the texture beongs to or None to unset

Sets the context to be used for the texture. This is the context that owns the texture.

The context must be set before calling [method`Gdk`.GLTextureBuilder.build].

New in version 4.12.

set_format(format)[source]
Parameters:

format (Gdk.MemoryFormat) – The texture’s format

Sets the format of the texture. The default is GDK_MEMORY_R8G8B8A8_PREMULTIPLIED.

The format is the preferred format the texture data should be downloaded to. The format must be supported by the GL version of [property`Gdk`.GLTextureBuilder:context].

GDK’s texture download code assumes that the format corresponds to the storage parameters of the GL texture in an obvious way. For example, a format of GDK_MEMORY_R16G16B16A16_PREMULTIPLIED is expected to be stored as GL_RGBA16 texture, and GDK_MEMORY_G8A8 is expected to be stored as GL_RG8 texture.

Setting the right format is particularly useful when using high bit depth textures to preserve the bit depth, to set the correct value for unpremultiplied textures and to make sure opaque textures are treated as such.

Non-RGBA textures need to have swizzling parameters set up properly to be usable in GSK’s shaders.

New in version 4.12.

set_has_mipmap(has_mipmap)[source]
Parameters:

has_mipmap (bool) – Whether the texture has a mipmap

Sets whether the texture has a mipmap. This allows the renderer and other users of the generated texture to use a higher quality downscaling.

Typically, the glGenerateMipmap function is used to generate a mimap.

New in version 4.12.

set_height(height)[source]
Parameters:

height (int) – The texture’s height or 0 to unset

Sets the height of the texture.

The height must be set before calling [method`Gdk`.GLTextureBuilder.build].

New in version 4.12.

set_id(id)[source]
Parameters:

id (int) – The texture id to be used for creating the texture

Sets the texture id of the texture. The texture id must remain unmodified until the texture was finalized. See [method`Gdk`.GLTextureBuilder.build] for a longer discussion.

The id must be set before calling [method`Gdk`.GLTextureBuilder.build].

New in version 4.12.

set_sync(sync)[source]
Parameters:

sync (object or None) – the GLSync object

Sets the GLSync object to use for the texture.

GTK will wait on this object before using the created GdkTexture.

The destroy function that is passed to [method`Gdk`.GLTextureBuilder.build] is responsible for freeing the sync object when it is no longer needed. The texture builder does not destroy it and it is the callers responsibility to make sure it doesn’t leak.

New in version 4.12.

set_update_region(region)[source]
Parameters:

region (cairo.Region or None) – the region to update

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

New in version 4.12.

set_update_texture(texture)[source]
Parameters:

texture (Gdk.Texture or None) – the texture to update

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

New in version 4.12.

set_width(width)[source]
Parameters:

width (int) – The texture’s width or 0 to unset

Sets the width of the texture.

The width must be set before calling [method`Gdk`.GLTextureBuilder.build].

New in version 4.12.

Property Details

Gdk.GLTextureBuilder.props.context
Name:

context

Type:

Gdk.GLContext

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The context owning the texture.

New in version 4.12.

Gdk.GLTextureBuilder.props.format
Name:

format

Type:

Gdk.MemoryFormat

Default Value:

Gdk.MemoryFormat.R8G8B8A8_PREMULTIPLIED

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The format when downloading the texture.

New in version 4.12.

Gdk.GLTextureBuilder.props.has_mipmap
Name:

has-mipmap

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

If the texture has a mipmap.

New in version 4.12.

Gdk.GLTextureBuilder.props.height
Name:

height

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The height of the texture.

New in version 4.12.

Gdk.GLTextureBuilder.props.id
Name:

id

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The texture ID to use.

New in version 4.12.

Gdk.GLTextureBuilder.props.sync
Name:

sync

Type:

int

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

An optional GLSync object.

If this is set, GTK will wait on it before using the texture.

New in version 4.12.

Gdk.GLTextureBuilder.props.update_region
Name:

update-region

Type:

cairo.Region

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The update region for [property`Gdk`.GLTextureBuilder:update-texture].

New in version 4.12.

Gdk.GLTextureBuilder.props.update_texture
Name:

update-texture

Type:

Gdk.Texture

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The texture [property`Gdk`.GLTextureBuilder:update-region] is an update for.

New in version 4.12.

Gdk.GLTextureBuilder.props.width
Name:

width

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The width of the texture.

New in version 4.12.