diff options
author | Matthew Waters <matthew@centricular.com> | 2015-07-24 16:11:38 +1000 |
---|---|---|
committer | Matthew Waters <matthew@centricular.com> | 2015-07-27 18:23:17 +1000 |
commit | dbcae77e02a465fa5813cf1bd97c1264d43b1ffe (patch) | |
tree | 8b6bcd38ff9b2ae6041eced62f43e76e2848643d /gst-libs | |
parent | 5e4b94c1bbf530db49b56915154f4d9fabd09bec (diff) | |
download | gstreamer-plugins-bad-dbcae77e02a465fa5813cf1bd97c1264d43b1ffe.tar.gz |
glcontext: pass display to implentation's _new()
This allows the context to fail creation based on incompatible
display type's. e.g. glx context with an wayland display handle.
https://bugzilla.gnome.org/show_bug.cgi?id=752743
Diffstat (limited to 'gst-libs')
-rw-r--r-- | gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m | 8 | ||||
-rw-r--r-- | gst-libs/gst/gl/eagl/gstglcontext_eagl.h | 2 | ||||
-rw-r--r-- | gst-libs/gst/gl/eagl/gstglcontext_eagl.m | 7 | ||||
-rw-r--r-- | gst-libs/gst/gl/egl/gstglcontext_egl.c | 8 | ||||
-rw-r--r-- | gst-libs/gst/gl/egl/gstglcontext_egl.h | 4 | ||||
-rw-r--r-- | gst-libs/gst/gl/gstglcontext.c | 10 | ||||
-rw-r--r-- | gst-libs/gst/gl/win32/gstglcontext_wgl.c | 7 | ||||
-rw-r--r-- | gst-libs/gst/gl/x11/gstglcontext_glx.c | 10 | ||||
-rw-r--r-- | gst-libs/gst/gl/x11/gstglcontext_glx.h | 2 |
9 files changed, 32 insertions, 26 deletions
diff --git a/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m b/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m index 769395a86..bde90f1c6 100644 --- a/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m +++ b/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m @@ -72,11 +72,13 @@ gst_gl_context_cocoa_init (GstGLContextCocoa * context) /* Must be called in the gl thread */ GstGLContextCocoa * -gst_gl_context_cocoa_new (void) +gst_gl_context_cocoa_new (GstGLDisplay * display) { - GstGLContextCocoa *context = g_object_new (GST_GL_TYPE_CONTEXT_COCOA, NULL); + if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_COCOA) == 0) + /* we require an cocoa display to create CGL contexts */ + return NULL; - return context; + return g_object_new (GST_GL_TYPE_CONTEXT_COCOA, NULL); } struct pixel_attr diff --git a/gst-libs/gst/gl/eagl/gstglcontext_eagl.h b/gst-libs/gst/gl/eagl/gstglcontext_eagl.h index c8997ff0e..bd6cd2072 100644 --- a/gst-libs/gst/gl/eagl/gstglcontext_eagl.h +++ b/gst-libs/gst/gl/eagl/gstglcontext_eagl.h @@ -57,7 +57,7 @@ struct _GstGLContextEaglClass { GType gst_gl_context_eagl_get_type (void); -GstGLContextEagl * gst_gl_context_eagl_new (void); +GstGLContextEagl * gst_gl_context_eagl_new (GstGLDisplay * display); void gst_gl_context_eagl_update_layer (GstGLContext * context); void gst_gl_context_eagl_resize (GstGLContextEagl * eagl_context); diff --git a/gst-libs/gst/gl/eagl/gstglcontext_eagl.m b/gst-libs/gst/gl/eagl/gstglcontext_eagl.m index aaabfe256..dce81680c 100644 --- a/gst-libs/gst/gl/eagl/gstglcontext_eagl.m +++ b/gst-libs/gst/gl/eagl/gstglcontext_eagl.m @@ -92,11 +92,10 @@ gst_gl_context_eagl_init (GstGLContextEagl * context) /* Must be called in the gl thread */ GstGLContextEagl * -gst_gl_context_eagl_new (void) +gst_gl_context_eagl_new (GstGLDisplay * display) { - GstGLContextEagl *context = g_object_new (GST_GL_TYPE_CONTEXT_EAGL, NULL); - - return context; + /* there isn't actually a display type for eagl yet? */ + return g_object_new (GST_GL_TYPE_CONTEXT_EAGL, NULL); } void diff --git a/gst-libs/gst/gl/egl/gstglcontext_egl.c b/gst-libs/gst/gl/egl/gstglcontext_egl.c index c466a0a68..3a4aa356b 100644 --- a/gst-libs/gst/gl/egl/gstglcontext_egl.c +++ b/gst-libs/gst/gl/egl/gstglcontext_egl.c @@ -100,11 +100,11 @@ gst_gl_context_egl_init (GstGLContextEGL * context) /* Must be called in the gl thread */ GstGLContextEGL * -gst_gl_context_egl_new (void) +gst_gl_context_egl_new (GstGLDisplay * display) { - GstGLContextEGL *window = g_object_new (GST_GL_TYPE_CONTEXT_EGL, NULL); - - return window; + /* XXX: display type could theoretically be anything, as long as + * eglGetDisplay supports it. */ + return g_object_new (GST_GL_TYPE_CONTEXT_EGL, NULL); } static const gchar * diff --git a/gst-libs/gst/gl/egl/gstglcontext_egl.h b/gst-libs/gst/gl/egl/gstglcontext_egl.h index 5af9d6065..88b8bd773 100644 --- a/gst-libs/gst/gl/egl/gstglcontext_egl.h +++ b/gst-libs/gst/gl/egl/gstglcontext_egl.h @@ -30,6 +30,7 @@ G_BEGIN_DECLS typedef struct _GstGLContextEGL GstGLContextEGL; typedef struct _GstGLContextEGLClass GstGLContextEGLClass; +GType gst_gl_context_egl_get_type (void); #define GST_GL_TYPE_CONTEXT_EGL (gst_gl_context_egl_get_type()) #define GST_GL_CONTEXT_EGL(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_GL_TYPE_CONTEXT_EGL, GstGLContextEGL)) #define GST_GL_CONTEXT_EGL_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_GL_TYPE_CONTEXT_EGL, GstGLContextEGLClass)) @@ -59,8 +60,7 @@ struct _GstGLContextEGLClass { GstGLContextClass parent; }; -GType gst_gl_context_egl_get_type (void); -GstGLContextEGL * gst_gl_context_egl_new (void); +GstGLContextEGL * gst_gl_context_egl_new (GstGLDisplay * display); guintptr gst_gl_context_egl_get_current_context (void); gpointer gst_gl_context_egl_get_proc_address (GstGLAPI gl_api, const gchar * name); diff --git a/gst-libs/gst/gl/gstglcontext.c b/gst-libs/gst/gl/gstglcontext.c index 102abc274..9ec30ca43 100644 --- a/gst-libs/gst/gl/gstglcontext.c +++ b/gst-libs/gst/gl/gstglcontext.c @@ -311,24 +311,24 @@ gst_gl_context_new (GstGLDisplay * display) ", user choice:%s", display, user_choice); #if GST_GL_HAVE_PLATFORM_CGL if (!context && (!user_choice || g_strstr_len (user_choice, 5, "cgl"))) - context = GST_GL_CONTEXT (gst_gl_context_cocoa_new ()); + context = GST_GL_CONTEXT (gst_gl_context_cocoa_new (display)); #endif #if GST_GL_HAVE_PLATFORM_GLX if (!context && (!user_choice || g_strstr_len (user_choice, 3, "glx"))) - context = GST_GL_CONTEXT (gst_gl_context_glx_new ()); + context = GST_GL_CONTEXT (gst_gl_context_glx_new (display)); #endif #if GST_GL_HAVE_PLATFORM_EGL if (!context && (!user_choice || g_strstr_len (user_choice, 7, "egl"))) - context = GST_GL_CONTEXT (gst_gl_context_egl_new ()); + context = GST_GL_CONTEXT (gst_gl_context_egl_new (display)); #endif #if GST_GL_HAVE_PLATFORM_WGL if (!context && (!user_choice || g_strstr_len (user_choice, 3, "wgl"))) { - context = GST_GL_CONTEXT (gst_gl_context_wgl_new ()); + context = GST_GL_CONTEXT (gst_gl_context_wgl_new (display)); } #endif #if GST_GL_HAVE_PLATFORM_EAGL if (!context && (!user_choice || g_strstr_len (user_choice, 5, "eagl"))) - context = GST_GL_CONTEXT (gst_gl_context_eagl_new ()); + context = GST_GL_CONTEXT (gst_gl_context_eagl_new (display)); #endif if (!context) { diff --git a/gst-libs/gst/gl/win32/gstglcontext_wgl.c b/gst-libs/gst/gl/win32/gstglcontext_wgl.c index 9fd6e61a8..59b238c2c 100644 --- a/gst-libs/gst/gl/win32/gstglcontext_wgl.c +++ b/gst-libs/gst/gl/win32/gstglcontext_wgl.c @@ -80,9 +80,12 @@ gst_gl_context_wgl_init (GstGLContextWGL * context_wgl) GstGLContextWGL * gst_gl_context_wgl_new (void) { - GstGLContextWGL *context = g_object_new (GST_GL_TYPE_CONTEXT_WGL, NULL); + if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_WIN32) == + 0) + /* we require an win32 display handle to create WGL contexts */ + return NULL; - return context; + return g_object_new (GST_GL_TYPE_CONTEXT_WGL, NULL); } static gboolean diff --git a/gst-libs/gst/gl/x11/gstglcontext_glx.c b/gst-libs/gst/gl/x11/gstglcontext_glx.c index 645d5c749..0e4e67b83 100644 --- a/gst-libs/gst/gl/x11/gstglcontext_glx.c +++ b/gst-libs/gst/gl/x11/gstglcontext_glx.c @@ -37,7 +37,7 @@ #include <gst/gl/gl.h> #include "gstglcontext_glx.h" -#define GST_CAT_DEFAULT gst_gl_window_debug +#define GST_CAT_DEFAULT gst_gl_context_debug #define gst_gl_context_glx_parent_class parent_class G_DEFINE_TYPE (GstGLContextGLX, gst_gl_context_glx, GST_GL_TYPE_CONTEXT); @@ -105,11 +105,13 @@ gst_gl_context_glx_init (GstGLContextGLX * context) } GstGLContextGLX * -gst_gl_context_glx_new (void) +gst_gl_context_glx_new (GstGLDisplay * display) { - GstGLContextGLX *context = g_object_new (GST_GL_TYPE_CONTEXT_GLX, NULL); + if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_X11) == 0) + /* we require an x11 display handle to create GLX contexts */ + return NULL; - return context; + return g_object_new (GST_GL_TYPE_CONTEXT_GLX, NULL); } static inline void diff --git a/gst-libs/gst/gl/x11/gstglcontext_glx.h b/gst-libs/gst/gl/x11/gstglcontext_glx.h index cb133fa9d..e015108f7 100644 --- a/gst-libs/gst/gl/x11/gstglcontext_glx.h +++ b/gst-libs/gst/gl/x11/gstglcontext_glx.h @@ -59,7 +59,7 @@ struct _GstGLContextGLXClass { GType gst_gl_context_glx_get_type (void); -GstGLContextGLX * gst_gl_context_glx_new (void); +GstGLContextGLX * gst_gl_context_glx_new (GstGLDisplay * display); guintptr gst_gl_context_glx_get_current_context (void); gpointer gst_gl_context_glx_get_proc_address (GstGLAPI gl_api, const gchar * name); |