[gtkmm] Gdk::Texture: Add create_for_gl() and release_gl()
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Gdk::Texture: Add create_for_gl() and release_gl()
- Date: Wed, 7 Feb 2018 18:08:48 +0000 (UTC)
commit cf84c3a55153fb51853306a18174c5b2ad5d4de1
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Wed Feb 7 19:01:31 2018 +0100
Gdk::Texture: Add create_for_gl() and release_gl()
gdk/src/texture.ccg | 19 +++++++++++++++++++
gdk/src/texture.hg | 12 ++++++++++++
2 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/gdk/src/texture.ccg b/gdk/src/texture.ccg
index 96109a8..e5ba9de 100644
--- a/gdk/src/texture.ccg
+++ b/gdk/src/texture.ccg
@@ -15,4 +15,23 @@
*/
#include <giomm/file.h>
+#include <gdkmm/glcontext.h>
#include <gdkmm/pixbuf.h>
+
+namespace
+{
+void Texture_GL_destroy_callback(void* data)
+{
+ auto the_slot = static_cast<Gdk::Texture::SlotGLReleased*>(data);
+ try
+ {
+ (*the_slot)();
+ }
+ catch (...)
+ {
+ Glib::exception_handlers_invoke();
+ }
+ delete the_slot;
+}
+
+} // anonymous namespace
diff --git a/gdk/src/texture.hg b/gdk/src/texture.hg
index 8451162..117d290 100644
--- a/gdk/src/texture.hg
+++ b/gdk/src/texture.hg
@@ -26,6 +26,7 @@ class File;
namespace Gdk
{
+class GLContext;
class Pixbuf;
/** Pixel data.
@@ -59,6 +60,17 @@ public:
_WRAP_METHOD(static Glib::RefPtr<Texture> create_from_file(
const Glib::RefPtr<Gio::File>& file), gdk_texture_new_from_file, errthrow)
+ /** For instance,
+ * void on_gl_resources_released();
+ */
+ using SlotGLReleased = sigc::slot<void()>;
+
+ _WRAP_METHOD(static Glib::RefPtr<Texture> create_for_gl(
+ const Glib::RefPtr<GLContext>& context,
+ guint id, int width, int height, const SlotGLReleased& slot{destroy} = {}),
+ gdk_texture_new_for_gl, slot_name slot, slot_callback Texture_GL_destroy_callback)
+ _WRAP_METHOD(void release_gl(), gdk_texture_release_gl)
+
_WRAP_METHOD(int get_width() const, gdk_texture_get_width)
_WRAP_METHOD(int get_height() const, gdk_texture_get_height)
_WRAP_METHOD(void download(guchar* data, gsize stride) const, gdk_texture_download)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]