From 9fffa2cbc6253fa6810b2dbd7d05fa78abf039f8 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Sun, 11 May 2014 10:27:02 +1000 Subject: [PATCH] gl/upload: update the respective state when we cache textures/data --- gst-libs/gst/gl/gstglupload.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/gl/gstglupload.c b/gst-libs/gst/gl/gstglupload.c index b292c33..adbb723 100644 --- a/gst-libs/gst/gl/gstglupload.c +++ b/gst-libs/gst/gl/gstglupload.c @@ -510,7 +510,10 @@ _gst_gl_upload_perform_for_gl_texture_upload_meta (GstVideoGLTextureUploadMeta * GST_VIDEO_INFO_HEIGHT (&upload->in_info), NULL, NULL);; /* FIXME: kinda breaks the abstraction */ - upload->out_tex->tex_id = texture_id[0]; + if (upload->out_tex->tex_id != texture_id[0]) { + upload->out_tex->tex_id = texture_id[0]; + GST_GL_MEMORY_FLAG_SET (upload->out_tex, GST_GL_MEMORY_FLAG_NEED_DOWNLOAD); + } GST_LOG ("Uploading for meta with textures %i,%i,%i,%i", texture_id[0], texture_id[1], texture_id[2], texture_id[3]); @@ -585,7 +588,10 @@ gst_gl_upload_perform_with_data (GstGLUpload * upload, GLuint texture_id, GST_VIDEO_INFO_HEIGHT (&upload->in_info), NULL, NULL); /* FIXME: kinda breaks the abstraction */ - upload->out_tex->tex_id = texture_id; + if (upload->out_tex->tex_id != texture_id) { + upload->out_tex->tex_id = texture_id; + GST_GL_MEMORY_FLAG_SET (upload->out_tex, GST_GL_MEMORY_FLAG_NEED_DOWNLOAD); + } ret = _gst_gl_upload_perform_with_data_unlocked (upload, texture_id, data); @@ -598,6 +604,8 @@ static gboolean _gst_gl_upload_perform_with_data_unlocked (GstGLUpload * upload, GLuint texture_id, gpointer data[GST_VIDEO_MAX_PLANES]) { + guint i; + g_return_val_if_fail (upload != NULL, FALSE); g_return_val_if_fail (texture_id > 0, FALSE); @@ -605,6 +613,13 @@ _gst_gl_upload_perform_with_data_unlocked (GstGLUpload * upload, gst_gl_memory_setup_wrapped (upload->context, &upload->in_info, data, upload->in_tex); + for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) { + if (upload->in_tex[i] && upload->in_tex[i]->data != data[i]) { + upload->in_tex[i]->data = data[i]; + GST_GL_MEMORY_FLAG_SET (upload->in_tex[i], GST_GL_MEMORY_FLAG_NEED_UPLOAD); + } + } + GST_LOG ("Uploading data into texture %u", texture_id); return _upload_memory (upload); -- 2.7.4