libs: texture: egl: update EGL display and context

It is required to use the context of the calling thread when wrapping
a foreign texture. According the documentation of
GstVideoGLTextureUploadMeta:

 "The caller of gst_video_gl_texture_upload_meta_upload() must
  have OpenGL set up and call this from a thread where it is valid
  to upload something to an OpenGL texture."

This patch updates the EGL display and context in GstVaapiDisplay
instance to the one used by te renderer that uploads the texture.

Original-patch-by: Daniel van Vugt <daniel.van.vugt@canonical.com>

https://bugzilla.gnome.org/show_bug.cgi?id=773453
This commit is contained in:
Víctor Manuel Jáquez Leal 2017-10-09 16:02:11 +02:00
parent 8092537763
commit 98a136ae2a

View file

@ -252,9 +252,28 @@ static gboolean
gst_vaapi_texture_egl_create (GstVaapiTextureEGL * texture)
{
CreateTextureArgs args = { texture };
GstVaapiDisplayEGL *display =
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;
}
}
egl_object_replace (&texture->egl_context,
GST_VAAPI_DISPLAY_EGL_CONTEXT (GST_VAAPI_OBJECT_DISPLAY (texture)));
GST_VAAPI_DISPLAY_EGL_CONTEXT (display));
return egl_context_run (texture->egl_context,
(EglContextRunFunc) do_create_texture, &args) && args.success;