[gtk+/wip/gl-texture] Add a destroy notify to gl textures
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/gl-texture] Add a destroy notify to gl textures
- Date: Wed, 17 Jan 2018 15:19:38 +0000 (UTC)
commit 9d9d69287ffd34fe39a406b6f8272722cb414f9c
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Jan 17 10:17:20 2018 -0500
Add a destroy notify to gl textures
This will be used to make sure we don't modify
the GL texture while it is still in use.
For now, just pass NULL as destroy notify.
gdk/gdktexture.c | 24 +++++++++++++++++-------
gdk/gdktexture.h | 5 ++++-
gtk/gtkglarea.c | 5 +++--
3 files changed, 24 insertions(+), 10 deletions(-)
---
diff --git a/gdk/gdktexture.c b/gdk/gdktexture.c
index 5b04247..c87ed57 100644
--- a/gdk/gdktexture.c
+++ b/gdk/gdktexture.c
@@ -442,6 +442,9 @@ struct _GdkGLTexture {
GdkGLContext *context;
int id;
+
+ GDestroyNotify destroy;
+ gpointer data;
};
struct _GdkGLTextureClass {
@@ -451,13 +454,16 @@ struct _GdkGLTextureClass {
G_DEFINE_TYPE (GdkGLTexture, gdk_gl_texture, GDK_TYPE_TEXTURE)
static void
-gdk_gl_texture_finalize (GObject *object)
+gdk_gl_texture_dispose (GObject *object)
{
GdkGLTexture *self = GDK_GL_TEXTURE (object);
g_object_unref (self->context);
- G_OBJECT_CLASS (gdk_gl_texture_parent_class)->finalize (object);
+ if (self->destroy)
+ self->destroy (self->data);
+
+ G_OBJECT_CLASS (gdk_gl_texture_parent_class)->dispose (object);
}
static void
@@ -490,7 +496,7 @@ gdk_gl_texture_class_init (GdkGLTextureClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
texture_class->download = gdk_gl_texture_download;
- gobject_class->finalize = gdk_gl_texture_finalize;
+ gobject_class->dispose = gdk_gl_texture_dispose;
}
static void
@@ -611,10 +617,12 @@ gdk_texture_new_from_file (GFile *file,
}
GdkTexture *
-gdk_texture_new_for_gl (GdkGLContext *context,
- int id,
- int width,
- int height)
+gdk_texture_new_for_gl (GdkGLContext *context,
+ int id,
+ int width,
+ int height,
+ GDestroyNotify destroy,
+ gpointer data)
{
GdkGLTexture *self;
@@ -627,6 +635,8 @@ gdk_texture_new_for_gl (GdkGLContext *context,
self->context = g_object_ref (context);
self->id = id;
+ self->destroy = destroy;
+ self->data = data;
return GDK_TEXTURE (self);
}
diff --git a/gdk/gdktexture.h b/gdk/gdktexture.h
index b95a7fe..4f3ead2 100644
--- a/gdk/gdktexture.h
+++ b/gdk/gdktexture.h
@@ -55,11 +55,14 @@ GdkTexture * gdk_texture_new_from_resource (const char
GDK_AVAILABLE_IN_3_94
GdkTexture * gdk_texture_new_from_file (GFile *file,
GError **error);
+
GDK_AVAILABLE_IN_3_94
GdkTexture * gdk_texture_new_for_gl (GdkGLContext *context,
int id,
int width,
- int height);
+ int height,
+ GDestroyNotify destroy,
+ gpointer data);
GDK_AVAILABLE_IN_3_94
int gdk_texture_get_width (GdkTexture *texture);
diff --git a/gtk/gtkglarea.c b/gtk/gtkglarea.c
index d086afb..3bb8137 100644
--- a/gtk/gtkglarea.c
+++ b/gtk/gtkglarea.c
@@ -490,7 +490,7 @@ gtk_gl_area_delete_buffers (GtkGLArea *area)
if (priv->texture != 0)
{
- glDeleteTextures(1, &priv->texture);
+ glDeleteTextures (1, &priv->texture);
priv->texture = 0;
}
@@ -628,7 +628,8 @@ gtk_gl_area_snapshot (GtkWidget *widget,
texture = gdk_texture_new_for_gl (priv->context,
priv->texture,
gtk_widget_get_width (widget),
- gtk_widget_get_height (widget));
+ gtk_widget_get_height (widget),
+ NULL, NULL);
gtk_snapshot_append_texture (snapshot,
texture,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]