Fix texture rendering.
authorgb <gb@5584edef-b1fe-4b99-b61b-dd2bab72e969>
Mon, 29 Mar 2010 12:51:38 +0000 (12:51 +0000)
committergb <gb@5584edef-b1fe-4b99-b61b-dd2bab72e969>
Mon, 29 Mar 2010 12:51:38 +0000 (12:51 +0000)
gst-libs/gst/vaapi/gstvaapitexture.c
gst-libs/gst/vaapi/gstvaapiutils_glx.c
gst-libs/gst/vaapi/gstvaapiutils_glx.h

index 3d69da2..3932fbe 100644 (file)
@@ -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;
index 9669ab2..de6ea3f 100644 (file)
@@ -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;
index ca88b60..1902daa 100644 (file)
@@ -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