From 92553103119115bc5b78cea1f3a571dc5e3fbd44 Mon Sep 17 00:00:00 2001 From: gb Date: Mon, 29 Mar 2010 12:51:38 +0000 Subject: [PATCH] Fix texture rendering. --- gst-libs/gst/vaapi/gstvaapitexture.c | 20 ++++++++++++++------ gst-libs/gst/vaapi/gstvaapiutils_glx.c | 9 +++++---- gst-libs/gst/vaapi/gstvaapiutils_glx.h | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapitexture.c b/gst-libs/gst/vaapi/gstvaapitexture.c index 3d69da2..3932fbe 100644 --- a/gst-libs/gst/vaapi/gstvaapitexture.c +++ b/gst-libs/gst/vaapi/gstvaapitexture.c @@ -75,7 +75,7 @@ gst_vaapi_texture_destroy(GstVaapiTexture *texture) priv->gl_surface = NULL; } - if (texture) { + if (texture_id) { if (!priv->foreign_texture) glDeleteTextures(1, &texture_id); GST_VAAPI_OBJECT_ID(texture) = 0; @@ -331,15 +331,23 @@ gst_vaapi_texture_new_with_texture( ) { guint width, height, border_width; + GLTextureState ts; + gboolean success; g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL); /* Check texture dimensions */ - if (!gl_get_texture_param(GL_TEXTURE_WIDTH, &width)) - return NULL; - if (!gl_get_texture_param(GL_TEXTURE_HEIGHT, &height)) - return NULL; - if (!gl_get_texture_param(GL_TEXTURE_BORDER, &border_width)) + GST_VAAPI_DISPLAY_LOCK(display); + success = gl_bind_texture(&ts, target, texture); + 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)) + success = FALSE; + gl_unbind_texture(&ts); + } + GST_VAAPI_DISPLAY_UNLOCK(display); + if (!success) return NULL; width -= 2 * border_width; diff --git a/gst-libs/gst/vaapi/gstvaapiutils_glx.c b/gst-libs/gst/vaapi/gstvaapiutils_glx.c index 9669ab2..de6ea3f 100644 --- a/gst-libs/gst/vaapi/gstvaapiutils_glx.c +++ b/gst-libs/gst/vaapi/gstvaapiutils_glx.c @@ -120,7 +120,8 @@ gl_get_param(GLenum param, guint *pval) } /** - * gl_get_param: + * gl_get_texture_param: + * @target: the target to which the texture is bound * @param: the parameter name * @pval: return location for the value * @@ -130,12 +131,12 @@ gl_get_param(GLenum param, guint *pval) * Return value: %TRUE on success */ gboolean -gl_get_texture_param(GLenum param, guint *pval) +gl_get_texture_param(GLenum target, GLenum param, guint *pval) { GLint val; gl_purge_errors(); - glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, param, &val); + glGetTexLevelParameteriv(target, 0, param, &val); if (gl_check_error()) return FALSE; @@ -250,7 +251,7 @@ gl_bind_texture(GLTextureState *ts, GLenum target, GLuint texture) return FALSE; } - if (ts->was_enabled && gl_get_param(texture_binding, &ts->old_texture) < 0) + if (ts->was_enabled && !gl_get_param(texture_binding, &ts->old_texture)) return FALSE; ts->was_bound = texture == ts->old_texture; diff --git a/gst-libs/gst/vaapi/gstvaapiutils_glx.h b/gst-libs/gst/vaapi/gstvaapiutils_glx.h index ca88b60..1902daa 100644 --- a/gst-libs/gst/vaapi/gstvaapiutils_glx.h +++ b/gst-libs/gst/vaapi/gstvaapiutils_glx.h @@ -43,7 +43,7 @@ gl_get_param(GLenum param, guint *pval) attribute_hidden; gboolean -gl_get_texture_param(GLenum param, guint *pval) +gl_get_texture_param(GLenum target, GLenum param, guint *pval) attribute_hidden; void -- 2.7.4