mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 23:36:38 +00:00
gl/window: use the default main loop implementation for all backends
fixes glimagsink being unable to display. https://bugzilla.gnome.org/show_bug.cgi?id=750337
This commit is contained in:
parent
b7808270ca
commit
fbbf1ac324
9 changed files with 21 additions and 529 deletions
|
@ -38,7 +38,6 @@
|
||||||
#define gst_gl_window_android_egl_parent_class parent_class
|
#define gst_gl_window_android_egl_parent_class parent_class
|
||||||
G_DEFINE_TYPE (GstGLWindowAndroidEGL, gst_gl_window_android_egl,
|
G_DEFINE_TYPE (GstGLWindowAndroidEGL, gst_gl_window_android_egl,
|
||||||
GST_GL_TYPE_WINDOW);
|
GST_GL_TYPE_WINDOW);
|
||||||
static void gst_gl_window_android_egl_finalize (GObject * object);
|
|
||||||
|
|
||||||
static guintptr gst_gl_window_android_egl_get_display (GstGLWindow * window);
|
static guintptr gst_gl_window_android_egl_get_display (GstGLWindow * window);
|
||||||
static guintptr gst_gl_window_android_egl_get_window_handle (GstGLWindow *
|
static guintptr gst_gl_window_android_egl_get_window_handle (GstGLWindow *
|
||||||
|
@ -46,19 +45,11 @@ static guintptr gst_gl_window_android_egl_get_window_handle (GstGLWindow *
|
||||||
static void gst_gl_window_android_egl_set_window_handle (GstGLWindow * window,
|
static void gst_gl_window_android_egl_set_window_handle (GstGLWindow * window,
|
||||||
guintptr handle);
|
guintptr handle);
|
||||||
static void gst_gl_window_android_egl_draw (GstGLWindow * window);
|
static void gst_gl_window_android_egl_draw (GstGLWindow * window);
|
||||||
static void gst_gl_window_android_egl_run (GstGLWindow * window);
|
|
||||||
static void gst_gl_window_android_egl_quit (GstGLWindow * window);
|
|
||||||
static void gst_gl_window_android_egl_send_message_async (GstGLWindow * window,
|
|
||||||
GstGLWindowCB callback, gpointer data, GDestroyNotify destroy);
|
|
||||||
static gboolean gst_gl_window_android_egl_open (GstGLWindow * window,
|
|
||||||
GError ** error);
|
|
||||||
static void gst_gl_window_android_egl_close (GstGLWindow * window);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_window_android_egl_class_init (GstGLWindowAndroidEGLClass * klass)
|
gst_gl_window_android_egl_class_init (GstGLWindowAndroidEGLClass * klass)
|
||||||
{
|
{
|
||||||
GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
|
GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
|
||||||
GObjectClass *gobject_class = (GObjectClass *) klass;
|
|
||||||
|
|
||||||
window_class->get_display =
|
window_class->get_display =
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_get_display);
|
GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_get_display);
|
||||||
|
@ -69,32 +60,11 @@ gst_gl_window_android_egl_class_init (GstGLWindowAndroidEGLClass * klass)
|
||||||
window_class->draw_unlocked =
|
window_class->draw_unlocked =
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_draw);
|
GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_draw);
|
||||||
window_class->draw = GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_draw);
|
window_class->draw = GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_draw);
|
||||||
window_class->run = GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_run);
|
|
||||||
window_class->quit = GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_quit);
|
|
||||||
window_class->send_message_async =
|
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_send_message_async);
|
|
||||||
window_class->open = GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_open);
|
|
||||||
window_class->close = GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_close);
|
|
||||||
|
|
||||||
gobject_class->finalize = gst_gl_window_android_egl_finalize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_window_android_egl_init (GstGLWindowAndroidEGL * window)
|
gst_gl_window_android_egl_init (GstGLWindowAndroidEGL * window)
|
||||||
{
|
{
|
||||||
window->main_context = g_main_context_new ();
|
|
||||||
window->loop = g_main_loop_new (window->main_context, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_android_egl_finalize (GObject * object)
|
|
||||||
{
|
|
||||||
GstGLWindowAndroidEGL *window_egl = GST_GL_WINDOW_ANDROID_EGL (object);
|
|
||||||
|
|
||||||
g_main_loop_unref (window_egl->loop);
|
|
||||||
g_main_context_unref (window_egl->main_context);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Must be called in the gl thread */
|
/* Must be called in the gl thread */
|
||||||
|
@ -110,82 +80,6 @@ gst_gl_window_android_egl_new (void)
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_gl_window_android_egl_open (GstGLWindow * window, GError ** error)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_android_egl_close (GstGLWindow * window)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_android_egl_run (GstGLWindow * window)
|
|
||||||
{
|
|
||||||
GstGLWindowAndroidEGL *window_egl;
|
|
||||||
|
|
||||||
window_egl = GST_GL_WINDOW_ANDROID_EGL (window);
|
|
||||||
|
|
||||||
GST_LOG ("starting main loop");
|
|
||||||
g_main_loop_run (window_egl->loop);
|
|
||||||
GST_LOG ("exiting main loop");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_android_egl_quit (GstGLWindow * window)
|
|
||||||
{
|
|
||||||
GstGLWindowAndroidEGL *window_egl;
|
|
||||||
|
|
||||||
window_egl = GST_GL_WINDOW_ANDROID_EGL (window);
|
|
||||||
|
|
||||||
GST_LOG ("sending quit");
|
|
||||||
|
|
||||||
g_main_loop_quit (window_egl->loop);
|
|
||||||
|
|
||||||
GST_LOG ("quit sent");
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct _GstGLMessage
|
|
||||||
{
|
|
||||||
GstGLWindowCB callback;
|
|
||||||
gpointer data;
|
|
||||||
GDestroyNotify destroy;
|
|
||||||
} GstGLMessage;
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
_run_message (GstGLMessage * message)
|
|
||||||
{
|
|
||||||
if (message->callback)
|
|
||||||
message->callback (message->data);
|
|
||||||
|
|
||||||
if (message->destroy)
|
|
||||||
message->destroy (message->data);
|
|
||||||
|
|
||||||
g_slice_free (GstGLMessage, message);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_android_egl_send_message_async (GstGLWindow * window,
|
|
||||||
GstGLWindowCB callback, gpointer data, GDestroyNotify destroy)
|
|
||||||
{
|
|
||||||
GstGLWindowAndroidEGL *window_egl;
|
|
||||||
GstGLMessage *message;
|
|
||||||
|
|
||||||
window_egl = GST_GL_WINDOW_ANDROID_EGL (window);
|
|
||||||
message = g_slice_new (GstGLMessage);
|
|
||||||
|
|
||||||
message->callback = callback;
|
|
||||||
message->data = data;
|
|
||||||
message->destroy = destroy;
|
|
||||||
|
|
||||||
g_main_context_invoke (window_egl->main_context, (GSourceFunc) _run_message,
|
|
||||||
message);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_window_android_egl_set_window_handle (GstGLWindow * window,
|
gst_gl_window_android_egl_set_window_handle (GstGLWindow * window,
|
||||||
guintptr handle)
|
guintptr handle)
|
||||||
|
|
|
@ -44,9 +44,6 @@ struct _GstGLWindowAndroidEGL {
|
||||||
EGLNativeWindowType native_window;
|
EGLNativeWindowType native_window;
|
||||||
gint window_width, window_height;
|
gint window_width, window_height;
|
||||||
|
|
||||||
GMainContext *main_context;
|
|
||||||
GMainLoop *loop;
|
|
||||||
|
|
||||||
gpointer _reserved[GST_PADDING];
|
gpointer _reserved[GST_PADDING];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,6 @@
|
||||||
G_DEFINE_TYPE (GstGLWindowDispmanxEGL, gst_gl_window_dispmanx_egl,
|
G_DEFINE_TYPE (GstGLWindowDispmanxEGL, gst_gl_window_dispmanx_egl,
|
||||||
GST_GL_TYPE_WINDOW);
|
GST_GL_TYPE_WINDOW);
|
||||||
|
|
||||||
static void gst_gl_window_dispmanx_egl_finalize (GObject * object);
|
|
||||||
static guintptr gst_gl_window_dispmanx_egl_get_window_handle (GstGLWindow *
|
static guintptr gst_gl_window_dispmanx_egl_get_window_handle (GstGLWindow *
|
||||||
window);
|
window);
|
||||||
static void gst_gl_window_dispmanx_egl_set_window_handle (GstGLWindow * window,
|
static void gst_gl_window_dispmanx_egl_set_window_handle (GstGLWindow * window,
|
||||||
|
@ -55,10 +54,6 @@ static void gst_gl_window_dispmanx_egl_set_preferred_size (GstGLWindow * window,
|
||||||
gint width, gint height);
|
gint width, gint height);
|
||||||
static void gst_gl_window_dispmanx_egl_show (GstGLWindow * window);
|
static void gst_gl_window_dispmanx_egl_show (GstGLWindow * window);
|
||||||
static void gst_gl_window_dispmanx_egl_draw (GstGLWindow * window);
|
static void gst_gl_window_dispmanx_egl_draw (GstGLWindow * window);
|
||||||
static void gst_gl_window_dispmanx_egl_run (GstGLWindow * window);
|
|
||||||
static void gst_gl_window_dispmanx_egl_quit (GstGLWindow * window);
|
|
||||||
static void gst_gl_window_dispmanx_egl_send_message_async (GstGLWindow * window,
|
|
||||||
GstGLWindowCB callback, gpointer data, GDestroyNotify destroy);
|
|
||||||
static void gst_gl_window_dispmanx_egl_close (GstGLWindow * window);
|
static void gst_gl_window_dispmanx_egl_close (GstGLWindow * window);
|
||||||
static gboolean gst_gl_window_dispmanx_egl_open (GstGLWindow * window,
|
static gboolean gst_gl_window_dispmanx_egl_open (GstGLWindow * window,
|
||||||
GError ** error);
|
GError ** error);
|
||||||
|
@ -72,46 +67,23 @@ static void
|
||||||
gst_gl_window_dispmanx_egl_class_init (GstGLWindowDispmanxEGLClass * klass)
|
gst_gl_window_dispmanx_egl_class_init (GstGLWindowDispmanxEGLClass * klass)
|
||||||
{
|
{
|
||||||
GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
|
GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
|
||||||
GObjectClass *gobject_class = (GObjectClass *) klass;
|
|
||||||
|
|
||||||
window_class->get_window_handle =
|
window_class->get_window_handle =
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_get_window_handle);
|
GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_get_window_handle);
|
||||||
window_class->set_window_handle =
|
window_class->set_window_handle =
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_set_window_handle);
|
GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_set_window_handle);
|
||||||
window_class->show = GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_show);
|
window_class->show = GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_show);
|
||||||
window_class->draw_unlocked =
|
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_draw);
|
|
||||||
window_class->draw = GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_draw);
|
|
||||||
window_class->run = GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_run);
|
|
||||||
window_class->quit = GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_quit);
|
|
||||||
window_class->send_message_async =
|
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_send_message_async);
|
|
||||||
window_class->close = GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_close);
|
window_class->close = GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_close);
|
||||||
window_class->open = GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_open);
|
window_class->open = GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_open);
|
||||||
window_class->get_display =
|
window_class->get_display =
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_get_display);
|
GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_get_display);
|
||||||
window_class->set_preferred_size =
|
window_class->set_preferred_size =
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_set_preferred_size);
|
GST_DEBUG_FUNCPTR (gst_gl_window_dispmanx_egl_set_preferred_size);
|
||||||
|
|
||||||
gobject_class->finalize = gst_gl_window_dispmanx_egl_finalize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_window_dispmanx_egl_init (GstGLWindowDispmanxEGL * window_egl)
|
gst_gl_window_dispmanx_egl_init (GstGLWindowDispmanxEGL * window_egl)
|
||||||
{
|
{
|
||||||
window_egl->main_context = g_main_context_new ();
|
|
||||||
window_egl->loop = g_main_loop_new (window_egl->main_context, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_dispmanx_egl_finalize (GObject * object)
|
|
||||||
{
|
|
||||||
GstGLWindowDispmanxEGL *window_egl = GST_GL_WINDOW_DISPMANX_EGL (object);
|
|
||||||
|
|
||||||
g_main_loop_unref (window_egl->loop);
|
|
||||||
g_main_context_unref (window_egl->main_context);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Must be called in the gl thread */
|
/* Must be called in the gl thread */
|
||||||
|
@ -152,10 +124,7 @@ gst_gl_window_dispmanx_egl_close (GstGLWindow * window)
|
||||||
}
|
}
|
||||||
vc_dispmanx_display_close (window_egl->display);
|
vc_dispmanx_display_close (window_egl->display);
|
||||||
|
|
||||||
g_main_loop_unref (window_egl->loop);
|
GST_GL_WINDOW_CLASS (parent_class)->close (window);
|
||||||
window_egl->loop = NULL;
|
|
||||||
g_main_context_unref (window_egl->main_context);
|
|
||||||
window_egl->main_context = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -165,7 +134,8 @@ gst_gl_window_dispmanx_egl_open (GstGLWindow * window, GError ** error)
|
||||||
gint ret = graphics_get_display_size (0, &window_egl->dp_width,
|
gint ret = graphics_get_display_size (0, &window_egl->dp_width,
|
||||||
&window_egl->dp_height);
|
&window_egl->dp_height);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
GST_ERROR ("Can't open display");
|
g_set_error (GST_GL_WINDOW_ERROR, GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE,
|
||||||
|
"Can't open display");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
GST_DEBUG ("Got display size: %dx%d\n", window_egl->dp_width,
|
GST_DEBUG ("Got display size: %dx%d\n", window_egl->dp_width,
|
||||||
|
@ -173,7 +143,7 @@ gst_gl_window_dispmanx_egl_open (GstGLWindow * window, GError ** error)
|
||||||
|
|
||||||
window_egl->native.element = 0;
|
window_egl->native.element = 0;
|
||||||
|
|
||||||
return TRUE;
|
return GST_GL_WINDOW_CLASS (parent_class)->open (window, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -186,71 +156,6 @@ gst_gl_window_dispmanx_egl_create_window (GstGLWindowDispmanxEGL * window_egl)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_dispmanx_egl_run (GstGLWindow * window)
|
|
||||||
{
|
|
||||||
GstGLWindowDispmanxEGL *window_egl;
|
|
||||||
|
|
||||||
window_egl = GST_GL_WINDOW_DISPMANX_EGL (window);
|
|
||||||
|
|
||||||
GST_LOG ("starting main loop");
|
|
||||||
g_main_loop_run (window_egl->loop);
|
|
||||||
GST_LOG ("exiting main loop");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_dispmanx_egl_quit (GstGLWindow * window)
|
|
||||||
{
|
|
||||||
GstGLWindowDispmanxEGL *window_egl;
|
|
||||||
|
|
||||||
window_egl = GST_GL_WINDOW_DISPMANX_EGL (window);
|
|
||||||
|
|
||||||
GST_LOG ("sending quit");
|
|
||||||
|
|
||||||
g_main_loop_quit (window_egl->loop);
|
|
||||||
|
|
||||||
GST_LOG ("quit sent");
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct _GstGLMessage
|
|
||||||
{
|
|
||||||
GstGLWindowCB callback;
|
|
||||||
gpointer data;
|
|
||||||
GDestroyNotify destroy;
|
|
||||||
} GstGLMessage;
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
_run_message (GstGLMessage * message)
|
|
||||||
{
|
|
||||||
if (message->callback)
|
|
||||||
message->callback (message->data);
|
|
||||||
|
|
||||||
if (message->destroy)
|
|
||||||
message->destroy (message->data);
|
|
||||||
|
|
||||||
g_slice_free (GstGLMessage, message);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_dispmanx_egl_send_message_async (GstGLWindow * window,
|
|
||||||
GstGLWindowCB callback, gpointer data, GDestroyNotify destroy)
|
|
||||||
{
|
|
||||||
GstGLWindowDispmanxEGL *window_egl;
|
|
||||||
GstGLMessage *message;
|
|
||||||
|
|
||||||
window_egl = GST_GL_WINDOW_DISPMANX_EGL (window);
|
|
||||||
message = g_slice_new (GstGLMessage);
|
|
||||||
|
|
||||||
message->callback = callback;
|
|
||||||
message->data = data;
|
|
||||||
message->destroy = destroy;
|
|
||||||
|
|
||||||
g_main_context_invoke (window_egl->main_context, (GSourceFunc) _run_message,
|
|
||||||
message);
|
|
||||||
}
|
|
||||||
|
|
||||||
static guintptr
|
static guintptr
|
||||||
gst_gl_window_dispmanx_egl_get_window_handle (GstGLWindow * window)
|
gst_gl_window_dispmanx_egl_get_window_handle (GstGLWindow * window)
|
||||||
{
|
{
|
||||||
|
@ -332,8 +237,8 @@ window_resize (GstGLWindowDispmanxEGL * window_egl, guint width, guint height,
|
||||||
vc_dispmanx_update_submit_sync (dispman_update);
|
vc_dispmanx_update_submit_sync (dispman_update);
|
||||||
|
|
||||||
if (GST_GL_WINDOW (window_egl)->resize)
|
if (GST_GL_WINDOW (window_egl)->resize)
|
||||||
GST_GL_WINDOW (window_egl)->
|
GST_GL_WINDOW (window_egl)->resize (GST_GL_WINDOW (window_egl)->
|
||||||
resize (GST_GL_WINDOW (window_egl)->resize_data, width, height);
|
resize_data, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
window_egl->native.width = width;
|
window_egl->native.width = width;
|
||||||
|
@ -346,33 +251,12 @@ gst_gl_window_dispmanx_egl_show (GstGLWindow * window)
|
||||||
GstGLWindowDispmanxEGL *window_egl = GST_GL_WINDOW_DISPMANX_EGL (window);
|
GstGLWindowDispmanxEGL *window_egl = GST_GL_WINDOW_DISPMANX_EGL (window);
|
||||||
|
|
||||||
if (!window_egl->visible) {
|
if (!window_egl->visible) {
|
||||||
window_resize (window_egl, window_egl->preferred_width, window_egl->preferred_height, TRUE);
|
window_resize (window_egl, window_egl->preferred_width,
|
||||||
|
window_egl->preferred_height, TRUE);
|
||||||
window_egl->visible = TRUE;
|
window_egl->visible = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
draw_cb (gpointer data)
|
|
||||||
{
|
|
||||||
GstGLWindowDispmanxEGL *window_egl = data;
|
|
||||||
GstGLWindow *window = GST_GL_WINDOW (window_egl);
|
|
||||||
GstGLContext *context = gst_gl_window_get_context (window);
|
|
||||||
GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context);
|
|
||||||
|
|
||||||
if (window->draw)
|
|
||||||
window->draw (window->draw_data);
|
|
||||||
|
|
||||||
context_class->swap_buffers (context);
|
|
||||||
|
|
||||||
gst_object_unref (context);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_dispmanx_egl_draw (GstGLWindow * window)
|
|
||||||
{
|
|
||||||
gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, window);
|
|
||||||
}
|
|
||||||
|
|
||||||
static guintptr
|
static guintptr
|
||||||
gst_gl_window_dispmanx_egl_get_display (GstGLWindow * window)
|
gst_gl_window_dispmanx_egl_get_display (GstGLWindow * window)
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,9 +51,6 @@ struct _GstGLWindowDispmanxEGL {
|
||||||
gint preferred_width;
|
gint preferred_width;
|
||||||
gint preferred_height;
|
gint preferred_height;
|
||||||
|
|
||||||
GMainContext *main_context;
|
|
||||||
GMainLoop *loop;
|
|
||||||
|
|
||||||
gboolean visible;
|
gboolean visible;
|
||||||
|
|
||||||
gpointer _reserved[GST_PADDING];
|
gpointer _reserved[GST_PADDING];
|
||||||
|
|
|
@ -40,7 +40,6 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
||||||
#define gst_gl_window_eagl_parent_class parent_class
|
#define gst_gl_window_eagl_parent_class parent_class
|
||||||
G_DEFINE_TYPE_WITH_CODE (GstGLWindowEagl, gst_gl_window_eagl,
|
G_DEFINE_TYPE_WITH_CODE (GstGLWindowEagl, gst_gl_window_eagl,
|
||||||
GST_GL_TYPE_WINDOW, DEBUG_INIT);
|
GST_GL_TYPE_WINDOW, DEBUG_INIT);
|
||||||
static void gst_gl_window_eagl_finalize (GObject * object);
|
|
||||||
|
|
||||||
static guintptr gst_gl_window_eagl_get_display (GstGLWindow * window);
|
static guintptr gst_gl_window_eagl_get_display (GstGLWindow * window);
|
||||||
static guintptr gst_gl_window_eagl_get_window_handle (GstGLWindow * window);
|
static guintptr gst_gl_window_eagl_get_window_handle (GstGLWindow * window);
|
||||||
|
@ -49,28 +48,18 @@ static void gst_gl_window_eagl_set_window_handle (GstGLWindow * window,
|
||||||
static void gst_gl_window_eagl_set_preferred_size (GstGLWindow * window,
|
static void gst_gl_window_eagl_set_preferred_size (GstGLWindow * window,
|
||||||
gint width, gint height);
|
gint width, gint height);
|
||||||
static void gst_gl_window_eagl_draw (GstGLWindow * window);
|
static void gst_gl_window_eagl_draw (GstGLWindow * window);
|
||||||
static void gst_gl_window_eagl_run (GstGLWindow * window);
|
|
||||||
static void gst_gl_window_eagl_quit (GstGLWindow * window);
|
|
||||||
static void gst_gl_window_eagl_send_message_async (GstGLWindow * window,
|
|
||||||
GstGLWindowCB callback, gpointer data, GDestroyNotify destroy);
|
|
||||||
static gboolean gst_gl_window_eagl_open (GstGLWindow * window, GError ** error);
|
|
||||||
static void gst_gl_window_eagl_close (GstGLWindow * window);
|
|
||||||
|
|
||||||
struct _GstGLWindowEaglPrivate
|
struct _GstGLWindowEaglPrivate
|
||||||
{
|
{
|
||||||
UIView *view;
|
UIView *view;
|
||||||
gint window_width, window_height;
|
gint window_width, window_height;
|
||||||
gint preferred_width, preferred_height;
|
gint preferred_width, preferred_height;
|
||||||
|
|
||||||
GMainContext *main_context;
|
|
||||||
GMainLoop *loop;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_window_eagl_class_init (GstGLWindowEaglClass * klass)
|
gst_gl_window_eagl_class_init (GstGLWindowEaglClass * klass)
|
||||||
{
|
{
|
||||||
GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
|
GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
|
||||||
GObjectClass *gobject_class = (GObjectClass *) klass;
|
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (GstGLWindowEaglPrivate));
|
g_type_class_add_private (klass, sizeof (GstGLWindowEaglPrivate));
|
||||||
|
|
||||||
|
@ -82,16 +71,8 @@ gst_gl_window_eagl_class_init (GstGLWindowEaglClass * klass)
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_eagl_set_window_handle);
|
GST_DEBUG_FUNCPTR (gst_gl_window_eagl_set_window_handle);
|
||||||
window_class->draw_unlocked = GST_DEBUG_FUNCPTR (gst_gl_window_eagl_draw);
|
window_class->draw_unlocked = GST_DEBUG_FUNCPTR (gst_gl_window_eagl_draw);
|
||||||
window_class->draw = GST_DEBUG_FUNCPTR (gst_gl_window_eagl_draw);
|
window_class->draw = GST_DEBUG_FUNCPTR (gst_gl_window_eagl_draw);
|
||||||
window_class->run = GST_DEBUG_FUNCPTR (gst_gl_window_eagl_run);
|
|
||||||
window_class->quit = GST_DEBUG_FUNCPTR (gst_gl_window_eagl_quit);
|
|
||||||
window_class->send_message_async =
|
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_eagl_send_message_async);
|
|
||||||
window_class->open = GST_DEBUG_FUNCPTR (gst_gl_window_eagl_open);
|
|
||||||
window_class->close = GST_DEBUG_FUNCPTR (gst_gl_window_eagl_close);
|
|
||||||
window_class->set_preferred_size =
|
window_class->set_preferred_size =
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_eagl_set_preferred_size);
|
GST_DEBUG_FUNCPTR (gst_gl_window_eagl_set_preferred_size);
|
||||||
|
|
||||||
gobject_class->finalize = gst_gl_window_eagl_finalize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -99,19 +80,6 @@ gst_gl_window_eagl_init (GstGLWindowEagl * window)
|
||||||
{
|
{
|
||||||
window->priv = GST_GL_WINDOW_EAGL_GET_PRIVATE (window);
|
window->priv = GST_GL_WINDOW_EAGL_GET_PRIVATE (window);
|
||||||
|
|
||||||
window->priv->main_context = g_main_context_new ();
|
|
||||||
window->priv->loop = g_main_loop_new (window->priv->main_context, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_eagl_finalize (GObject * object)
|
|
||||||
{
|
|
||||||
GstGLWindowEagl *window_eagl = GST_GL_WINDOW_EAGL (object);
|
|
||||||
|
|
||||||
g_main_loop_unref (window_eagl->priv->loop);
|
|
||||||
g_main_context_unref (window_eagl->priv->main_context);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Must be called in the gl thread */
|
/* Must be called in the gl thread */
|
||||||
|
@ -149,82 +117,6 @@ gst_gl_window_eagl_set_window_handle (GstGLWindow * window, guintptr handle)
|
||||||
gst_gl_context_eagl_update_layer (context);
|
gst_gl_context_eagl_update_layer (context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_gl_window_eagl_open (GstGLWindow * window, GError ** error)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_eagl_close (GstGLWindow * window)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_eagl_run (GstGLWindow * window)
|
|
||||||
{
|
|
||||||
GstGLWindowEagl *window_eagl;
|
|
||||||
|
|
||||||
window_eagl = GST_GL_WINDOW_EAGL (window);
|
|
||||||
|
|
||||||
GST_LOG ("starting main loop");
|
|
||||||
g_main_loop_run (window_eagl->priv->loop);
|
|
||||||
GST_LOG ("exiting main loop");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_eagl_quit (GstGLWindow * window)
|
|
||||||
{
|
|
||||||
GstGLWindowEagl *window_eagl;
|
|
||||||
|
|
||||||
window_eagl = GST_GL_WINDOW_EAGL (window);
|
|
||||||
|
|
||||||
GST_LOG ("sending quit");
|
|
||||||
|
|
||||||
g_main_loop_quit (window_eagl->priv->loop);
|
|
||||||
|
|
||||||
GST_LOG ("quit sent");
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct _GstGLMessage
|
|
||||||
{
|
|
||||||
GstGLWindowCB callback;
|
|
||||||
gpointer data;
|
|
||||||
GDestroyNotify destroy;
|
|
||||||
} GstGLMessage;
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
_run_message (GstGLMessage * message)
|
|
||||||
{
|
|
||||||
if (message->callback)
|
|
||||||
message->callback (message->data);
|
|
||||||
|
|
||||||
if (message->destroy)
|
|
||||||
message->destroy (message->data);
|
|
||||||
|
|
||||||
g_slice_free (GstGLMessage, message);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_eagl_send_message_async (GstGLWindow * window,
|
|
||||||
GstGLWindowCB callback, gpointer data, GDestroyNotify destroy)
|
|
||||||
{
|
|
||||||
GstGLWindowEagl *window_eagl;
|
|
||||||
GstGLMessage *message;
|
|
||||||
|
|
||||||
window_eagl = GST_GL_WINDOW_EAGL (window);
|
|
||||||
message = g_slice_new (GstGLMessage);
|
|
||||||
|
|
||||||
message->callback = callback;
|
|
||||||
message->data = data;
|
|
||||||
message->destroy = destroy;
|
|
||||||
|
|
||||||
g_main_context_invoke (window_eagl->priv->main_context,
|
|
||||||
(GSourceFunc) _run_message, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_window_eagl_set_preferred_size (GstGLWindow * window, gint width, gint height)
|
gst_gl_window_eagl_set_preferred_size (GstGLWindow * window, gint width, gint height)
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,7 +42,6 @@ const gchar *WlEGLErrorString ();
|
||||||
#define gst_gl_window_wayland_egl_parent_class parent_class
|
#define gst_gl_window_wayland_egl_parent_class parent_class
|
||||||
G_DEFINE_TYPE (GstGLWindowWaylandEGL, gst_gl_window_wayland_egl,
|
G_DEFINE_TYPE (GstGLWindowWaylandEGL, gst_gl_window_wayland_egl,
|
||||||
GST_GL_TYPE_WINDOW);
|
GST_GL_TYPE_WINDOW);
|
||||||
static void gst_gl_window_wayland_egl_finalize (GObject * object);
|
|
||||||
|
|
||||||
static guintptr gst_gl_window_wayland_egl_get_window_handle (GstGLWindow *
|
static guintptr gst_gl_window_wayland_egl_get_window_handle (GstGLWindow *
|
||||||
window);
|
window);
|
||||||
|
@ -50,10 +49,6 @@ static void gst_gl_window_wayland_egl_set_window_handle (GstGLWindow * window,
|
||||||
guintptr handle);
|
guintptr handle);
|
||||||
static void gst_gl_window_wayland_egl_show (GstGLWindow * window);
|
static void gst_gl_window_wayland_egl_show (GstGLWindow * window);
|
||||||
static void gst_gl_window_wayland_egl_draw (GstGLWindow * window);
|
static void gst_gl_window_wayland_egl_draw (GstGLWindow * window);
|
||||||
static void gst_gl_window_wayland_egl_run (GstGLWindow * window);
|
|
||||||
static void gst_gl_window_wayland_egl_quit (GstGLWindow * window);
|
|
||||||
static void gst_gl_window_wayland_egl_send_message_async (GstGLWindow * window,
|
|
||||||
GstGLWindowCB callback, gpointer data, GDestroyNotify destroy);
|
|
||||||
static void gst_gl_window_wayland_egl_close (GstGLWindow * window);
|
static void gst_gl_window_wayland_egl_close (GstGLWindow * window);
|
||||||
static gboolean gst_gl_window_wayland_egl_open (GstGLWindow * window,
|
static gboolean gst_gl_window_wayland_egl_open (GstGLWindow * window,
|
||||||
GError ** error);
|
GError ** error);
|
||||||
|
@ -332,7 +327,6 @@ static void
|
||||||
gst_gl_window_wayland_egl_class_init (GstGLWindowWaylandEGLClass * klass)
|
gst_gl_window_wayland_egl_class_init (GstGLWindowWaylandEGLClass * klass)
|
||||||
{
|
{
|
||||||
GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
|
GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
|
||||||
GObjectClass *gobject_class = (GObjectClass *) klass;
|
|
||||||
|
|
||||||
window_class->get_window_handle =
|
window_class->get_window_handle =
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_get_window_handle);
|
GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_get_window_handle);
|
||||||
|
@ -342,36 +336,17 @@ gst_gl_window_wayland_egl_class_init (GstGLWindowWaylandEGLClass * klass)
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_draw);
|
GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_draw);
|
||||||
window_class->show = GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_show);
|
window_class->show = GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_show);
|
||||||
window_class->draw = GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_draw);
|
window_class->draw = GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_draw);
|
||||||
window_class->run = GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_run);
|
|
||||||
window_class->quit = GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_quit);
|
|
||||||
window_class->send_message_async =
|
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_send_message_async);
|
|
||||||
window_class->close = GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_close);
|
window_class->close = GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_close);
|
||||||
window_class->open = GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_open);
|
window_class->open = GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_open);
|
||||||
window_class->get_display =
|
window_class->get_display =
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_get_display);
|
GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_get_display);
|
||||||
window_class->set_render_rectangle =
|
window_class->set_render_rectangle =
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_set_render_rectangle);
|
GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_set_render_rectangle);
|
||||||
|
|
||||||
gobject_class->finalize = gst_gl_window_wayland_egl_finalize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_window_wayland_egl_init (GstGLWindowWaylandEGL * window)
|
gst_gl_window_wayland_egl_init (GstGLWindowWaylandEGL * window)
|
||||||
{
|
{
|
||||||
window->main_context = g_main_context_new ();
|
|
||||||
window->loop = g_main_loop_new (window->main_context, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_wayland_egl_finalize (GObject * object)
|
|
||||||
{
|
|
||||||
GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (object);
|
|
||||||
|
|
||||||
g_main_loop_unref (window_egl->loop);
|
|
||||||
g_main_context_unref (window_egl->main_context);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Must be called in the gl thread */
|
/* Must be called in the gl thread */
|
||||||
|
@ -399,6 +374,8 @@ gst_gl_window_wayland_egl_close (GstGLWindow * window)
|
||||||
g_source_destroy (window_egl->wl_source);
|
g_source_destroy (window_egl->wl_source);
|
||||||
g_source_unref (window_egl->wl_source);
|
g_source_unref (window_egl->wl_source);
|
||||||
window_egl->wl_source = NULL;
|
window_egl->wl_source = NULL;
|
||||||
|
|
||||||
|
GST_GL_WINDOW_CLASS (parent_class)->close (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -419,76 +396,14 @@ gst_gl_window_wayland_egl_open (GstGLWindow * window, GError ** error)
|
||||||
window_egl->wl_source = wayland_event_source_new (display->display,
|
window_egl->wl_source = wayland_event_source_new (display->display,
|
||||||
window_egl->window.queue);
|
window_egl->window.queue);
|
||||||
|
|
||||||
g_source_attach (window_egl->wl_source, window_egl->main_context);
|
if (!GST_GL_WINDOW_CLASS (parent_class)->open (window, error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
g_source_attach (window_egl->wl_source, g_main_context_get_thread_default ());
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_wayland_egl_run (GstGLWindow * window)
|
|
||||||
{
|
|
||||||
GstGLWindowWaylandEGL *window_egl;
|
|
||||||
|
|
||||||
window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
|
|
||||||
|
|
||||||
GST_LOG ("starting main loop");
|
|
||||||
g_main_loop_run (window_egl->loop);
|
|
||||||
GST_LOG ("exiting main loop");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_wayland_egl_quit (GstGLWindow * window)
|
|
||||||
{
|
|
||||||
GstGLWindowWaylandEGL *window_egl;
|
|
||||||
|
|
||||||
window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
|
|
||||||
|
|
||||||
GST_LOG ("sending quit");
|
|
||||||
|
|
||||||
g_main_loop_quit (window_egl->loop);
|
|
||||||
|
|
||||||
GST_LOG ("quit sent");
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct _GstGLMessage
|
|
||||||
{
|
|
||||||
GstGLWindowCB callback;
|
|
||||||
gpointer data;
|
|
||||||
GDestroyNotify destroy;
|
|
||||||
} GstGLMessage;
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
_run_message (GstGLMessage * message)
|
|
||||||
{
|
|
||||||
if (message->callback)
|
|
||||||
message->callback (message->data);
|
|
||||||
|
|
||||||
if (message->destroy)
|
|
||||||
message->destroy (message->data);
|
|
||||||
|
|
||||||
g_slice_free (GstGLMessage, message);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_wayland_egl_send_message_async (GstGLWindow * window,
|
|
||||||
GstGLWindowCB callback, gpointer data, GDestroyNotify destroy)
|
|
||||||
{
|
|
||||||
GstGLWindowWaylandEGL *window_egl;
|
|
||||||
GstGLMessage *message;
|
|
||||||
|
|
||||||
window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
|
|
||||||
message = g_slice_new (GstGLMessage);
|
|
||||||
|
|
||||||
message->callback = callback;
|
|
||||||
message->data = data;
|
|
||||||
message->destroy = destroy;
|
|
||||||
|
|
||||||
g_main_context_invoke (window_egl->main_context, (GSourceFunc) _run_message,
|
|
||||||
message);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_gl_window_wayland_egl_create_window (GstGLWindowWaylandEGL * window_egl)
|
gst_gl_window_wayland_egl_create_window (GstGLWindowWaylandEGL * window_egl)
|
||||||
{
|
{
|
||||||
|
|
|
@ -83,8 +83,6 @@ struct _GstGLWindowWaylandEGL {
|
||||||
struct window window;
|
struct window window;
|
||||||
|
|
||||||
GSource *wl_source;
|
GSource *wl_source;
|
||||||
GMainContext *main_context;
|
|
||||||
GMainLoop *loop;
|
|
||||||
|
|
||||||
gpointer _reserved[GST_PADDING];
|
gpointer _reserved[GST_PADDING];
|
||||||
};
|
};
|
||||||
|
|
|
@ -61,49 +61,21 @@ static void gst_gl_window_win32_set_preferred_size (GstGLWindow * window,
|
||||||
gint width, gint height);
|
gint width, gint height);
|
||||||
static void gst_gl_window_win32_show (GstGLWindow * window);
|
static void gst_gl_window_win32_show (GstGLWindow * window);
|
||||||
static void gst_gl_window_win32_draw (GstGLWindow * window);
|
static void gst_gl_window_win32_draw (GstGLWindow * window);
|
||||||
static void gst_gl_window_win32_run (GstGLWindow * window);
|
|
||||||
static void gst_gl_window_win32_quit (GstGLWindow * window);
|
|
||||||
static void gst_gl_window_win32_send_message_async (GstGLWindow * window,
|
|
||||||
GstGLWindowCB callback, gpointer data, GDestroyNotify destroy);
|
|
||||||
gboolean gst_gl_window_win32_open (GstGLWindow * window, GError ** error);
|
gboolean gst_gl_window_win32_open (GstGLWindow * window, GError ** error);
|
||||||
void gst_gl_window_win32_close (GstGLWindow * window);
|
void gst_gl_window_win32_close (GstGLWindow * window);
|
||||||
static void release_parent_win_id (GstGLWindowWin32 * window_win32);
|
static void release_parent_win_id (GstGLWindowWin32 * window_win32);
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_win32_finalize (GObject * object)
|
|
||||||
{
|
|
||||||
GstGLWindowWin32 *window_win32 = GST_GL_WINDOW_WIN32 (object);
|
|
||||||
|
|
||||||
if (window_win32->loop) {
|
|
||||||
g_main_loop_unref (window_win32->loop);
|
|
||||||
window_win32->loop = NULL;
|
|
||||||
}
|
|
||||||
if (window_win32->main_context) {
|
|
||||||
g_main_context_unref (window_win32->main_context);
|
|
||||||
window_win32->main_context = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_window_win32_class_init (GstGLWindowWin32Class * klass)
|
gst_gl_window_win32_class_init (GstGLWindowWin32Class * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *obj_class = G_OBJECT_CLASS (klass);
|
|
||||||
GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
|
GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (GstGLWindowWin32Private));
|
g_type_class_add_private (klass, sizeof (GstGLWindowWin32Private));
|
||||||
|
|
||||||
obj_class->finalize = gst_gl_window_win32_finalize;
|
|
||||||
|
|
||||||
window_class->set_window_handle =
|
window_class->set_window_handle =
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_win32_set_window_handle);
|
GST_DEBUG_FUNCPTR (gst_gl_window_win32_set_window_handle);
|
||||||
window_class->draw_unlocked = GST_DEBUG_FUNCPTR (gst_gl_window_win32_draw);
|
window_class->draw_unlocked = GST_DEBUG_FUNCPTR (gst_gl_window_win32_draw);
|
||||||
window_class->draw = GST_DEBUG_FUNCPTR (gst_gl_window_win32_draw);
|
window_class->draw = GST_DEBUG_FUNCPTR (gst_gl_window_win32_draw);
|
||||||
window_class->run = GST_DEBUG_FUNCPTR (gst_gl_window_win32_run);
|
|
||||||
window_class->quit = GST_DEBUG_FUNCPTR (gst_gl_window_win32_quit);
|
|
||||||
window_class->send_message_async =
|
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_win32_send_message_async);
|
|
||||||
window_class->get_display =
|
window_class->get_display =
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_win32_get_display);
|
GST_DEBUG_FUNCPTR (gst_gl_window_win32_get_display);
|
||||||
window_class->set_preferred_size =
|
window_class->set_preferred_size =
|
||||||
|
@ -117,12 +89,8 @@ static void
|
||||||
gst_gl_window_win32_init (GstGLWindowWin32 * window)
|
gst_gl_window_win32_init (GstGLWindowWin32 * window)
|
||||||
{
|
{
|
||||||
window->priv = GST_GL_WINDOW_WIN32_GET_PRIVATE (window);
|
window->priv = GST_GL_WINDOW_WIN32_GET_PRIVATE (window);
|
||||||
|
|
||||||
window->main_context = g_main_context_new ();
|
|
||||||
window->loop = g_main_loop_new (window->main_context, FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Must be called in the gl thread */
|
|
||||||
GstGLWindowWin32 *
|
GstGLWindowWin32 *
|
||||||
gst_gl_window_win32_new (void)
|
gst_gl_window_win32_new (void)
|
||||||
{
|
{
|
||||||
|
@ -144,10 +112,14 @@ gst_gl_window_win32_open (GstGLWindow * window, GError ** error)
|
||||||
{
|
{
|
||||||
GstGLWindowWin32 *window_win32 = GST_GL_WINDOW_WIN32 (window);
|
GstGLWindowWin32 *window_win32 = GST_GL_WINDOW_WIN32 (window);
|
||||||
|
|
||||||
|
if (!GST_GL_WINDOW_CLASS (parent_class)->open (window, error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
window_win32->msg_source = win32_message_source_new (window_win32);
|
window_win32->msg_source = win32_message_source_new (window_win32);
|
||||||
g_source_set_callback (window_win32->msg_source, (GSourceFunc) msg_cb,
|
g_source_set_callback (window_win32->msg_source, (GSourceFunc) msg_cb,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
g_source_attach (window_win32->msg_source, window_win32->main_context);
|
g_source_attach (window_win32->msg_source,
|
||||||
|
g_main_context_get_thread_default ());
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -170,6 +142,8 @@ gst_gl_window_win32_close (GstGLWindow * window)
|
||||||
g_source_destroy (window_win32->msg_source);
|
g_source_destroy (window_win32->msg_source);
|
||||||
g_source_unref (window_win32->msg_source);
|
g_source_unref (window_win32->msg_source);
|
||||||
window_win32->msg_source = NULL;
|
window_win32->msg_source = NULL;
|
||||||
|
|
||||||
|
GST_GL_WINDOW_CLASS (parent_class)->close (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -397,63 +371,6 @@ gst_gl_window_win32_draw (GstGLWindow * window)
|
||||||
RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE);
|
RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_window_win32_run (GstGLWindow * window)
|
|
||||||
{
|
|
||||||
GstGLWindowWin32 *window_win32 = GST_GL_WINDOW_WIN32 (window);
|
|
||||||
|
|
||||||
g_main_loop_run (window_win32->loop);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Thread safe */
|
|
||||||
static void
|
|
||||||
gst_gl_window_win32_quit (GstGLWindow * window)
|
|
||||||
{
|
|
||||||
GstGLWindowWin32 *window_win32 = GST_GL_WINDOW_WIN32 (window);
|
|
||||||
|
|
||||||
g_main_loop_quit (window_win32->loop);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct _GstGLMessage
|
|
||||||
{
|
|
||||||
GstGLWindowCB callback;
|
|
||||||
gpointer data;
|
|
||||||
GDestroyNotify destroy;
|
|
||||||
} GstGLMessage;
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
_run_message (GstGLMessage * message)
|
|
||||||
{
|
|
||||||
if (message->callback)
|
|
||||||
message->callback (message->data);
|
|
||||||
|
|
||||||
if (message->destroy)
|
|
||||||
message->destroy (message->data);
|
|
||||||
|
|
||||||
g_slice_free (GstGLMessage, message);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Thread safe */
|
|
||||||
static void
|
|
||||||
gst_gl_window_win32_send_message_async (GstGLWindow * window,
|
|
||||||
GstGLWindowCB callback, gpointer data, GDestroyNotify destroy)
|
|
||||||
{
|
|
||||||
GstGLWindowWin32 *window_win32;
|
|
||||||
GstGLMessage *message;
|
|
||||||
|
|
||||||
window_win32 = GST_GL_WINDOW_WIN32 (window);
|
|
||||||
message = g_slice_new (GstGLMessage);
|
|
||||||
|
|
||||||
message->callback = callback;
|
|
||||||
message->data = data;
|
|
||||||
message->destroy = destroy;
|
|
||||||
|
|
||||||
g_main_context_invoke (window_win32->main_context, (GSourceFunc) _run_message,
|
|
||||||
message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* PRIVATE */
|
/* PRIVATE */
|
||||||
|
|
||||||
LRESULT CALLBACK
|
LRESULT CALLBACK
|
||||||
|
|
|
@ -51,8 +51,6 @@ struct _GstGLWindowWin32 {
|
||||||
gboolean visible;
|
gboolean visible;
|
||||||
|
|
||||||
GSource *msg_source;
|
GSource *msg_source;
|
||||||
GMainContext *main_context;
|
|
||||||
GMainLoop *loop;
|
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
GstGLWindowWin32Private *priv;
|
GstGLWindowWin32Private *priv;
|
||||||
|
|
Loading…
Reference in a new issue