mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 00:01:23 +00:00
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.
This commit is contained in:
parent
1a6c4be242
commit
e4916fb1ef
4 changed files with 102 additions and 2 deletions
|
@ -1039,6 +1039,9 @@ gst_gl_display_add_context
|
|||
gst_gl_display_get_gl_context_for_thread
|
||||
gst_gl_display_get_handle
|
||||
gst_gl_display_create_context
|
||||
gst_gl_display_create_window
|
||||
gst_gl_display_find_window
|
||||
gst_gl_display_remove_window
|
||||
gst_context_get_gl_display
|
||||
gst_context_set_gl_display
|
||||
<SUBSECTION Standard>
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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__ */
|
||||
|
|
Loading…
Reference in a new issue