mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
[669/906] window: seperate object creation and context creation
This commit is contained in:
parent
63a5d9e981
commit
7d4d1f50d4
14 changed files with 163 additions and 178 deletions
|
@ -58,9 +58,7 @@ struct _GstGLWindowCocoaClass {
|
|||
|
||||
GType gst_gl_window_cocoa_get_type (void);
|
||||
|
||||
GstGLWindowCocoa * gst_gl_window_cocoa_new (GstGLAPI gl_api,
|
||||
guintptr external_gl_context,
|
||||
GError ** error);
|
||||
GstGLWindowCocoa * gst_gl_window_cocoa_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -111,6 +111,8 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
|||
#define gst_gl_window_cocoa_parent_class parent_class
|
||||
G_DEFINE_TYPE_WITH_CODE (GstGLWindowCocoa, gst_gl_window_cocoa, GST_GL_TYPE_WINDOW, DEBUG_INIT);
|
||||
|
||||
gboolean gst_gl_window_cocoa_create_context (GstGLWindow *window, GstGLAPI gl_api,
|
||||
guintptr external_opengl_context, GError **error);
|
||||
guintptr gst_gl_window_cocoa_get_gl_context (GstGLWindow * window);
|
||||
gboolean gst_gl_window_cocoa_activate (GstGLWindow * window, gboolean activate);
|
||||
void gst_gl_window_cocoa_set_window_handle (GstGLWindow * window,
|
||||
|
@ -167,6 +169,8 @@ gst_gl_window_cocoa_class_init (GstGLWindowCocoaClass * klass)
|
|||
|
||||
g_type_class_add_private (klass, sizeof (GstGLWindowCocoaPrivate));
|
||||
|
||||
window_class->create_context =
|
||||
GST_DEBUG_FUNCPTR (gst_gl_window_cocoa_create_context);
|
||||
window_class->get_gl_context =
|
||||
GST_DEBUG_FUNCPTR (gst_gl_window_cocoa_get_gl_context);
|
||||
window_class->activate = GST_DEBUG_FUNCPTR (gst_gl_window_cocoa_activate);
|
||||
|
@ -193,14 +197,25 @@ static void
|
|||
gst_gl_window_cocoa_init (GstGLWindowCocoa * window)
|
||||
{
|
||||
window->priv = GST_GL_WINDOW_COCOA_GET_PRIVATE (window);
|
||||
|
||||
gst_gl_window_set_need_lock (GST_GL_WINDOW (window), FALSE);
|
||||
}
|
||||
|
||||
/* Must be called in the gl thread */
|
||||
GstGLWindowCocoa *
|
||||
gst_gl_window_cocoa_new (GstGLAPI gl_api, guintptr external_gl_context, GError ** error)
|
||||
gst_gl_window_cocoa_new (void)
|
||||
{
|
||||
GstGLWindowCocoa *window = g_object_new (GST_GL_TYPE_WINDOW_COCOA, NULL);
|
||||
GstGLWindowCocoaPrivate *priv = window->priv;
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_gl_window_cocoa_create_context (GstGLWindow *window, GstGLAPI gl_api,
|
||||
guintptr external_gl_context, GError **error)
|
||||
{
|
||||
GstGLWindowCocoa *window_cocoa = GST_GL_WINDOW_COCOA (window);
|
||||
GstGLWindowCocoaPrivate *priv = window_cocoa->priv;
|
||||
NSRect rect;
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
|
@ -212,8 +227,6 @@ gst_gl_window_cocoa_new (GstGLAPI gl_api, guintptr external_gl_context, GError *
|
|||
priv->thread = nil;
|
||||
priv->running = TRUE;
|
||||
|
||||
gst_gl_window_set_need_lock (GST_GL_WINDOW (window), FALSE);
|
||||
|
||||
GSRegisterCurrentThread();
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
@ -230,7 +243,7 @@ gst_gl_window_cocoa_new (GstGLAPI gl_api, guintptr external_gl_context, GError *
|
|||
priv->internal_win_id =[[GstGLNSWindow alloc] initWithContentRect:rect styleMask:
|
||||
(NSTitledWindowMask | NSClosableWindowMask |
|
||||
NSResizableWindowMask | NSMiniaturizableWindowMask)
|
||||
backing: NSBackingStoreBuffered defer: NO screen: nil gstWin: window];
|
||||
backing: NSBackingStoreBuffered defer: NO screen: nil gstWin: window_cocoa];
|
||||
|
||||
GST_DEBUG ("NSWindow id: %lud\n", (gulong) priv->internal_win_id);
|
||||
|
||||
|
@ -244,7 +257,7 @@ gst_gl_window_cocoa_new (GstGLAPI gl_api, guintptr external_gl_context, GError *
|
|||
priv->source_id = g_timeout_add_seconds (1, gst_gl_window_cocoa_nsapp_iteration, NULL);
|
||||
#endif
|
||||
|
||||
return window;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
guintptr
|
||||
|
|
|
@ -221,6 +221,8 @@ gst_gl_display_init (GstGLDisplay * display)
|
|||
|
||||
display->gl_vtable = g_slice_alloc0 (sizeof (GstGLFuncs));
|
||||
|
||||
display->gl_window = gst_gl_window_new ();
|
||||
|
||||
gst_gl_memory_init ();
|
||||
}
|
||||
|
||||
|
@ -237,15 +239,16 @@ gst_gl_display_finalize (GObject * object)
|
|||
gst_gl_window_set_draw_callback (display->gl_window, NULL, NULL);
|
||||
gst_gl_window_set_close_callback (display->gl_window, NULL, NULL);
|
||||
|
||||
GST_INFO ("send quit gl window loop");
|
||||
if (display->context_created) {
|
||||
GST_INFO ("send quit gl window loop");
|
||||
gst_gl_window_quit (display->gl_window,
|
||||
GST_GL_WINDOW_CB (gst_gl_display_thread_destroy_context), display);
|
||||
|
||||
gst_gl_window_quit (display->gl_window,
|
||||
GST_GL_WINDOW_CB (gst_gl_display_thread_destroy_context), display);
|
||||
GST_INFO ("quit sent to gl window loop");
|
||||
|
||||
GST_INFO ("quit sent to gl window loop");
|
||||
|
||||
g_cond_wait (display->priv->cond_destroy_context, display->mutex);
|
||||
GST_INFO ("quit received from gl window");
|
||||
g_cond_wait (display->priv->cond_destroy_context, display->mutex);
|
||||
GST_INFO ("quit received from gl window");
|
||||
}
|
||||
gst_gl_display_unlock (display);
|
||||
}
|
||||
|
||||
|
@ -438,19 +441,20 @@ gst_gl_display_thread_create_context (GstGLDisplay * display)
|
|||
gst_gl_display_lock (display);
|
||||
|
||||
gl = display->gl_vtable;
|
||||
|
||||
compiled_api = _compiled_api ();
|
||||
|
||||
display->gl_window =
|
||||
gst_gl_window_new (compiled_api, display->external_gl_context, &error);
|
||||
if (!display->gl_window) {
|
||||
gst_gl_display_set_error (display, "Failed to create opengl window");
|
||||
goto failure;
|
||||
}
|
||||
|
||||
if (!display->gl_window || error) {
|
||||
if (!gst_gl_window_create_context (display->gl_window, compiled_api,
|
||||
display->external_gl_context, &error)) {
|
||||
gst_gl_display_set_error (display,
|
||||
error ? error->message : "Failed to create gl window");
|
||||
goto failure;
|
||||
}
|
||||
|
||||
GST_INFO ("gl window created");
|
||||
GST_INFO ("window created context");
|
||||
|
||||
display->gl_api = gst_gl_window_get_gl_api (display->gl_window);
|
||||
g_assert (display->gl_api != GST_GL_API_NONE
|
||||
|
@ -490,6 +494,7 @@ gst_gl_display_thread_create_context (GstGLDisplay * display)
|
|||
ret = _create_context_gles2 (display, &gl_major, NULL);
|
||||
|
||||
if (!ret || !gl_major) {
|
||||
GST_WARNING ("GL api specific initialization failed");
|
||||
goto failure;
|
||||
}
|
||||
|
||||
|
@ -1213,7 +1218,7 @@ gst_gl_display_create_context (GstGLDisplay * display,
|
|||
|
||||
gst_gl_display_lock (display);
|
||||
|
||||
if (!display->gl_window) {
|
||||
if (!display->context_created) {
|
||||
display->external_gl_context = external_gl_context;
|
||||
|
||||
display->gl_thread = g_thread_create (
|
||||
|
|
|
@ -144,6 +144,7 @@ struct _GstGLDisplay
|
|||
GThread *gl_thread;
|
||||
GstGLWindow *gl_window;
|
||||
gboolean isAlive;
|
||||
gboolean context_created;
|
||||
|
||||
/* gl API we are using */
|
||||
GstGLAPI gl_api;
|
||||
|
|
|
@ -66,14 +66,12 @@ gst_gl_window_class_init (GstGLWindowClass * klass)
|
|||
}
|
||||
|
||||
GstGLWindow *
|
||||
gst_gl_window_new (GstGLAPI api, guintptr external_gl_context, GError ** error)
|
||||
gst_gl_window_new (void)
|
||||
{
|
||||
GstGLWindow *window = NULL;
|
||||
const gchar *user_choice;
|
||||
static volatile gsize _init = 0;
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
if (g_once_init_enter (&_init)) {
|
||||
GST_DEBUG_CATEGORY_INIT (gst_gl_window_debug, "glwindow", 0,
|
||||
"glwindow element");
|
||||
|
@ -85,44 +83,29 @@ gst_gl_window_new (GstGLAPI api, guintptr external_gl_context, GError ** error)
|
|||
|
||||
#if GST_GL_HAVE_WINDOW_X11
|
||||
if (!window && (!user_choice || g_strstr_len (user_choice, 3, "x11")))
|
||||
window =
|
||||
GST_GL_WINDOW (gst_gl_window_x11_new (api, external_gl_context, error));
|
||||
window = GST_GL_WINDOW (gst_gl_window_x11_new ());
|
||||
#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 (api, external_gl_context,
|
||||
error));
|
||||
window = GST_GL_WINDOW (gst_gl_window_win32_new ());
|
||||
#endif
|
||||
#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 (api, external_gl_context,
|
||||
error));
|
||||
if (!window && (!user_choice || g_strstr_len (user_choice, 5, "cocoa"))) {
|
||||
window = GST_GL_WINDOW (gst_gl_window_cocoa_new ());
|
||||
}
|
||||
#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 (api,
|
||||
external_gl_context, error));
|
||||
window = GST_GL_WINDOW (gst_gl_window_wayland_egl_new ());
|
||||
#endif
|
||||
if (!window) {
|
||||
if (error && !*error) {
|
||||
if (user_choice) {
|
||||
g_set_error (error, GST_GL_WINDOW_ERROR, GST_GL_WINDOW_ERROR_FAILED,
|
||||
"Could not create %s window", user_choice);
|
||||
} else {
|
||||
/* subclass did not set an error yet returned a NULL window */
|
||||
g_set_error (error, GST_GL_WINDOW_ERROR, GST_GL_WINDOW_ERROR_FAILED,
|
||||
"Could not create %s window, Unknown Error",
|
||||
user_choice ? user_choice : "");
|
||||
}
|
||||
}
|
||||
/* subclass returned a NULL window */
|
||||
GST_WARNING ("Could not create window. user specified %s",
|
||||
user_choice ? user_choice : "(null)");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
window->external_gl_context = external_gl_context;
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
|
@ -346,6 +329,28 @@ gst_gl_window_get_proc_address (GstGLWindow * window, const gchar * name)
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
gst_gl_window_create_context (GstGLWindow * window, GstGLAPI gl_api,
|
||||
guintptr external_gl_context, GError ** error)
|
||||
{
|
||||
gboolean ret;
|
||||
GstGLWindowClass *window_class;
|
||||
|
||||
g_return_val_if_fail (GST_GL_IS_WINDOW (window), FALSE);
|
||||
window_class = GST_GL_WINDOW_GET_CLASS (window);
|
||||
g_return_val_if_fail (window_class->create_context != NULL, FALSE);
|
||||
|
||||
GST_GL_WINDOW_LOCK (window);
|
||||
|
||||
ret =
|
||||
window_class->create_context (window, gl_api, external_gl_context, error);
|
||||
|
||||
GST_GL_WINDOW_UNLOCK (window);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
gpointer
|
||||
gst_gl_window_default_get_proc_address (GstGLWindow * window,
|
||||
const gchar * name)
|
||||
|
|
|
@ -101,6 +101,8 @@ struct _GstGLWindowClass {
|
|||
gpointer (*get_proc_address) (GstGLWindow *window, const gchar *name);
|
||||
gboolean (*activate) (GstGLWindow *window, gboolean activate);
|
||||
void (*set_window_handle) (GstGLWindow *window, guintptr id);
|
||||
gboolean (*create_context) (GstGLWindow *window, GstGLAPI gl_api,
|
||||
guintptr external_gl_context, GError ** error);
|
||||
gboolean (*share_context) (GstGLWindow *window, guintptr external_gl_context);
|
||||
void (*draw_unlocked) (GstGLWindow *window, guint width, guint height);
|
||||
void (*draw) (GstGLWindow *window, guint width, guint height);
|
||||
|
@ -117,7 +119,7 @@ struct _GstGLWindowClass {
|
|||
GQuark gst_gl_window_error_quark (void);
|
||||
GType gst_gl_window_get_type (void);
|
||||
|
||||
GstGLWindow * gst_gl_window_new (GstGLAPI gl_api, guintptr external_gl_context, GError ** error);
|
||||
GstGLWindow * gst_gl_window_new (void);
|
||||
|
||||
void gst_gl_window_set_draw_callback (GstGLWindow *window, GstGLWindowCB callback, gpointer data);
|
||||
void gst_gl_window_set_resize_callback (GstGLWindow *window, GstGLWindowResizeCB callback, gpointer data);
|
||||
|
@ -138,6 +140,9 @@ gpointer gst_gl_window_get_proc_address (GstGLWindow *window, const gchar *
|
|||
GstGLPlatform gst_gl_window_get_platform (GstGLWindow *window);
|
||||
GstGLAPI gst_gl_window_get_gl_api (GstGLWindow *window);
|
||||
|
||||
gboolean gst_gl_window_create_context (GstGLWindow *window, GstGLAPI gl_api,
|
||||
guintptr external_gl_context, GError ** error);
|
||||
|
||||
gpointer gst_gl_window_default_get_proc_address (GstGLWindow *window, const gchar *name);
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (gst_gl_window_debug);
|
||||
|
|
|
@ -51,9 +51,8 @@ static void gst_gl_window_wayland_egl_send_message (GstGLWindow * window,
|
|||
GstGLWindowCB callback, gpointer data);
|
||||
static void gst_gl_window_wayland_egl_destroy_context (GstGLWindowWaylandEGL *
|
||||
window_egl);
|
||||
static gboolean gst_gl_window_wayland_egl_create_context (GstGLWindowWaylandEGL
|
||||
* window_egl, GstGLAPI gl_api, guintptr external_gl_context,
|
||||
GError ** error);
|
||||
static gboolean gst_gl_window_wayland_egl_create_context (GstGLWindow
|
||||
* window, GstGLAPI gl_api, guintptr external_gl_context, GError ** error);
|
||||
static GstGLAPI gst_gl_window_wayland_egl_get_gl_api (GstGLWindow * window);
|
||||
static gpointer gst_gl_window_wayland_egl_get_proc_address (GstGLWindow *
|
||||
window, const gchar * name);
|
||||
|
@ -260,6 +259,8 @@ gst_gl_window_wayland_egl_class_init (GstGLWindowWaylandEGLClass * klass)
|
|||
GObjectClass *object_class = (GObjectClass *) klass;
|
||||
GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
|
||||
|
||||
window_class->create_context =
|
||||
GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_create_context);
|
||||
window_class->get_gl_context =
|
||||
GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_get_gl_context);
|
||||
window_class->activate =
|
||||
|
@ -288,8 +289,7 @@ gst_gl_window_wayland_egl_init (GstGLWindowWaylandEGL * window)
|
|||
|
||||
/* Must be called in the gl thread */
|
||||
GstGLWindowWaylandEGL *
|
||||
gst_gl_window_wayland_egl_new (GstGLAPI gl_api, guintptr external_gl_context,
|
||||
GError ** error)
|
||||
gst_gl_window_wayland_egl_new (void)
|
||||
{
|
||||
GstGLWindowWaylandEGL *window;
|
||||
|
||||
|
@ -299,42 +299,7 @@ gst_gl_window_wayland_egl_new (GstGLAPI gl_api, guintptr external_gl_context,
|
|||
|
||||
gst_gl_window_set_need_lock (GST_GL_WINDOW (window), FALSE);
|
||||
|
||||
window->display.display = wl_display_connect (NULL);
|
||||
if (!window->display.display) {
|
||||
g_set_error (error, GST_GL_WINDOW_ERROR,
|
||||
GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE,
|
||||
"Failed to connect to Wayland display server");
|
||||
goto error;
|
||||
}
|
||||
|
||||
window->display.registry = wl_display_get_registry (window->display.display);
|
||||
wl_registry_add_listener (window->display.registry, ®istry_listener,
|
||||
&window->display);
|
||||
|
||||
wl_display_dispatch (window->display.display);
|
||||
|
||||
create_surface (window);
|
||||
|
||||
window->display.cursor_surface =
|
||||
wl_compositor_create_surface (window->display.compositor);
|
||||
|
||||
window->wl_source = wayland_event_source_new (window->display.display);
|
||||
window->main_context = g_main_context_new ();
|
||||
window->loop = g_main_loop_new (window->main_context, FALSE);
|
||||
|
||||
g_source_attach (window->wl_source, window->main_context);
|
||||
|
||||
gst_gl_window_wayland_egl_create_context (window, gl_api,
|
||||
external_gl_context, error);
|
||||
|
||||
return window;
|
||||
|
||||
error:
|
||||
{
|
||||
if (window)
|
||||
g_object_unref (window);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -367,9 +332,47 @@ gst_gl_window_wayland_egl_finalize (GObject * object)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_window_wayland_egl_create_context (GstGLWindowWaylandEGL * window_egl,
|
||||
_setup_wayland (GstGLWindowWaylandEGL * window_egl, GError ** error)
|
||||
{
|
||||
window_egl->display.display = wl_display_connect (NULL);
|
||||
if (!window_egl->display.display) {
|
||||
g_set_error (error, GST_GL_WINDOW_ERROR,
|
||||
GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE,
|
||||
"Failed to connect to Wayland display server");
|
||||
goto error;
|
||||
}
|
||||
|
||||
window_egl->display.registry =
|
||||
wl_display_get_registry (window_egl->display.display);
|
||||
wl_registry_add_listener (window_egl->display.registry, ®istry_listener,
|
||||
&window_egl->display);
|
||||
|
||||
wl_display_dispatch (window_egl->display.display);
|
||||
|
||||
create_surface (window_egl);
|
||||
|
||||
window_egl->display.cursor_surface =
|
||||
wl_compositor_create_surface (window_egl->display.compositor);
|
||||
|
||||
window_egl->wl_source =
|
||||
wayland_event_source_new (window_egl->display.display);
|
||||
window_egl->main_context = g_main_context_new ();
|
||||
window_egl->loop = g_main_loop_new (window_egl->main_context, FALSE);
|
||||
|
||||
g_source_attach (window_egl->wl_source, window_egl->main_context);
|
||||
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_gl_window_wayland_egl_create_context (GstGLWindow * window,
|
||||
GstGLAPI gl_api, guintptr external_gl_context, GError ** error)
|
||||
{
|
||||
GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
|
||||
|
||||
EGLint config_attrib[] = {
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_RED_SIZE, 1,
|
||||
|
@ -390,6 +393,9 @@ gst_gl_window_wayland_egl_create_context (GstGLWindowWaylandEGL * window_egl,
|
|||
EGLint minorVersion;
|
||||
EGLint numConfigs;
|
||||
|
||||
if (!_setup_wayland (window_egl, error))
|
||||
return FALSE;
|
||||
|
||||
window_egl->egl_display =
|
||||
eglGetDisplay ((EGLNativeDisplayType) window_egl->display.display);
|
||||
|
||||
|
|
|
@ -99,9 +99,7 @@ struct _GstGLWindowWaylandEGLClass {
|
|||
|
||||
GType gst_gl_window_wayland_egl_get_type (void);
|
||||
|
||||
GstGLWindowWaylandEGL * gst_gl_window_wayland_egl_new (GstGLAPI gl_api,
|
||||
guintptr external_gl_context,
|
||||
GError ** error);
|
||||
GstGLWindowWaylandEGL * gst_gl_window_wayland_egl_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#define GST_CAT_DEFAULT gst_gl_window_debug
|
||||
|
||||
#define gst_gl_window_x11_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstGLWindowX11, gst_gl_window_x11, GST_GL_TYPE_WINDOW);
|
||||
G_DEFINE_ABSTRACT_TYPE (GstGLWindowX11, gst_gl_window_x11, GST_GL_TYPE_WINDOW);
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -69,6 +69,8 @@ void gst_gl_window_x11_quit (GstGLWindow * window, GstGLWindowCB callback,
|
|||
gpointer data);
|
||||
void gst_gl_window_x11_send_message (GstGLWindow * window,
|
||||
GstGLWindowCB callback, gpointer data);
|
||||
gboolean gst_gl_window_x11_create_context (GstGLWindow * window,
|
||||
GstGLAPI gl_api, guintptr external_gl_context, GError ** error);
|
||||
|
||||
static gboolean gst_gl_window_x11_create_window (GstGLWindowX11 * window_x11);
|
||||
|
||||
|
@ -187,6 +189,8 @@ gst_gl_window_x11_class_init (GstGLWindowX11Class * klass)
|
|||
g_param_spec_string ("display", "Display", "X Display name", NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
window_class->create_context =
|
||||
GST_DEBUG_FUNCPTR (gst_gl_window_x11_create_context);
|
||||
window_class->get_gl_context =
|
||||
GST_DEBUG_FUNCPTR (gst_gl_window_x11_get_gl_context);
|
||||
window_class->activate = GST_DEBUG_FUNCPTR (gst_gl_window_x11_activate);
|
||||
|
@ -209,51 +213,23 @@ gst_gl_window_x11_init (GstGLWindowX11 * window)
|
|||
|
||||
/* Must be called in the gl thread */
|
||||
GstGLWindowX11 *
|
||||
gst_gl_window_x11_new (GstGLAPI gl_api, guintptr external_gl_context,
|
||||
GError ** error)
|
||||
gst_gl_window_x11_new (void)
|
||||
{
|
||||
GstGLWindowX11 *window = NULL;
|
||||
const gchar *user_choice;
|
||||
|
||||
user_choice = g_getenv ("GST_GL_PLATFORM");
|
||||
|
||||
GST_INFO ("Attempting to create x11 window, user platform choice:%s",
|
||||
user_choice ? user_choice : "(null)");
|
||||
|
||||
#if GST_GL_HAVE_PLATFORM_GLX
|
||||
#if GST_GL_HAVE_PLATFORM_EGL
|
||||
/* try GLX first for Desktop OpenGL */
|
||||
if (gl_api & GST_GL_API_OPENGL || gl_api & GST_GL_API_OPENGL3) {
|
||||
if (!window && (!user_choice
|
||||
|| g_strstr_len (user_choice, 3, "glx") != NULL))
|
||||
window =
|
||||
GST_GL_WINDOW_X11 (gst_gl_window_x11_glx_new (gl_api,
|
||||
external_gl_context, error));
|
||||
if (!window && (!user_choice
|
||||
|| g_strstr_len (user_choice, 3, "egl") != NULL))
|
||||
window =
|
||||
GST_GL_WINDOW_X11 (gst_gl_window_x11_egl_new (gl_api,
|
||||
external_gl_context, error));
|
||||
} else { /* try EGL first for OpenGL|ES */
|
||||
if (!window && (!user_choice
|
||||
|| g_strstr_len (user_choice, 3, "egl") != NULL))
|
||||
window =
|
||||
GST_GL_WINDOW_X11 (gst_gl_window_x11_egl_new (gl_api,
|
||||
external_gl_context, error));
|
||||
if (!window && (!user_choice
|
||||
|| g_strstr_len (user_choice, 3, "glx") != NULL))
|
||||
window =
|
||||
GST_GL_WINDOW_X11 (gst_gl_window_x11_glx_new (gl_api,
|
||||
external_gl_context, error));
|
||||
}
|
||||
#endif /* GST_GL_HAVE_PLATFORM_EGL */
|
||||
if (!window && (!user_choice || g_strstr_len (user_choice, 3, "glx") != NULL))
|
||||
window =
|
||||
GST_GL_WINDOW_X11 (gst_gl_window_x11_glx_new (gl_api,
|
||||
external_gl_context, error));
|
||||
window = GST_GL_WINDOW_X11 (gst_gl_window_x11_glx_new ());
|
||||
#endif /* GST_GL_HAVE_PLATFORM_GLX */
|
||||
#ifdef GST_GL_HAVE_PLATFORM_EGL
|
||||
if (!window && (!user_choice || g_strstr_len (user_choice, 3, "egl") != NULL))
|
||||
window =
|
||||
GST_GL_WINDOW_X11 (gst_gl_window_x11_egl_new (gl_api,
|
||||
external_gl_context, error));
|
||||
window = GST_GL_WINDOW_X11 (gst_gl_window_x11_egl_new ());
|
||||
#endif /* GST_GL_HAVE_PLATFORM_EGL */
|
||||
if (!window) {
|
||||
GST_WARNING ("Failed to create x11 window, user_choice:%s",
|
||||
|
@ -265,17 +241,16 @@ gst_gl_window_x11_new (GstGLAPI gl_api, guintptr external_gl_context,
|
|||
}
|
||||
|
||||
gboolean
|
||||
gst_gl_window_x11_open_device (GstGLWindowX11 * window_x11,
|
||||
gst_gl_window_x11_create_context (GstGLWindow * window,
|
||||
GstGLAPI gl_api, guintptr external_gl_context, GError ** error)
|
||||
{
|
||||
GstGLWindowX11 *window_x11 = GST_GL_WINDOW_X11 (window);
|
||||
GstGLWindowX11Class *window_class = GST_GL_WINDOW_X11_GET_CLASS (window_x11);
|
||||
|
||||
setlocale (LC_NUMERIC, "C");
|
||||
|
||||
gst_gl_window_set_need_lock (GST_GL_WINDOW (window_x11), TRUE);
|
||||
|
||||
GST_GL_WINDOW_LOCK (window_x11);
|
||||
|
||||
g_cond_init (&window_x11->cond_send_message);
|
||||
window_x11->running = TRUE;
|
||||
window_x11->visible = FALSE;
|
||||
|
@ -335,12 +310,9 @@ gst_gl_window_x11_open_device (GstGLWindowX11 * window_x11,
|
|||
goto failure;
|
||||
}
|
||||
|
||||
GST_GL_WINDOW_UNLOCK (window_x11);
|
||||
|
||||
return TRUE;
|
||||
|
||||
failure:
|
||||
GST_GL_WINDOW_UNLOCK (window_x11);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -635,13 +607,13 @@ gst_gl_window_x11_run (GstGLWindow * window)
|
|||
if (window_x11->running) {
|
||||
#if SIZEOF_VOID_P == 8
|
||||
GstGLWindowCB custom_cb =
|
||||
(GstGLWindowCB) (((event.xclient.
|
||||
data.l[0] & 0xffffffff) << 32) | (event.xclient.
|
||||
data.l[1] & 0xffffffff));
|
||||
(GstGLWindowCB) (((event.xclient.data.
|
||||
l[0] & 0xffffffff) << 32) | (event.xclient.data.
|
||||
l[1] & 0xffffffff));
|
||||
gpointer custom_data =
|
||||
(gpointer) (((event.xclient.
|
||||
data.l[2] & 0xffffffff) << 32) | (event.xclient.
|
||||
data.l[3] & 0xffffffff));
|
||||
(gpointer) (((event.xclient.data.
|
||||
l[2] & 0xffffffff) << 32) | (event.xclient.data.
|
||||
l[3] & 0xffffffff));
|
||||
#else
|
||||
GstGLWindowCB custom_cb = (GstGLWindowCB) event.xclient.data.l[0];
|
||||
gpointer custom_data = (gpointer) event.xclient.data.l[1];
|
||||
|
@ -670,13 +642,13 @@ gst_gl_window_x11_run (GstGLWindow * window)
|
|||
&& event.xclient.message_type == wm_quit_loop) {
|
||||
#if SIZEOF_VOID_P == 8
|
||||
GstGLWindowCB destroy_cb =
|
||||
(GstGLWindowCB) (((event.xclient.
|
||||
data.l[0] & 0xffffffff) << 32) | (event.xclient.
|
||||
data.l[1] & 0xffffffff));
|
||||
(GstGLWindowCB) (((event.xclient.data.
|
||||
l[0] & 0xffffffff) << 32) | (event.xclient.data.
|
||||
l[1] & 0xffffffff));
|
||||
gpointer destroy_data =
|
||||
(gpointer) (((event.xclient.
|
||||
data.l[2] & 0xffffffff) << 32) | (event.xclient.
|
||||
data.l[3] & 0xffffffff));
|
||||
(gpointer) (((event.xclient.data.
|
||||
l[2] & 0xffffffff) << 32) | (event.xclient.data.
|
||||
l[3] & 0xffffffff));
|
||||
#else
|
||||
GstGLWindowCB destroy_cb = (GstGLWindowCB) event.xclient.data.l[0];
|
||||
gpointer destroy_data = (gpointer) event.xclient.data.l[1];
|
||||
|
@ -694,13 +666,13 @@ gst_gl_window_x11_run (GstGLWindow * window)
|
|||
&pending_event)) {
|
||||
#if SIZEOF_VOID_P == 8
|
||||
GstGLWindowCB custom_cb =
|
||||
(GstGLWindowCB) (((event.xclient.
|
||||
data.l[0] & 0xffffffff) << 32) | (event.xclient.
|
||||
data.l[1] & 0xffffffff));
|
||||
(GstGLWindowCB) (((event.xclient.data.
|
||||
l[0] & 0xffffffff) << 32) | (event.xclient.data.
|
||||
l[1] & 0xffffffff));
|
||||
gpointer custom_data =
|
||||
(gpointer) (((event.xclient.
|
||||
data.l[2] & 0xffffffff) << 32) | (event.xclient.
|
||||
data.l[3] & 0xffffffff));
|
||||
(gpointer) (((event.xclient.data.
|
||||
l[2] & 0xffffffff) << 32) | (event.xclient.data.
|
||||
l[3] & 0xffffffff));
|
||||
#else
|
||||
GstGLWindowCB custom_cb = (GstGLWindowCB) event.xclient.data.l[0];
|
||||
gpointer custom_data = (gpointer) event.xclient.data.l[1];
|
||||
|
|
|
@ -95,13 +95,7 @@ struct _GstGLWindowX11Class {
|
|||
|
||||
GType gst_gl_window_x11_get_type (void);
|
||||
|
||||
GstGLWindowX11 * gst_gl_window_x11_new (GstGLAPI gl_api,
|
||||
guintptr external_gl_context,
|
||||
GError ** error);
|
||||
gboolean gst_gl_window_x11_open_device (GstGLWindowX11 *window_x11,
|
||||
GstGLAPI gl_api,
|
||||
guintptr external_gl_context,
|
||||
GError ** error);
|
||||
GstGLWindowX11 * gst_gl_window_x11_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -81,14 +81,10 @@ gst_gl_window_x11_egl_init (GstGLWindowX11EGL * window)
|
|||
|
||||
/* Must be called in the gl thread */
|
||||
GstGLWindowX11EGL *
|
||||
gst_gl_window_x11_egl_new (GstGLAPI gl_api, guintptr external_gl_context,
|
||||
GError ** error)
|
||||
gst_gl_window_x11_egl_new (void)
|
||||
{
|
||||
GstGLWindowX11EGL *window = g_object_new (GST_GL_TYPE_WINDOW_X11_EGL, NULL);
|
||||
|
||||
gst_gl_window_x11_open_device (GST_GL_WINDOW_X11 (window), gl_api,
|
||||
external_gl_context, error);
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,9 +61,7 @@ struct _GstGLWindowX11EGLClass {
|
|||
|
||||
GType gst_gl_window_x11_egl_get_type (void);
|
||||
|
||||
GstGLWindowX11EGL * gst_gl_window_x11_egl_new (GstGLAPI gl_api,
|
||||
guintptr external_gl_context,
|
||||
GError ** error);
|
||||
GstGLWindowX11EGL * gst_gl_window_x11_egl_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -81,14 +81,10 @@ gst_gl_window_x11_glx_init (GstGLWindowX11GLX * window)
|
|||
|
||||
/* Must be called in the gl thread */
|
||||
GstGLWindowX11GLX *
|
||||
gst_gl_window_x11_glx_new (GstGLAPI gl_api, guintptr external_gl_context,
|
||||
GError ** error)
|
||||
gst_gl_window_x11_glx_new (void)
|
||||
{
|
||||
GstGLWindowX11GLX *window = g_object_new (GST_GL_TYPE_WINDOW_X11_GLX, NULL);
|
||||
|
||||
gst_gl_window_x11_open_device (GST_GL_WINDOW_X11 (window), gl_api,
|
||||
external_gl_context, error);
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,9 +56,7 @@ struct _GstGLWindowX11GLXClass {
|
|||
|
||||
GType gst_gl_window_x11_glx_get_type (void);
|
||||
|
||||
GstGLWindowX11GLX * gst_gl_window_x11_glx_new (GstGLAPI gl_api,
|
||||
guintptr external_gl_context,
|
||||
GError ** error);
|
||||
GstGLWindowX11GLX * gst_gl_window_x11_glx_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
Loading…
Reference in a new issue