glwindow: pass display to implementation's _new()

So they have to opportunity to fail if they cannot handle the
display connection.

https://bugzilla.gnome.org/show_bug.cgi?id=752743
This commit is contained in:
Matthew Waters 2015-07-24 17:00:27 +10:00 committed by Tim-Philipp Müller
parent 9587eb477d
commit 6ccaafc0f3
14 changed files with 59 additions and 59 deletions

View file

@ -69,15 +69,15 @@ gst_gl_window_android_egl_init (GstGLWindowAndroidEGL * window)
/* Must be called in the gl thread */
GstGLWindowAndroidEGL *
gst_gl_window_android_egl_new (void)
gst_gl_window_android_egl_new (GstGLDisplay * display)
{
GstGLWindowAndroidEGL *window;
if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_EGL) == 0)
/* we require an egl display to create android windows */
return NULL;
GST_DEBUG ("creating Android EGL window");
window = g_object_new (GST_GL_TYPE_WINDOW_ANDROID_EGL, NULL);
return window;
return g_object_new (GST_GL_TYPE_WINDOW_ANDROID_EGL, NULL);
}
static void

View file

@ -58,7 +58,7 @@ struct _GstGLWindowAndroidEGLClass {
GType gst_gl_window_android_egl_get_type (void);
GstGLWindowAndroidEGL * gst_gl_window_android_egl_new (void);
GstGLWindowAndroidEGL * gst_gl_window_android_egl_new (GstGLDisplay * display);
G_END_DECLS

View file

@ -58,7 +58,7 @@ struct _GstGLWindowCocoaClass {
GType gst_gl_window_cocoa_get_type (void);
GstGLWindowCocoa * gst_gl_window_cocoa_new (void);
GstGLWindowCocoa * gst_gl_window_cocoa_new (GstGLDisplay * display);
void gst_gl_window_cocoa_draw_thread (GstGLWindowCocoa *window_cocoa);

View file

@ -129,13 +129,14 @@ gst_gl_window_cocoa_finalize (GObject * object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
/* Must be called in the gl thread */
GstGLWindowCocoa *
gst_gl_window_cocoa_new (void)
gst_gl_window_cocoa_new (GstGLDisplay * display)
{
GstGLWindowCocoa *window = g_object_new (GST_GL_TYPE_WINDOW_COCOA, NULL);
if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_COCOA) == 0)
/* we require an cocoa display to create CGL windows */
return NULL;
return window;
return g_object_new (GST_GL_TYPE_WINDOW_COCOA, NULL);
}
/* Must be called from the main thread */

View file

@ -83,29 +83,28 @@ gst_gl_window_dispmanx_egl_class_init (GstGLWindowDispmanxEGLClass * klass)
static void
gst_gl_window_dispmanx_egl_init (GstGLWindowDispmanxEGL * window_egl)
{
window_egl->egldisplay = EGL_DEFAULT_DISPLAY;
window_egl->visible = FALSE;
window_egl->display = 0;
window_egl->dp_width = 0;
window_egl->dp_height = 0;
window_egl->native.element = 0;
window_egl->native.width = 0;
window_egl->native.height = 0;
}
/* Must be called in the gl thread */
GstGLWindowDispmanxEGL *
gst_gl_window_dispmanx_egl_new (void)
gst_gl_window_dispmanx_egl_new (GstGLDisplay * display)
{
GstGLWindowDispmanxEGL *window;
if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_EGL) == 0)
/* we require an egl display to create dispmanx windows */
return NULL;
GST_DEBUG ("creating Dispmanx EGL window");
window = g_object_new (GST_GL_TYPE_WINDOW_DISPMANX_EGL, NULL);
window->egldisplay = EGL_DEFAULT_DISPLAY;
window->visible = FALSE;
window->display = 0;
window->dp_width = 0;
window->dp_height = 0;
window->native.element = 0;
window->native.width = 0;
window->native.height = 0;
return window;
return g_object_new (GST_GL_TYPE_WINDOW_DISPMANX_EGL, NULL);
}
static void
@ -133,8 +132,8 @@ gst_gl_window_dispmanx_egl_open (GstGLWindow * window, GError ** error)
gint ret = graphics_get_display_size (0, &window_egl->dp_width,
&window_egl->dp_height);
if (ret < 0) {
g_set_error (error, GST_GL_WINDOW_ERROR, GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE,
"Can't open display");
g_set_error (error, GST_GL_WINDOW_ERROR,
GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE, "Can't open display");
return FALSE;
}
GST_DEBUG ("Got display size: %dx%d\n", window_egl->dp_width,
@ -236,8 +235,8 @@ window_resize (GstGLWindowDispmanxEGL * window_egl, guint width, guint height,
vc_dispmanx_update_submit_sync (dispman_update);
if (GST_GL_WINDOW (window_egl)->resize)
GST_GL_WINDOW (window_egl)->resize (GST_GL_WINDOW (window_egl)->
resize_data, width, height);
GST_GL_WINDOW (window_egl)->
resize (GST_GL_WINDOW (window_egl)->resize_data, width, height);
}
window_egl->native.width = width;

View file

@ -83,7 +83,7 @@ struct _GstGLWindowDispmanxEGLClass {
GType gst_gl_window_dispmanx_egl_get_type (void);
GstGLWindowDispmanxEGL * gst_gl_window_dispmanx_egl_new (void);
GstGLWindowDispmanxEGL * gst_gl_window_dispmanx_egl_new (GstGLDisplay * display);
gboolean gst_gl_window_dispmanx_egl_create_window (GstGLWindowDispmanxEGL * window_egl);
G_END_DECLS

View file

@ -57,7 +57,7 @@ struct _GstGLWindowEaglClass {
GType gst_gl_window_eagl_get_type (void);
GstGLWindowEagl * gst_gl_window_eagl_new (void);
GstGLWindowEagl * gst_gl_window_eagl_new (GstGLDisplay * display);
G_END_DECLS

View file

@ -84,11 +84,10 @@ gst_gl_window_eagl_init (GstGLWindowEagl * window)
/* Must be called in the gl thread */
GstGLWindowEagl *
gst_gl_window_eagl_new (void)
gst_gl_window_eagl_new (GstGLDisplay * display)
{
GstGLWindowEagl *window = g_object_new (GST_GL_TYPE_WINDOW_EAGL, NULL);
return window;
/* there isn't an eagl display type */
return g_object_new (GST_GL_TYPE_WINDOW_EAGL, NULL);
}
static guintptr

View file

@ -272,7 +272,7 @@ gst_gl_window_new (GstGLDisplay * display)
#if GST_GL_HAVE_WINDOW_COCOA
if (!window && (!user_choice || g_strstr_len (user_choice, 5, "cocoa")))
window = GST_GL_WINDOW (gst_gl_window_cocoa_new ());
window = GST_GL_WINDOW (gst_gl_window_cocoa_new (display));
#endif
#if GST_GL_HAVE_WINDOW_X11
if (!window && (!user_choice || g_strstr_len (user_choice, 3, "x11")))
@ -280,23 +280,23 @@ gst_gl_window_new (GstGLDisplay * display)
#endif
#if GST_GL_HAVE_WINDOW_WIN32
if (!window && (!user_choice || g_strstr_len (user_choice, 5, "win32")))
window = GST_GL_WINDOW (gst_gl_window_win32_new ());
window = GST_GL_WINDOW (gst_gl_window_win32_new (display));
#endif
#if GST_GL_HAVE_WINDOW_WAYLAND
if (!window && (!user_choice || g_strstr_len (user_choice, 7, "wayland")))
window = GST_GL_WINDOW (gst_gl_window_wayland_egl_new ());
window = GST_GL_WINDOW (gst_gl_window_wayland_egl_new (display));
#endif
#if GST_GL_HAVE_WINDOW_DISPMANX
if (!window && (!user_choice || g_strstr_len (user_choice, 8, "dispmanx")))
window = GST_GL_WINDOW (gst_gl_window_dispmanx_egl_new ());
window = GST_GL_WINDOW (gst_gl_window_dispmanx_egl_new (display));
#endif
#if GST_GL_HAVE_WINDOW_ANDROID
if (!window && (!user_choice || g_strstr_len (user_choice, 7, "android")))
window = GST_GL_WINDOW (gst_gl_window_android_egl_new ());
window = GST_GL_WINDOW (gst_gl_window_android_egl_new (display));
#endif
#if GST_GL_HAVE_WINDOW_EAGL
if (!window && (!user_choice || g_strstr_len (user_choice, 4, "eagl")))
window = GST_GL_WINDOW (gst_gl_window_eagl_new ());
window = GST_GL_WINDOW (gst_gl_window_eagl_new (display));
#endif
if (!window) {
/* subclass returned a NULL window */

View file

@ -290,8 +290,8 @@ create_surfaces (GstGLWindowWaylandEGL * window_egl)
wl_shell_get_shell_surface (display->shell,
window_egl->window.surface);
if (window_egl->window.queue)
wl_proxy_set_queue ((struct wl_proxy *) window_egl->
window.shell_surface, window_egl->window.queue);
wl_proxy_set_queue ((struct wl_proxy *) window_egl->window.
shell_surface, window_egl->window.queue);
wl_shell_surface_add_listener (window_egl->window.shell_surface,
&shell_surface_listener, window_egl);
@ -351,15 +351,16 @@ gst_gl_window_wayland_egl_init (GstGLWindowWaylandEGL * window)
/* Must be called in the gl thread */
GstGLWindowWaylandEGL *
gst_gl_window_wayland_egl_new (void)
gst_gl_window_wayland_egl_new (GstGLDisplay * display)
{
GstGLWindowWaylandEGL *window;
if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_WAYLAND)
== 0)
/* we require a wayland display to create wayland surfaces */
return NULL;
GST_DEBUG ("creating Wayland EGL window");
window = g_object_new (GST_GL_TYPE_WINDOW_WAYLAND_EGL, NULL);
return window;
return g_object_new (GST_GL_TYPE_WINDOW_WAYLAND_EGL, NULL);
}
static void

View file

@ -97,7 +97,7 @@ struct _GstGLWindowWaylandEGLClass {
GType gst_gl_window_wayland_egl_get_type (void);
GstGLWindowWaylandEGL * gst_gl_window_wayland_egl_new (void);
GstGLWindowWaylandEGL * gst_gl_window_wayland_egl_new (GstGLDisplay * display);
void gst_gl_window_wayland_egl_create_window (GstGLWindowWaylandEGL * window_egl);

View file

@ -94,9 +94,12 @@ gst_gl_window_win32_init (GstGLWindowWin32 * window)
GstGLWindowWin32 *
gst_gl_window_win32_new (void)
{
GstGLWindowWin32 *window = g_object_new (GST_GL_TYPE_WINDOW_WIN32, NULL);
if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_WIN32) ==
0)
/* we require an win32 display to create win32 windows */
return NULL;
return window;
return g_object_new (GST_GL_TYPE_WINDOW_WIN32, NULL);
}
static void

View file

@ -77,7 +77,7 @@ struct _GstGLWindowWin32Class {
GType gst_gl_window_win32_get_type (void);
GstGLWindowWin32 * gst_gl_window_win32_new (void);
GstGLWindowWin32 * gst_gl_window_win32_new (GstGLDisplay * display);
gboolean gst_gl_window_win32_create_window (GstGLWindowWin32 * window_win32, GError ** error);

View file

@ -130,17 +130,14 @@ gst_gl_window_x11_init (GstGLWindowX11 * window)
GstGLWindowX11 *
gst_gl_window_x11_new (GstGLDisplay * display)
{
GstGLWindowX11 *window = NULL;
if ((display->type & GST_GL_DISPLAY_TYPE_X11) == GST_GL_DISPLAY_TYPE_NONE) {
if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_X11)
== GST_GL_DISPLAY_TYPE_NONE) {
GST_INFO ("Wrong display type %u for this window type %u", display->type,
GST_GL_DISPLAY_TYPE_X11);
return NULL;
}
window = g_object_new (GST_GL_TYPE_WINDOW_X11, NULL);
return window;
return g_object_new (GST_GL_TYPE_WINDOW_X11, NULL);
}
gboolean