mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
glcontext: consolidate get_proc_address function definition
Pass the GstGLAPI directly.
This commit is contained in:
parent
36408736c0
commit
cfa9b94045
8 changed files with 39 additions and 22 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue