libs: display: egl: add gst_vaapi_display_egl_set_current_display()

Adds a new function that changes the internal EGL display to the
current one (eglGetCurrentDisplay()) and sets the current context
too (eglGetCurrentContext()).

This new function is called by gst_vaapi_texture_egl_create() updating
the GstVaapiDisplayEGL with the current EGL display.

https://bugzilla.gnome.org/show_bug.cgi?id=773453
This commit is contained in:
Víctor Manuel Jáquez Leal 2017-10-10 13:38:21 +02:00
parent 98a136ae2a
commit 429e800204
3 changed files with 28 additions and 14 deletions

View file

@ -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;
}

View file

@ -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;

View file

@ -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,