gst_gl_window_set_window_handle() problem on Wayland EGL
Submitted by Yuji Kuwabara
Link to original bug (#794614)
Description
In "gstglwindow.c"
void
gst_gl_window_set_window_handle (GstGLWindow * window, guintptr handle)
{
gst_gl_window_send_message_async (window,
(GstGLWindowCB) _set_window_handle_cb, data,
(GDestroyNotify) _free_swh_cb);
}
In "gstglwindow.c"
static void
_set_window_handle_cb (GstSetWindowHandleCb * data)
{
gst_gl_context_activate (context, FALSE);
window_class->set_window_handle (data->window, data->handle);
gst_gl_context_activate (context, TRUE);
}
In "gstglcontext_egl.c"
static gboolean
gst_gl_context_egl_activate (GstGLContext * context, gboolean activate)
{
if (activate) {
/* Check if the backing handle changed */
handle = (EGLNativeWindowType) gst_gl_window_get_window_handle (window);
if (handle && handle != egl->window_handle) {
GST_DEBUG_OBJECT (context,
"Handle changed ",
:
}
result = eglMakeCurrent (egl->egl_display, egl->egl_surface,
egl->egl_surface, egl->egl_context);
}
:
}
NOTE: GstGLContextEGL assumes window handle change.
In "gstglwindow_wayland_egl.c"
static guintptr
gst_gl_window_wayland_egl_get_window_handle (GstGLWindow * window)
{
return (guintptr) GST_GL_WINDOW_WAYLAND_EGL (window)->window.native;
}
NOTE: "window handle" is window.native .
In "gstglwindow_wayland_egl.c"
static void
gst_gl_window_wayland_egl_set_window_handle (GstGLWindow * window,
guintptr handle)
{
destroy_surfaces (window_egl);
window_egl->window.foreign_surface = surface;
create_surfaces (window_egl);
}
NOTE: window.native is destroyed in destroy_surfaces().
create_surfaces() may allocate same id for window.native .
If so, gst_gl_context_egl_activate() cannot detect change.
Modification suggestion:
In "gstglwindow_wayland_egl.c"
static void
gst_gl_window_wayland_egl_set_window_handle (GstGLWindow * window,
guintptr handle)
{
struct wl_egl_window *savewin;
savewin = window_egl->window.native; /* defer destroy window to generate different id */
window_egl->window.native = NULL; /* avoid destroy */
destroy_surfaces (window_egl);
window_egl->window.foreign_surface = surface;
create_surfaces (window_egl);
if (savewin) {
wl_egl_window_destroy (savewin); /* deferred destroy */
}
}
Version: 1.12.4
Edited by Nicolas Dufresne