class Gdk::MemoryTextureBuilder

Overview

Constructs Gdk::Texture objects from system memory provided via GLib::Bytes.

The operation is quite simple: Create a texture builder, set all the necessary properties - keep in mind that the properties Gdk::MemoryTextureBuilder#bytes, Gdk::MemoryTextureBuilder#stride, Gdk::MemoryTextureBuilder#width, and Gdk::MemoryTextureBuilder#height are mandatory - and then call Gdk::MemoryTextureBuilder#build to create the new texture.

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

Defined in:

lib/gi-crystal/src/auto/gdk-4.0/memory_texture_builder.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class GObject::Object

==(other : self) ==, bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void) | Nil data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, hash(hasher) hash, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void) | Nil qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void) | Nil) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void) | Nil steal_data, steal_qdata(quark : UInt32) : Pointer(Void) | Nil steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

cast?(obj : GObject::Object) : self | Nil cast?, compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Macros inherited from class GObject::Object

previous_vfunc(*args) previous_vfunc, previous_vfunc!(*args) previous_vfunc!, signal(signature) signal

Constructor Detail

def self.new : self #

Creates a new texture builder.


def self.new(*, bytes : GLib::Bytes | Nil = nil, color_state : Gdk::ColorState | Nil = nil, format : Gdk::MemoryFormat | Nil = nil, height : Int32 | Nil = nil, stride : UInt64 | Nil = nil, update_region : Cairo::Region | Nil = nil, update_texture : Gdk::Texture | Nil = nil, width : Int32 | Nil = nil) #

Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def build : Gdk::Texture #

Builds a new Gdk::Texture with the values set up in the builder.

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.


def bytes : GLib::Bytes | Nil #

Gets the bytes previously set via gdk_memory_texture_builder_set_bytes() or nil if none was set.


def bytes=(bytes : GLib::Bytes | Nil) : Nil #

Sets the data to be shown but the texture.

The bytes must be set before calling Gdk::MemoryTextureBuilder#build.


def color_state : Gdk::ColorState #

Gets the colorstate previously set via gdk_memory_texture_builder_set_color_state().


def color_state=(color_state : Gdk::ColorState | Nil) : Nil #

Sets the colorstate describing the data.

By default, the sRGB colorstate is used. If you don't know what colorstates are, this is probably the right thing.


def format : Gdk::MemoryFormat #

Gets the format previously set via gdk_memory_texture_builder_set_format().


def format=(format : Gdk::MemoryFormat) : Nil #

Sets the format of the bytes.

The default is GDK_MEMORY_R8G8B8A8_PREMULTIPLIED.


def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def height : Int32 #

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


def height=(height : Int32) : Nil #

Sets the height of the texture.

The height must be set before calling Gdk::MemoryTextureBuilder#build.


def stride : UInt64 #

Gets the stride previously set via gdk_memory_texture_builder_set_stride().


def stride=(stride : UInt64) : Nil #

Sets the rowstride of the bytes used.

The rowstride must be set before calling Gdk::MemoryTextureBuilder#build.


def update_region : Cairo::Region | Nil #

Gets the region previously set via gdk_memory_texture_builder_set_update_region() or nil if none was set.


def update_region=(region : Cairo::Region | Nil) : Nil #

Sets the region to be updated by this texture.

Together with [property@Gdk.MemoryTextureBuilder: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.


def update_texture : Gdk::Texture | Nil #

Gets the texture previously set via gdk_memory_texture_builder_set_update_texture() or nil if none was set.


def update_texture=(texture : Gdk::Texture | Nil) : Nil #

Sets the texture to be updated by this texture.

See Gdk::MemoryTextureBuilder#update_region= for an explanation.


def width : Int32 #

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


def width=(width : Int32) : Nil #

Sets the width of the texture.

The width must be set before calling Gdk::MemoryTextureBuilder#build.