glcontext: consolidate get_proc_address function definition
authorMatthew Waters <matthew@centricular.com>
Sat, 18 Jul 2015 07:08:36 +0000 (17:08 +1000)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 9 Dec 2017 19:32:05 +0000 (19:32 +0000)
Pass the GstGLAPI directly.

gst-libs/gst/gl/egl/gstglcontext_egl.c
gst-libs/gst/gl/egl/gstglcontext_egl.h
gst-libs/gst/gl/gstglcontext.c
gst-libs/gst/gl/gstglcontext.h
gst-libs/gst/gl/win32/gstglcontext_wgl.c
gst-libs/gst/gl/win32/gstglcontext_wgl.h
gst-libs/gst/gl/x11/gstglcontext_glx.c
gst-libs/gst/gl/x11/gstglcontext_glx.h

index 1b130a8..74ddc73 100644 (file)
@@ -622,11 +622,10 @@ load_egl_module (gpointer user_data)
 }
 
 gpointer
-gst_gl_context_egl_get_proc_address (GstGLContext * context, const gchar * name)
+gst_gl_context_egl_get_proc_address (GstGLAPI gl_api, const gchar * name)
 {
   gpointer result = NULL;
   static GOnce g_once = G_ONCE_INIT;
-  GstGLAPI gl_api = gst_gl_context_get_gl_api (context);
 
   result = gst_gl_context_default_get_proc_address (gl_api, name);
 
index 76632a3..5af9d60 100644 (file)
@@ -62,7 +62,7 @@ struct _GstGLContextEGLClass {
 GType gst_gl_context_egl_get_type     (void);
 GstGLContextEGL *   gst_gl_context_egl_new                  (void);
 guintptr            gst_gl_context_egl_get_current_context  (void);
-gpointer            gst_gl_context_egl_get_proc_address     (GstGLContext * context, const gchar * name);
+gpointer            gst_gl_context_egl_get_proc_address     (GstGLAPI gl_api, const gchar * name);
 
 /* TODO:
  * add support for EGL_NO_CONTEXT
index 2a418e1..a8e4af0 100644 (file)
@@ -174,8 +174,6 @@ G_DEFINE_ABSTRACT_TYPE (GstGLContext, gst_gl_context, GST_TYPE_OBJECT);
 static void _init_debug (void);
 
 static gpointer gst_gl_context_create_thread (GstGLContext * context);
-static gpointer _default_get_proc_address (GstGLContext * context,
-    const gchar * name);
 static void gst_gl_context_finalize (GObject * object);
 
 struct _GstGLContextPrivate
@@ -269,7 +267,8 @@ gst_gl_context_class_init (GstGLContextClass * klass)
 {
   g_type_class_add_private (klass, sizeof (GstGLContextPrivate));
 
-  klass->get_proc_address = GST_DEBUG_FUNCPTR (_default_get_proc_address);
+  klass->get_proc_address =
+      GST_DEBUG_FUNCPTR (gst_gl_context_default_get_proc_address);
 
   G_OBJECT_CLASS (klass)->finalize = gst_gl_context_finalize;
 
@@ -480,6 +479,32 @@ gst_gl_context_get_current_gl_context (GstGLPlatform context_type)
   return handle;
 }
 
+gpointer
+gst_gl_context_get_proc_address_with_platform (GstGLPlatform context_type,
+    GstGLAPI gl_api, const gchar * name)
+{
+  gpointer ret = NULL;
+
+#if GST_GL_HAVE_PLATFORM_GLX
+  if (!ret && (context_type & GST_GL_PLATFORM_GLX) != 0)
+    ret = gst_gl_context_glx_get_proc_address (gl_api, name);
+#endif
+#if GST_GL_HAVE_PLATFORM_EGL
+  if (!ret && (context_type & GST_GL_PLATFORM_EGL) != 0)
+    ret = gst_gl_context_egl_get_proc_address (gl_api, name);
+#endif
+#if GST_GL_HAVE_PLATFORM_WGL
+  if (!ret && (context_type & GST_GL_PLATFORM_WGL) != 0)
+    ret = gst_gl_context_wgl_get_proc_address (gl_api, name);
+#endif
+  /* CGL and EAGL rely on the default impl */
+
+  if (!ret)
+    ret = gst_gl_context_default_get_proc_address (gl_api, name);
+
+  return ret;
+}
+
 /**
  * gst_gl_context_get_current_gl_api:
  * @major: (out): (allow-none): the major version
@@ -723,14 +748,6 @@ gst_gl_context_get_gl_api (GstGLContext * context)
   return context_class->get_gl_api (context);
 }
 
-static gpointer
-_default_get_proc_address (GstGLContext * context, const gchar * name)
-{
-  GstGLAPI gl_api = gst_gl_context_get_gl_api (context);
-
-  return gst_gl_context_default_get_proc_address (gl_api, name);
-}
-
 /**
  * gst_gl_context_get_proc_address:
  * @context: a #GstGLContext
@@ -751,12 +768,14 @@ gst_gl_context_get_proc_address (GstGLContext * context, const gchar * name)
 {
   gpointer ret;
   GstGLContextClass *context_class;
+  GstGLAPI gl_api;
 
   g_return_val_if_fail (GST_GL_IS_CONTEXT (context), NULL);
   context_class = GST_GL_CONTEXT_GET_CLASS (context);
   g_return_val_if_fail (context_class->get_proc_address != NULL, NULL);
 
-  ret = context_class->get_proc_address (context, name);
+  gl_api = gst_gl_context_get_gl_api (context);
+  ret = context_class->get_proc_address (gl_api, name);
 
   return ret;
 }
index 1ee2e72..ee8953e 100644 (file)
@@ -100,7 +100,7 @@ struct _GstGLContextClass {
   guintptr      (*get_gl_context)     (GstGLContext *context);
   GstGLAPI      (*get_gl_api)         (GstGLContext *context);
   GstGLPlatform (*get_gl_platform)    (GstGLContext *context);
-  gpointer      (*get_proc_address)   (GstGLContext *context, const gchar *name);
+  gpointer      (*get_proc_address)   (GstGLAPI gl_api, const gchar *name);
   gboolean      (*activate)           (GstGLContext *context, gboolean activate);
   gboolean      (*choose_format)      (GstGLContext *context, GError **error);
   gboolean      (*create_context)     (GstGLContext *context, GstGLAPI gl_api,
@@ -136,6 +136,7 @@ gboolean      gst_gl_context_create           (GstGLContext *context, GstGLConte
 void          gst_gl_context_destroy          (GstGLContext *context);
 
 gpointer      gst_gl_context_default_get_proc_address (GstGLAPI gl_api, const gchar *name);
+gpointer      gst_gl_context_get_proc_address_with_platform (GstGLPlatform, GstGLAPI gl_api, const gchar *name);
 
 gboolean      gst_gl_context_set_window (GstGLContext *context, GstGLWindow *window);
 GstGLWindow * gst_gl_context_get_window (GstGLContext *context);
index a2570fc..9fd6e61 100644 (file)
@@ -284,10 +284,9 @@ gst_gl_context_wgl_get_gl_platform (GstGLContext * context)
 }
 
 gpointer
-gst_gl_context_wgl_get_proc_address (GstGLContext * context, const gchar * name)
+gst_gl_context_wgl_get_proc_address (GstGLAPI gl_api, const gchar * name)
 {
   gpointer result;
-  GstGLAPI gl_api = gst_gl_context_get_gl_api (context);
 
   if (!(result = gst_gl_context_default_get_proc_address (gl_api, name))) {
     result = wglGetProcAddress ((LPCSTR) name);
index 8d9758c..fd3daca 100644 (file)
@@ -57,7 +57,7 @@ GType gst_gl_context_wgl_get_type     (void);
 
 GstGLContextWGL *   gst_gl_context_wgl_new                  (void);
 guintptr            gst_gl_context_wgl_get_current_context  (void);
-gpointer            gst_gl_context_wgl_get_proc_address     (GstGLContext * context, const gchar * name);
+gpointer            gst_gl_context_wgl_get_proc_address     (GstGLAPI gl_api, const gchar * name);
 
 G_END_DECLS
 
index 3d511b8..645d5c7 100644 (file)
@@ -481,10 +481,9 @@ gst_gl_context_glx_get_gl_platform (GstGLContext * context)
 }
 
 gpointer
-gst_gl_context_glx_get_proc_address (GstGLContext * context, const gchar * name)
+gst_gl_context_glx_get_proc_address (GstGLAPI gl_api, const gchar * name)
 {
   gpointer result;
-  GstGLAPI gl_api = gst_gl_context_get_gl_api (context);
 
   if (!(result = gst_gl_context_default_get_proc_address (gl_api, name))) {
     result = glXGetProcAddressARB ((const GLubyte *) name);
index 9b8c890..cb133fa 100644 (file)
@@ -61,7 +61,7 @@ GType gst_gl_context_glx_get_type     (void);
 
 GstGLContextGLX *   gst_gl_context_glx_new                  (void);
 guintptr            gst_gl_context_glx_get_current_context  (void);
-gpointer            gst_gl_context_glx_get_proc_address     (GstGLContext * context, const gchar * name);
+gpointer            gst_gl_context_glx_get_proc_address     (GstGLAPI gl_api, const gchar * name);
 
 G_END_DECLS