gtkmm
3.93.0
|
Pixel data. More...
#include <gdkmm/texture.h>
Public Types | |
using | SlotGLReleased = sigc::slot< void()> |
For instance, void on_gl_resources_released();. More... | |
![]() | |
typedef void(*)(gpointer data | DestroyNotify) |
![]() | |
typedef internal::func_destroy_notify | func_destroy_notify |
Public Member Functions | |
Texture (Texture&& src) noexcept | |
Texture& | operator= (Texture&& src) noexcept |
~Texture () noexcept override | |
GdkTexture* | gobj () |
Provides access to the underlying C GObject. More... | |
const GdkTexture* | gobj () const |
Provides access to the underlying C GObject. More... | |
GdkTexture* | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More... | |
void | release_gl () |
Releases the GL resources held by a Gdk::Texture that was created with new_for_gl(). More... | |
int | get_width () const |
Returns the width of texture. More... | |
int | get_height () const |
Returns the height of the texture. More... | |
void | download (guchar* data, gsize stride) const |
Downloads the texture into local memory. More... | |
Glib::PropertyProxy_ReadOnly< int > | property_width () const |
The width of the texture. More... | |
Glib::PropertyProxy_ReadOnly< int > | property_height () const |
The height of the texture. More... | |
![]() | |
Object (const Object &)=delete | |
Object & | operator= (const Object &)=delete |
Object (Object &&src) noexcept | |
Object & | operator= (Object &&src) noexcept |
void * | get_data (const QueryQuark &key) |
void | set_data (const Quark &key, void *data) |
void | set_data (const Quark &key, void *data, DestroyNotify notify) |
void | remove_data (const QueryQuark &quark) |
void * | steal_data (const QueryQuark &quark) |
Glib::RefPtr< Glib::Object > | wrap (GObject *object, bool take_copy=false) |
![]() | |
ObjectBase (const ObjectBase &)=delete | |
ObjectBase & | operator= (const ObjectBase &)=delete |
void | set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value) |
void | get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const |
void | set_property (const Glib::ustring &property_name, const PropertyType &value) |
void | get_property (const Glib::ustring &property_name, PropertyType &value) const |
PropertyType | get_property (const Glib::ustring &property_name) const |
sigc::connection | connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void()> &slot) |
sigc::connection | connect_property_changed (const Glib::ustring &property_name, sigc::slot< void()> &&slot) |
void | freeze_notify () |
void | thaw_notify () |
virtual void | reference () const |
virtual void | unreference () const |
GObject * | gobj () |
const GObject * | gobj () const |
GObject * | gobj_copy () const |
![]() | |
trackable () noexcept | |
trackable (const trackable &src) noexcept | |
trackable (trackable &&src) | |
~trackable () | |
void | add_destroy_notify_callback (void *data, func_destroy_notify func) const |
void | notify_callbacks () |
trackable & | operator= (const trackable &src) |
trackable & | operator= (trackable &&src) |
void | remove_destroy_notify_callback (void *data) const |
Static Public Member Functions | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. More... | |
static Glib::RefPtr< Texture > | create_for_data (const guchar* data, int width, int height, int stride) |
Creates a new texture object holding the given data. More... | |
static Glib::RefPtr< Texture > | create_for_pixbuf (const Glib::RefPtr< Pixbuf >& pixbuf) |
Creates a new texture object representing the GdkPixbuf. More... | |
static Glib::RefPtr< Texture > | create_from_resource (const std::string& resource_path) |
Creates a new texture by loading an image from a resource. More... | |
static Glib::RefPtr< Texture > | create_from_file (const Glib::RefPtr< Gio::File >& file) |
Creates a new texture by loading an image from a file. More... | |
static Glib::RefPtr< Texture > | create_for_gl (const Glib::RefPtr< GLContext >& context, guint id, int width, int height, const SlotGLReleased& slot={}) |
Creates a new texture for an existing GL texture. More... | |
Protected Member Functions | |
Texture () | |
![]() | |
Object () | |
Object (const Glib::ConstructParams &construct_params) | |
Object (GObject *castitem) | |
~Object () noexcept override | |
![]() | |
ObjectBase () | |
ObjectBase (const char *custom_type_name) | |
ObjectBase (const std::type_info &custom_type_info) | |
ObjectBase (ObjectBase &&src) noexcept | |
ObjectBase & | operator= (ObjectBase &&src) noexcept |
virtual | ~ObjectBase () noexcept=0 |
void | initialize (GObject *castitem) |
void | initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper) |
Related Functions | |
(Note that these are not member functions.) | |
Glib::RefPtr< Gdk::Texture > | wrap (GdkTexture* object, bool take_copy=false) |
A Glib::wrap() method for this object. More... | |
Pixel data.
Gdk::Texture is the basic element used to refer to pixel data. It is primarily meant for pixel data that will not change over multiple frames, and will be used for a long time.
You cannot get your pixel data back once you've uploaded it.
Gdk::Texture is an immutable object: That means you cannot change anything about it.
using Gdk::Texture::SlotGLReleased = sigc::slot<void()> |
For instance, void on_gl_resources_released();.
|
noexcept |
|
overridenoexcept |
|
protected |
|
static |
Creates a new texture object holding the given data.
The data is assumed to be in CAIRO_FORMAT_ARGB32 format.
data | The pixel data. |
width | The number of pixels in each row. |
height | The number of rows. |
stride | The distance from the beginning of one row to the next, in bytes. |
|
static |
Creates a new texture for an existing GL texture.
Note that the GL texture must not be modified until slot is called, which will happen when the GdkTexture object is finalized, or due to an explicit call of release_gl().
context | A Gdk::GLContext. |
id | The ID of a texture that was created with context. |
width | The nominal width of the texture. |
height | The nominal height of the texture. |
slot | A destroy notify that will be called when the GL resources are released. |
|
static |
Creates a new texture object representing the GdkPixbuf.
pixbuf | A Gdk::Pixbuf. |
|
static |
Creates a new texture by loading an image from a file.
The file format is detected automatically. If nullptr
is returned, then error will be set.
file | File to load. |
nullptr
if an error occured.Glib::Error |
|
static |
Creates a new texture by loading an image from a resource.
The file format is detected automatically.
It is a fatal error if resource_path does not specify a valid image resource and the program will abort if that happens. If you are unsure about the validity of a resource, use new_from_file() to load it.
resource_path | The path of the resource file. |
void Gdk::Texture::download | ( | guchar * | data, |
gsize | stride | ||
) | const |
Downloads the texture into local memory.
This may be an expensive operation, as the actual texture data may reside on a GPU or on a remote display server.
The data format of the downloaded data is equivalent to Cairo::Surface::Format::ARGB32, so every downloaded pixel requires 4 bytes of memory.
Downloading a texture into a Cairo image surface:
[C example ellipted]
data | Pointer to enough memory to be filled with the downloaded data of texture. |
stride | Rowstride in bytes. |
int Gdk::Texture::get_height | ( | ) | const |
Returns the height of the texture.
|
static |
Get the GType for this class, for use with the underlying GObject type system.
int Gdk::Texture::get_width | ( | ) | const |
Returns the width of texture.
|
inline |
Provides access to the underlying C GObject.
|
inline |
Provides access to the underlying C GObject.
GdkTexture* Gdk::Texture::gobj_copy | ( | ) |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
Glib::PropertyProxy_ReadOnly< int > Gdk::Texture::property_height | ( | ) | const |
The height of the texture.
Default value: 1
Glib::PropertyProxy_ReadOnly< int > Gdk::Texture::property_width | ( | ) | const |
The width of the texture.
Default value: 1
void Gdk::Texture::release_gl | ( | ) |
Releases the GL resources held by a Gdk::Texture that was created with new_for_gl().
The texture contents are still available via the download() function, after this function has been called.
|
related |
A Glib::wrap() method for this object.
object | The C instance. |
take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref. |