From 567185a2775cfe581d71dc4ac365f4fc00da5b1e Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Thu, 30 Oct 2014 16:48:00 +1100 Subject: [PATCH] glcontext: add more functionality to wrapped contexts Implements get_current_context() and get_proc_address() for wrapped contexts. --- gst-libs/gst/gl/egl/gstglcontext_egl.c | 4 +-- gst-libs/gst/gl/egl/gstglcontext_egl.h | 5 ++-- gst-libs/gst/gl/gstglcontext.c | 34 ++++++++++++++++++++++++ gst-libs/gst/gl/win32/gstglcontext_wgl.c | 4 +-- gst-libs/gst/gl/win32/gstglcontext_wgl.h | 5 ++-- gst-libs/gst/gl/x11/gstglcontext_glx.c | 4 +-- gst-libs/gst/gl/x11/gstglcontext_glx.h | 5 ++-- 7 files changed, 46 insertions(+), 15 deletions(-) diff --git a/gst-libs/gst/gl/egl/gstglcontext_egl.c b/gst-libs/gst/gl/egl/gstglcontext_egl.c index aebbdd57d6..325f06cc32 100644 --- a/gst-libs/gst/gl/egl/gstglcontext_egl.c +++ b/gst-libs/gst/gl/egl/gstglcontext_egl.c @@ -51,8 +51,6 @@ static guintptr gst_gl_context_egl_get_gl_context (GstGLContext * context); static GstGLAPI gst_gl_context_egl_get_gl_api (GstGLContext * context); static GstGLPlatform gst_gl_context_egl_get_gl_platform (GstGLContext * context); -static gpointer gst_gl_context_egl_get_proc_address (GstGLContext * context, - const gchar * name); static gboolean gst_gl_context_egl_check_feature (GstGLContext * context, const gchar * feature); @@ -547,7 +545,7 @@ load_egl_module (gpointer user_data) return NULL; } -static gpointer +gpointer gst_gl_context_egl_get_proc_address (GstGLContext * context, const gchar * name) { gpointer result = NULL; diff --git a/gst-libs/gst/gl/egl/gstglcontext_egl.h b/gst-libs/gst/gl/egl/gstglcontext_egl.h index 2f950f8b03..f6c05b17b2 100644 --- a/gst-libs/gst/gl/egl/gstglcontext_egl.h +++ b/gst-libs/gst/gl/egl/gstglcontext_egl.h @@ -56,8 +56,9 @@ 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); +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); /* TODO: * add support for EGL_NO_CONTEXT diff --git a/gst-libs/gst/gl/gstglcontext.c b/gst-libs/gst/gl/gstglcontext.c index 2393a532e2..c67bbba1e7 100644 --- a/gst-libs/gst/gl/gstglcontext.c +++ b/gst-libs/gst/gl/gstglcontext.c @@ -325,6 +325,7 @@ gst_gl_context_new_wrapped (GstGLDisplay * display, guintptr handle, { GstGLContext *context; GstGLWrappedContext *context_wrap = NULL; + GstGLContextClass *context_class; _init_debug (); @@ -344,6 +345,39 @@ gst_gl_context_new_wrapped (GstGLDisplay * display, guintptr handle, context_wrap->platform = context_type; context_wrap->available_apis = available_apis; + context_class = GST_GL_CONTEXT_GET_CLASS (context); + +#if GST_GL_HAVE_PLATFORM_GLX + if (context_type == GST_GL_PLATFORM_GLX) { + context_class->get_current_context = gst_gl_context_glx_get_current_context; + context_class->get_proc_address = gst_gl_context_glx_get_proc_address; + } +#endif +#if GST_GL_HAVE_PLATFORM_EGL + if (context_type == GST_GL_PLATFORM_EGL) { + context_class->get_current_context = gst_gl_context_egl_get_current_context; + context_class->get_proc_address = gst_gl_context_egl_get_proc_address; + } +#endif +#if GST_GL_HAVE_PLATFORM_CGL + if (context_type == GST_GL_PLATFORM_CGL) { + context_class->get_current_context = + gst_gl_context_cocoa_get_current_context; + } +#endif +#if GST_GL_HAVE_PLATFORM_WGL + if (context_type == GST_GL_PLATFORM_WGL) { + context_class->get_current_context = gst_gl_context_wgl_get_current_context; + context_class->get_proc_address = gst_gl_context_wgl_get_proc_address; + } +#endif +#if GST_GL_HAVE_PLATFORM_EAGL + if (context_type == GST_GL_PLATFORM_EAGL) { + context_class->get_current_context = + gst_gl_context_eagl_get_current_context; + } +#endif + return context; } diff --git a/gst-libs/gst/gl/win32/gstglcontext_wgl.c b/gst-libs/gst/gl/win32/gstglcontext_wgl.c index 7547b47272..a2570fce02 100644 --- a/gst-libs/gst/gl/win32/gstglcontext_wgl.c +++ b/gst-libs/gst/gl/win32/gstglcontext_wgl.c @@ -46,8 +46,6 @@ static void gst_gl_context_wgl_destroy_context (GstGLContext * context); GstGLAPI gst_gl_context_wgl_get_gl_api (GstGLContext * context); static GstGLPlatform gst_gl_context_wgl_get_gl_platform (GstGLContext * context); -static gpointer gst_gl_context_wgl_get_proc_address (GstGLContext * context, - const gchar * name); static void gst_gl_context_wgl_class_init (GstGLContextWGLClass * klass) @@ -285,7 +283,7 @@ gst_gl_context_wgl_get_gl_platform (GstGLContext * context) return GST_GL_PLATFORM_WGL; } -static gpointer +gpointer gst_gl_context_wgl_get_proc_address (GstGLContext * context, const gchar * name) { gpointer result; diff --git a/gst-libs/gst/gl/win32/gstglcontext_wgl.h b/gst-libs/gst/gl/win32/gstglcontext_wgl.h index d840175e13..8d9758cb76 100644 --- a/gst-libs/gst/gl/win32/gstglcontext_wgl.h +++ b/gst-libs/gst/gl/win32/gstglcontext_wgl.h @@ -55,8 +55,9 @@ struct _GstGLContextWGLClass { GType gst_gl_context_wgl_get_type (void); -GstGLContextWGL * gst_gl_context_wgl_new (void); -guintptr gst_gl_context_wgl_get_current_context (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); G_END_DECLS diff --git a/gst-libs/gst/gl/x11/gstglcontext_glx.c b/gst-libs/gst/gl/x11/gstglcontext_glx.c index 6614dddf73..6c52f431d3 100644 --- a/gst-libs/gst/gl/x11/gstglcontext_glx.c +++ b/gst-libs/gst/gl/x11/gstglcontext_glx.c @@ -57,8 +57,6 @@ static gboolean gst_gl_context_glx_choose_format (GstGLContext * GstGLAPI gst_gl_context_glx_get_gl_api (GstGLContext * context); static GstGLPlatform gst_gl_context_glx_get_gl_platform (GstGLContext * context); -static gpointer gst_gl_context_glx_get_proc_address (GstGLContext * context, - const gchar * name); struct _GstGLContextGLXPrivate { @@ -421,7 +419,7 @@ gst_gl_context_glx_get_gl_platform (GstGLContext * context) return GST_GL_PLATFORM_GLX; } -static gpointer +gpointer gst_gl_context_glx_get_proc_address (GstGLContext * context, const gchar * name) { gpointer result; diff --git a/gst-libs/gst/gl/x11/gstglcontext_glx.h b/gst-libs/gst/gl/x11/gstglcontext_glx.h index 0c08f24b84..9b8c890ea3 100644 --- a/gst-libs/gst/gl/x11/gstglcontext_glx.h +++ b/gst-libs/gst/gl/x11/gstglcontext_glx.h @@ -59,8 +59,9 @@ struct _GstGLContextGLXClass { GType gst_gl_context_glx_get_type (void); -GstGLContextGLX * gst_gl_context_glx_new (void); -guintptr gst_gl_context_glx_get_current_context (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); G_END_DECLS