priv->gl_surface = NULL;
}
- if (texture) {
+ if (texture_id) {
if (!priv->foreign_texture)
glDeleteTextures(1, &texture_id);
GST_VAAPI_OBJECT_ID(texture) = 0;
)
{
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;
}
/**
- * 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
*
* 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;
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;