diff --git a/gst-libs/gst/gl/dispmanx/gstglwindow_dispmanx_egl.c b/gst-libs/gst/gl/dispmanx/gstglwindow_dispmanx_egl.c index f6bfa78dfd..80827b97ed 100644 --- a/gst-libs/gst/gl/dispmanx/gstglwindow_dispmanx_egl.c +++ b/gst-libs/gst/gl/dispmanx/gstglwindow_dispmanx_egl.c @@ -95,6 +95,9 @@ gst_gl_window_dispmanx_egl_init (GstGLWindowDispmanxEGL * window_egl) window_egl->native.element = 0; window_egl->native.width = 0; window_egl->native.height = 0; + window_egl->foreign.element = 0; + window_egl->foreign.width = 0; + window_egl->foreign.height = 0; window_egl->render_rect.x = 0; window_egl->render_rect.y = 0; window_egl->render_rect.w = 0; @@ -122,7 +125,7 @@ gst_gl_window_dispmanx_egl_close (GstGLWindow * window) window_egl = GST_GL_WINDOW_DISPMANX_EGL (window); - if (window_egl->native.element) { + if (window_egl->native.element && window_egl->native.element != window_egl->foreign.element) { dispman_update = vc_dispmanx_update_start (0); vc_dispmanx_element_remove (dispman_update, window_egl->native.element); vc_dispmanx_update_submit_sync (dispman_update); @@ -175,6 +178,21 @@ static void gst_gl_window_dispmanx_egl_set_window_handle (GstGLWindow * window, guintptr handle) { + GstGLWindowDispmanxEGL *window_egl = GST_GL_WINDOW_DISPMANX_EGL (window); + EGL_DISPMANX_WINDOW_T *foreign_window = (EGL_DISPMANX_WINDOW_T *)handle; + DISPMANX_UPDATE_HANDLE_T dispman_update; + + GST_DEBUG_OBJECT (window, "set window handle with size %dx%d", foreign_window->width, foreign_window->height); + + if (window_egl->native.element) { + dispman_update = vc_dispmanx_update_start (0); + vc_dispmanx_element_remove (dispman_update, window_egl->native.element); + vc_dispmanx_update_submit_sync (dispman_update); + } + + window_egl->native.element = window_egl->foreign.element = foreign_window->element; + window_egl->native.width = window_egl->foreign.width = foreign_window->width; + window_egl->native.height = window_egl->foreign.height = foreign_window->height; } static void diff --git a/gst-libs/gst/gl/dispmanx/gstglwindow_dispmanx_egl.h b/gst-libs/gst/gl/dispmanx/gstglwindow_dispmanx_egl.h index f0663e22cd..aa996e779b 100644 --- a/gst-libs/gst/gl/dispmanx/gstglwindow_dispmanx_egl.h +++ b/gst-libs/gst/gl/dispmanx/gstglwindow_dispmanx_egl.h @@ -64,6 +64,7 @@ struct _GstGLWindowDispmanxEGL { uint32_t dp_height; uint32_t dp_width; EGL_DISPMANX_WINDOW_T native; + EGL_DISPMANX_WINDOW_T foreign; gint preferred_width; gint preferred_height;