[gtk+] GdkGLContext: Track shared context
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GdkGLContext: Track shared context
- Date: Thu, 30 Oct 2014 11:43:25 +0000 (UTC)
commit dbbab0791d7bd08dcd44cd2d34071748786f8b12
Author: Alexander Larsson <alexl redhat com>
Date: Thu Oct 30 12:04:23 2014 +0100
GdkGLContext: Track shared context
This allows us to read it back, but primarily it ensures
the shared context wrapper stays alive as long as the context.
gdk/gdkglcontext.c | 52 ++++++++++++++++++++++++++++++++++++
gdk/wayland/gdkglcontext-wayland.c | 1 +
gdk/x11/gdkglcontext-x11.c | 1 +
3 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
index 748d932..b15b76e 100644
--- a/gdk/gdkglcontext.c
+++ b/gdk/gdkglcontext.c
@@ -82,6 +82,7 @@
typedef struct {
GdkWindow *window;
GdkVisual *visual;
+ GdkGLContext *shared_context;
guint realized : 1;
guint use_texture_rectangle : 1;
@@ -93,6 +94,7 @@ enum {
PROP_WINDOW,
PROP_VISUAL,
+ PROP_SHARED_CONTEXT,
LAST_PROP
};
@@ -118,6 +120,7 @@ gdk_gl_context_dispose (GObject *gobject)
g_clear_object (&priv->window);
g_clear_object (&priv->visual);
+ g_clear_object (&priv->shared_context);
G_OBJECT_CLASS (gdk_gl_context_parent_class)->dispose (gobject);
}
@@ -155,6 +158,15 @@ gdk_gl_context_set_property (GObject *gobject,
}
break;
+ case PROP_SHARED_CONTEXT:
+ {
+ GdkGLContext *context = g_value_get_object (value);
+
+ if (context != NULL)
+ priv->shared_context = g_object_ref (context);
+ }
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
}
@@ -178,6 +190,10 @@ gdk_gl_context_get_property (GObject *gobject,
g_value_set_object (value, priv->visual);
break;
+ case PROP_SHARED_CONTEXT:
+ g_value_set_object (value, priv->shared_context);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
}
@@ -220,6 +236,22 @@ gdk_gl_context_class_init (GdkGLContextClass *klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
+ /**
+ * GdkGLContext:shared-context:
+ *
+ * The #GdkGLContext that this context is sharing data with, or #NULL
+ *
+ * Since: 3.16
+ */
+ obj_pspecs[PROP_SHARED_CONTEXT] =
+ g_param_spec_object ("shared-context",
+ P_("Shared context"),
+ P_("The GL context this context share data with"),
+ GDK_TYPE_GL_CONTEXT,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
gobject_class->set_property = gdk_gl_context_set_property;
gobject_class->get_property = gdk_gl_context_get_property;
gobject_class->dispose = gdk_gl_context_dispose;
@@ -352,6 +384,26 @@ gdk_gl_context_get_window (GdkGLContext *context)
}
/**
+ * gdk_gl_context_get_shared_context:
+ * @context: a #GdkGLContext
+ *
+ * Retrieves the #GdkGLContext that this @context share data with.
+ *
+ * Returns: (transfer none): a #GdkGLContext or %NULL
+ *
+ * Since: 3.16
+ */
+GdkGLContext *
+gdk_gl_context_get_shared_context (GdkGLContext *context)
+{
+ GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
+
+ g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), NULL);
+
+ return priv->shared_context;
+}
+
+/**
* gdk_gl_context_clear_current:
*
* Clears the current #GdkGLContext.
diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c
index 5a75c54..ee8782d 100644
--- a/gdk/wayland/gdkglcontext-wayland.c
+++ b/gdk/wayland/gdkglcontext-wayland.c
@@ -364,6 +364,7 @@ gdk_wayland_window_create_gl_context (GdkWindow *window,
context = g_object_new (GDK_TYPE_WAYLAND_GL_CONTEXT,
"window", window,
"visual", gdk_window_get_visual (window),
+ "shared-context", share,
NULL);
context->egl_config = config;
diff --git a/gdk/x11/gdkglcontext-x11.c b/gdk/x11/gdkglcontext-x11.c
index b7a90eb..071f8a1 100644
--- a/gdk/x11/gdkglcontext-x11.c
+++ b/gdk/x11/gdkglcontext-x11.c
@@ -1124,6 +1124,7 @@ gdk_x11_window_create_gl_context (GdkWindow *window,
context = g_object_new (GDK_TYPE_X11_GL_CONTEXT,
"window", window,
"visual", gdk_visual,
+ "shared-context", share,
NULL);
context->profile = profile;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]