mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
Fix texture rendering.
This commit is contained in:
parent
ab8b90aa59
commit
9255310311
3 changed files with 20 additions and 11 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue