summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorMatthew Waters <matthew@centricular.com>2016-06-30 23:12:33 +1000
committerMatthew Waters <matthew@centricular.com>2016-11-08 15:14:26 +1100
commite4916fb1ef8e5ecc075978b98f50bd799faf83e0 (patch)
treed867e87c2afc77edba1741400ba308fad3fa3362 /gst-libs
parent1a6c4be242d6d684b03bea6cba339207358faf79 (diff)
gldisplay: add a list of glwindow's
With the event thread on the display, for a particular winsys event we need to be able to retreive the window that the event matches.
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/gl/gstglcontext.c2
-rw-r--r--gst-libs/gst/gl/gstgldisplay.c91
-rw-r--r--gst-libs/gst/gl/gstgldisplay.h8
3 files changed, 99 insertions, 2 deletions
diff --git a/gst-libs/gst/gl/gstglcontext.c b/gst-libs/gst/gl/gstglcontext.c
index 85051ba08..af5b25e9a 100644
--- a/gst-libs/gst/gl/gstglcontext.c
+++ b/gst-libs/gst/gl/gstglcontext.c
@@ -255,7 +255,7 @@ _ensure_window (GstGLContext * context)
if (context->window)
return;
- window = gst_gl_window_new (context->display);
+ window = gst_gl_display_create_window (context->display);
gst_gl_context_set_window (context, window);
diff --git a/gst-libs/gst/gl/gstgldisplay.c b/gst-libs/gst/gl/gstgldisplay.c
index a7ac59625..b96e1b592 100644
--- a/gst-libs/gst/gl/gstgldisplay.c
+++ b/gst-libs/gst/gl/gstgldisplay.c
@@ -98,6 +98,8 @@ static guint gst_gl_display_signals[LAST_SIGNAL] = { 0 };
static void gst_gl_display_dispose (GObject * object);
static void gst_gl_display_finalize (GObject * object);
static guintptr gst_gl_display_default_get_handle (GstGLDisplay * display);
+static GstGLWindow *gst_gl_display_default_create_window (GstGLDisplay *
+ display);
struct _GstGLDisplayPrivate
{
@@ -169,6 +171,7 @@ gst_gl_display_class_init (GstGLDisplayClass * klass)
GST_TYPE_GL_CONTEXT, 1, GST_TYPE_GL_CONTEXT);
klass->get_handle = gst_gl_display_default_get_handle;
+ klass->create_window = gst_gl_display_default_create_window;
G_OBJECT_CLASS (klass)->finalize = gst_gl_display_finalize;
G_OBJECT_CLASS (klass)->dispose = gst_gl_display_dispose;
@@ -512,6 +515,94 @@ gst_gl_display_create_context (GstGLDisplay * display,
return ret;
}
+/**
+ * gst_gl_display_create_window:
+ * @display: a #GstGLDisplay
+ *
+ * It requires the display's object lock to be held.
+ *
+ * Returns: a new #GstGLWindow for @display or %NULL.
+ */
+GstGLWindow *
+gst_gl_display_create_window (GstGLDisplay * display)
+{
+ GstGLDisplayClass *klass;
+ GstGLWindow *window;
+
+ g_return_val_if_fail (GST_IS_GL_DISPLAY (display), NULL);
+ klass = GST_GL_DISPLAY_GET_CLASS (display);
+ g_return_val_if_fail (klass->create_window != NULL, NULL);
+
+ window = klass->create_window (display);
+
+ if (window)
+ display->windows = g_list_prepend (display->windows, window);
+
+ return window;
+}
+
+static GstGLWindow *
+gst_gl_display_default_create_window (GstGLDisplay * display)
+{
+ return gst_gl_window_new (display);
+}
+
+/**
+ * gst_gl_display_remove_window:
+ * @display: a #GstGLDisplay
+ * @window: a #GstGLWindow to remove
+ *
+ * Returns: if @window could be removed from @display
+ *
+ * Since: 1.12
+ */
+gboolean
+gst_gl_display_remove_window (GstGLDisplay * display, GstGLWindow * window)
+{
+ gboolean ret = FALSE;
+ GList *l;
+
+ GST_OBJECT_LOCK (display);
+ l = g_list_find (display->windows, window);
+ if (l) {
+ display->windows = g_list_delete_link (display->windows, l);
+ ret = TRUE;
+ }
+ GST_OBJECT_UNLOCK (display);
+
+ return ret;
+}
+
+/**
+ * gst_gl_display_find_window:
+ * @display: a #GstGLDisplay
+ * @data: some data to pass to @compare_func
+ * @compare_func: a comparison function to run
+ *
+ * Execute @compare_func over the list of windows stored by @display. The
+ * first argment to @compare_func is the #GstGLWindow being checked and the
+ * second argument is @data.
+ *
+ * Returns: The first #GstGLWindow that causes a match from @compare_func
+ *
+ * Since: 1.12
+ */
+GstGLWindow *
+gst_gl_display_find_window (GstGLDisplay * display, gpointer data,
+ GCompareFunc compare_func)
+{
+ GstGLWindow *ret = NULL;
+ GList *l;
+
+ GST_OBJECT_LOCK (display);
+ l = g_list_find_custom (display->windows, data, compare_func);
+ if (l)
+ ret = l->data;
+ GST_OBJECT_UNLOCK (display);
+
+ return ret;
+}
+
static GstGLContext *
_get_gl_context_for_thread_unlocked (GstGLDisplay * display, GThread * thread)
{
diff --git a/gst-libs/gst/gl/gstgldisplay.h b/gst-libs/gst/gl/gstgldisplay.h
index 5428a8e3f..5c0cc9ea1 100644
--- a/gst-libs/gst/gl/gstgldisplay.h
+++ b/gst-libs/gst/gl/gstgldisplay.h
@@ -79,6 +79,7 @@ struct _GstGLDisplay
GstGLDisplayType type;
/* <protected> */
+ GList *windows; /* OBJECT lock */
GMainContext *main_context;
GMainLoop *main_loop;
GSource *event_source;
@@ -90,7 +91,8 @@ struct _GstGLDisplayClass
{
GstObjectClass object_class;
- guintptr (*get_handle) (GstGLDisplay * display);
+ guintptr (*get_handle) (GstGLDisplay * display);
+ GstGLWindow * (*create_window) (GstGLDisplay * display);
/* <private> */
gpointer _padding[GST_PADDING];
@@ -130,6 +132,10 @@ GST_EXPORT
gboolean gst_gl_display_add_context (GstGLDisplay * display,
GstGLContext * context);
+GstGLWindow * gst_gl_display_create_window (GstGLDisplay * display);
+gboolean gst_gl_display_remove_window (GstGLDisplay * display, GstGLWindow * window);
+GstGLWindow * gst_gl_display_find_window (GstGLDisplay * display, gpointer data, GCompareFunc compar_func);
+
G_END_DECLS
#endif /* __GST_GL_DISPLAY_H__ */