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
This commit is contained in:
Matthew Waters 2015-07-24 16:11:38 +10:00 committed by Tim-Philipp Müller
parent 738ed418ad
commit 9587eb477d
9 changed files with 32 additions and 26 deletions

View file

@ -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

View file

@ -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);

View file

@ -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

View file

@ -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 *

View file

@ -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);

View file

@ -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) {

View file

@ -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

View file

@ -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

View file

@ -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);