[gtk/wip/otte/glcontext: 2/2] glcontext: Add gdk_gl_context_get_api()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/glcontext: 2/2] glcontext: Add gdk_gl_context_get_api()
- Date: Thu, 7 Oct 2021 23:27:24 +0000 (UTC)
commit 352779823e4b9b21b1e98f66d180f7325ac1becd
Author: Benjamin Otte <otte redhat com>
Date: Thu Oct 7 23:03:45 2021 +0200
glcontext: Add gdk_gl_context_get_api()
This is mostly for inspector.
Not sure if we also want to deprecate gdk_gl_context_get_use_es() in
favor of this function.
gdk/gdkglcontext.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
gdk/gdkglcontext.h | 2 ++
2 files changed, 49 insertions(+)
---
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
index 965e03f4d2..3989574d0a 100644
--- a/gdk/gdkglcontext.c
+++ b/gdk/gdkglcontext.c
@@ -124,6 +124,7 @@ enum {
PROP_0,
PROP_ALLOWED_APIS,
+ PROP_API,
PROP_SHARED_CONTEXT,
LAST_PROP
@@ -235,6 +236,10 @@ gdk_gl_context_get_property (GObject *object,
g_value_set_flags (value, priv->allowed_apis);
break;
+ case PROP_API:
+ g_value_set_flags (value, priv->api);
+ break;
+
case PROP_SHARED_CONTEXT:
g_value_set_object (value, NULL);
break;
@@ -761,6 +766,23 @@ gdk_gl_context_class_init (GdkGLContextClass *klass)
G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY);
+ /**
+ * GdkGLContext:api: (attributes org.gtk.Property.get=gdk_gl_context_get_api)
+ *
+ * The API currently in use.
+ *
+ * Since: 4.6
+ */
+ properties[PROP_API] =
+ g_param_spec_flags ("api",
+ P_("API"),
+ P_("The API currently in use"),
+ GDK_TYPE_GL_API,
+ 0,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS |
+ G_PARAM_EXPLICIT_NOTIFY);
+
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;
@@ -1234,6 +1256,28 @@ gdk_gl_context_get_allowed_apis (GdkGLContext *self)
return priv->allowed_apis;
}
+/**
+ * gdk_gl_context_get_api: (attributes org.gtk.Method.get_property=api)
+ * @self: a GL context
+ *
+ * Gets the API currently in use.
+ *
+ * If the renderer has not been realized yet, 0 is returned.
+ *
+ * Returns: the currently used API
+ *
+ * Since: 4.6
+ **/
+GdkGLAPI
+gdk_gl_context_get_api (GdkGLContext *self)
+{
+ GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (self);
+
+ g_return_val_if_fail (GDK_IS_GL_CONTEXT (self), 0);
+
+ return priv->api;
+}
+
gboolean
gdk_gl_context_is_api_allowed (GdkGLContext *self,
GdkGLAPI api,
@@ -1437,6 +1481,9 @@ gdk_gl_context_realize (GdkGLContext *context,
priv->api = GDK_GL_CONTEXT_GET_CLASS (context)->realize (context, error);
+ if (priv->api)
+ g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_API]);
+
return priv->api;
}
diff --git a/gdk/gdkglcontext.h b/gdk/gdkglcontext.h
index 7e8e0d1e36..5201f93cb1 100644
--- a/gdk/gdkglcontext.h
+++ b/gdk/gdkglcontext.h
@@ -95,6 +95,8 @@ void gdk_gl_context_set_allowed_apis (GdkGLContext *
GdkGLAPI apis);
GDK_AVAILABLE_IN_4_6
GdkGLAPI gdk_gl_context_get_allowed_apis (GdkGLContext *self);
+GDK_AVAILABLE_IN_4_6
+GdkGLAPI gdk_gl_context_get_api (GdkGLContext *self);
GDK_DEPRECATED_IN_4_6_FOR(gdk_gl_context_set_allowed_apis)
void gdk_gl_context_set_use_es (GdkGLContext *context,
int use_es);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]