summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2017-10-10 13:38:21 +0200
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2017-11-02 11:18:50 +0100
commit429e8002047e341136f834d44dc2a21b4af41dba (patch)
tree8916b4ef23b82fefc9d7012d22cc493763f3f1d6
parent98a136ae2a3b2f12fd37164534680ff27494ca0d (diff)
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
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay_egl.c23
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay_egl.h3
-rw-r--r--gst-libs/gst/vaapi/gstvaapitexture_egl.c16
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,