gl/context: add generic feature checking
authorMatthew Waters <ystreet00@gmail.com>
Wed, 14 May 2014 07:33:21 +0000 (17:33 +1000)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 9 Dec 2017 19:31:40 +0000 (19:31 +0000)
At the moment it simply delegates to the subclass.

gst-libs/gst/gl/gstglcontext.c
gst-libs/gst/gl/gstglcontext.h

index ea57601..a2f1909 100644 (file)
@@ -1032,6 +1032,31 @@ gst_gl_context_get_gl_version (GstGLContext * context, gint * maj, gint * min)
     *min = context->priv->gl_minor;
 }
 
+/**
+ * gst_gl_context_check_feature:
+ * @context: a #GstGLContext
+ * @feature: a platform specific feature
+ *
+ * Some features require that the context be created before it is possible to
+ * determine their existence and so will fail if that is not the case.
+ *
+ * Returns: Whether @feature is supported by @context
+ */
+gboolean
+gst_gl_context_check_feature (GstGLContext * context, const gchar * feature)
+{
+  GstGLContextClass *context_class;
+
+  g_return_val_if_fail (GST_GL_IS_CONTEXT (context), FALSE);
+  g_return_val_if_fail (feature != NULL, FALSE);
+
+  context_class = GST_GL_CONTEXT_GET_CLASS (context);
+  if (!context_class->check_feature)
+    return FALSE;
+
+  return context_class->check_feature (context, feature);
+}
+
 static GstGLAPI
 gst_gl_wrapped_context_get_gl_api (GstGLContext * context)
 {
index edf347f..269a51d 100644 (file)
@@ -103,6 +103,7 @@ struct _GstGLContextClass {
                                        GstGLContext *other_context, GError ** error);
   void          (*destroy_context)    (GstGLContext *context);
   void          (*swap_buffers)       (GstGLContext *context);
+  gboolean      (*check_feature)      (GstGLContext *context, const gchar *feature);
 
   /*< private >*/
   gpointer _reserved[GST_PADDING];
@@ -132,6 +133,7 @@ gboolean      gst_gl_context_set_window (GstGLContext *context, GstGLWindow *win
 GstGLWindow * gst_gl_context_get_window (GstGLContext *context);
 
 void          gst_gl_context_get_gl_version (GstGLContext *context, gint *maj, gint *min);
+gboolean      gst_gl_context_check_feature (GstGLContext *context, const gchar *feature);
 
 /* FIXME: remove */
 void gst_gl_context_thread_add (GstGLContext * context,