diff options
author | Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com> | 2015-11-26 10:34:12 +0100 |
---|---|---|
committer | Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com> | 2015-11-30 13:26:22 +0100 |
commit | 4897d96945dabf3fa9a222b2d6443904865e34ed (patch) | |
tree | e5474c0d2083c367f739e5b41ed34bcd51eeceb8 /gst-libs/gst/vaapi | |
parent | 1e39b59ce8c45669eb240c36e421771e8d5f7e82 (diff) | |
download | gst-vaapi-4897d96945dabf3fa9a222b2d6443904865e34ed.tar.gz |
texture: detect GL version and use the proper API
When receiving the texture from the application or the video sink, we must
know it size and border. To query the texture the API has changed according to
the OpenGL version used in the GL context of the application/vsink.
This patch checks the current context API type and queries the texture
according to this detected API.
Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
https://bugzilla.gnome.org/show_bug.cgi?id=753099
Diffstat (limited to 'gst-libs/gst/vaapi')
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapitexture_glx.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapitexture_glx.c b/gst-libs/gst/vaapi/gstvaapitexture_glx.c index b9eb81fa..dc931f74 100644 --- a/gst-libs/gst/vaapi/gstvaapitexture_glx.c +++ b/gst-libs/gst/vaapi/gstvaapitexture_glx.c @@ -235,6 +235,21 @@ gst_vaapi_texture_glx_new (GstVaapiDisplay * display, guint target, format, width, height); } +/* Can we assume that the vsink/app context API won't change ever? */ +GstVaapiGLApi +gl_get_curent_api_once () +{ + static GstVaapiGLApi cur_api = GST_VAAPI_GL_API_NONE; + static volatile gsize _init = 0; + + if (g_once_init_enter (&_init)) { + cur_api = gl_get_current_api (NULL, NULL); + g_once_init_leave (&_init, 1); + } + + return cur_api; +} + /** * gst_vaapi_texture_glx_new_wrapped: * @display: a #GstVaapiDisplay @@ -258,23 +273,33 @@ GstVaapiTexture * gst_vaapi_texture_glx_new_wrapped (GstVaapiDisplay * display, guint texture_id, guint target, guint format) { - guint width, height, border_width; - GLTextureState ts; + guint width, height, border_width = 0; + GLTextureState ts = { 0, }; gboolean success; + GstVaapiGLApi gl_api; g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_GLX (display), NULL); g_return_val_if_fail (texture_id != GL_NONE, NULL); g_return_val_if_fail (target == GL_TEXTURE_2D, NULL); g_return_val_if_fail (format == GL_RGBA || format == GL_BGRA, NULL); + gl_api = gl_get_curent_api_once (); + if (gl_api != GST_VAAPI_GL_API_OPENGL && gl_api != GST_VAAPI_GL_API_OPENGL3) + return NULL; + /* Check texture dimensions */ GST_VAAPI_DISPLAY_LOCK (display); - success = gl_bind_texture (&ts, target, texture_id); + if (gl_api == GST_VAAPI_GL_API_OPENGL) + success = gl_bind_texture (&ts, target, texture_id); + else + success = gl3_bind_texture_2d (&ts, target, texture_id); + if (success) { if (!gl_get_texture_param (target, GL_TEXTURE_WIDTH, &width) || - !gl_get_texture_param (target, GL_TEXTURE_HEIGHT, &height) || - !gl_get_texture_param (target, GL_TEXTURE_BORDER, &border_width)) + !gl_get_texture_param (target, GL_TEXTURE_HEIGHT, &height)) success = FALSE; + if (success && gl_api == GST_VAAPI_GL_API_OPENGL) + success = gl_get_texture_param (target, GL_TEXTURE_BORDER, &border_width); gl_unbind_texture (&ts); } GST_VAAPI_DISPLAY_UNLOCK (display); |