diff options
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapidisplay_egl.c | 23 | ||||
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapidisplay_egl.h | 3 | ||||
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapitexture_egl.c | 16 |
3 files changed, 28 insertions, 14 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_egl.c b/gst-libs/gst/vaapi/gstvaapidisplay_egl.c index 883257aa..c4fdbc24 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay_egl.c +++ b/gst-libs/gst/vaapi/gstvaapidisplay_egl.c @@ -414,3 +414,26 @@ gst_vaapi_display_egl_set_gl_context (GstVaapiDisplayEGL * display, return ensure_context_is_wrapped (display, gl_context); } + +gboolean +gst_vaapi_display_egl_set_current_display (GstVaapiDisplayEGL * display) +{ + EglDisplay *egl_display; + + g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_EGL (display), FALSE); + + if (G_UNLIKELY (eglGetCurrentDisplay () == EGL_NO_DISPLAY)) + return TRUE; + if (G_LIKELY (display->egl_display->base.handle.p == eglGetCurrentDisplay ())) + return TRUE; + + egl_display = egl_display_new_wrapped (eglGetCurrentDisplay ()); + if (!egl_display) + return FALSE; + egl_object_replace (&display->egl_display, egl_display); + egl_object_unref (egl_display); + if (!gst_vaapi_display_egl_set_gl_context (display, eglGetCurrentContext ())) + return FALSE; + + return TRUE; +} diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_egl.h b/gst-libs/gst/vaapi/gstvaapidisplay_egl.h index 22a80deb..ccabf0f8 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay_egl.h +++ b/gst-libs/gst/vaapi/gstvaapidisplay_egl.h @@ -51,6 +51,9 @@ gboolean gst_vaapi_display_egl_set_gl_context (GstVaapiDisplayEGL * display, EGLContext gl_context); +gboolean +gst_vaapi_display_egl_set_current_display (GstVaapiDisplayEGL * display); + GType gst_vaapi_display_egl_get_type (void) G_GNUC_CONST; diff --git a/gst-libs/gst/vaapi/gstvaapitexture_egl.c b/gst-libs/gst/vaapi/gstvaapitexture_egl.c index c50bb85d..efeced4a 100644 --- a/gst-libs/gst/vaapi/gstvaapitexture_egl.c +++ b/gst-libs/gst/vaapi/gstvaapitexture_egl.c @@ -256,20 +256,8 @@ gst_vaapi_texture_egl_create (GstVaapiTextureEGL * texture) GST_VAAPI_DISPLAY_EGL (GST_VAAPI_OBJECT_DISPLAY (texture)); if (GST_VAAPI_TEXTURE (texture)->is_wrapped) { - if (G_UNLIKELY (display->egl_display->base.handle.p != - eglGetCurrentDisplay ())) { - EglDisplay *current_egl_display = - egl_display_new_wrapped (eglGetCurrentDisplay ()); - if (!current_egl_display) - return FALSE; - - egl_object_replace (&display->egl_display, current_egl_display); - egl_object_unref (current_egl_display); - - if (!gst_vaapi_display_egl_set_gl_context (display, - eglGetCurrentContext ())) - return FALSE; - } + if (!gst_vaapi_display_egl_set_current_display (display)) + return FALSE; } egl_object_replace (&texture->egl_context, |