summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.com>2021-07-22 17:02:51 -0400
committerNicolas Dufresne <nicolas.dufresne@collabora.com>2021-07-23 13:44:11 -0400
commitefa6d1c2f8f3d8905f021cfaa43c6d1fe7e1f6fe (patch)
tree0300130dfd35e64b1aa8413931ae20ce5a5014e7
parentf72b3cf19997425418c6d2fe93ca8df9119a3052 (diff)
downloadgstreamer-plugins-base-efa6d1c2f8f3d8905f021cfaa43c6d1fe7e1f6fe.tar.gz
glwindow: Add "window-handle-changed" signal
This allow other objects to clear any wrapper object that depends on the previous handle, and properly re-create the new wrappers without having to resort into doing pointer comparison. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1231>
-rw-r--r--gst-libs/gst/gl/gstglwindow.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gst-libs/gst/gl/gstglwindow.c b/gst-libs/gst/gl/gstglwindow.c
index 419ce177c..6d4e3fb38 100644
--- a/gst-libs/gst/gl/gstglwindow.c
+++ b/gst-libs/gst/gl/gstglwindow.c
@@ -127,6 +127,7 @@ enum
EVENT_MOUSE_SIGNAL,
EVENT_KEY_SIGNAL,
EVENT_SCROLL_SIGNAL,
+ WINDOW_HANDLE_CHANGED_SIGNAL,
LAST_SIGNAL
};
@@ -253,6 +254,22 @@ gst_gl_window_class_init (GstGLWindowClass * klass)
G_TYPE_NONE, 4, G_TYPE_DOUBLE, G_TYPE_DOUBLE, G_TYPE_DOUBLE,
G_TYPE_DOUBLE);
+ /**
+ * GstGLWindow::window-handle-changed:
+ * @object: the #GstGLWindow
+ *
+ * Will be emitted when the window handle has been set into the native
+ * implementation, but before the context is re-activated. By using this
+ * signal, elements can refresh associated resource without relying on
+ * direct handle comparision.
+ *
+ * Since: 1.20
+ */
+ gst_gl_window_signals[WINDOW_HANDLE_CHANGED_SIGNAL] =
+ g_signal_new ("window-handle_changed", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_generic,
+ G_TYPE_NONE, 0);
+
_init_debug ();
}
@@ -381,6 +398,12 @@ _set_window_handle_cb (GstSetWindowHandleCb * data)
window_class->set_window_handle (data->window, data->handle);
+ /* Let's assume users don't call this without a new handle, this is the
+ * safest since we don't know the nature of the handle and direct
+ * comparision might not be safe */
+ g_signal_emit (data->window,
+ gst_gl_window_signals[WINDOW_HANDLE_CHANGED_SIGNAL], 0, NULL);
+
/* reactivate */
if (context && thread)
gst_gl_context_activate (context, TRUE);