gl/upload: update the respective state when we cache textures/data
authorMatthew Waters <ystreet00@gmail.com>
Sun, 11 May 2014 00:27:02 +0000 (10:27 +1000)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 9 Dec 2017 19:31:40 +0000 (19:31 +0000)
gst-libs/gst/gl/gstglupload.c

index b292c33..adbb723 100644 (file)
@@ -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);