diff options
author | Matthew Waters <ystreet00@gmail.com> | 2013-07-03 14:13:00 +1000 |
---|---|---|
committer | Sebastian Dröge <slomo@circular-chaos.org> | 2013-07-16 14:15:54 +0200 |
commit | b58cc06e76a0bc5f9ed2e64d327401049948c924 (patch) | |
tree | f66452deb2fb8e978e1abe6015abde9a3aa943ed /gst-libs | |
parent | c48b32379a16111833e77e6224fcf8ff7416cd65 (diff) |
memory: copy properly depending on where the most recent data is
Diffstat (limited to 'gst-libs')
-rw-r--r-- | gst-libs/gst/gl/gstglmemory.c | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/gst-libs/gst/gl/gstglmemory.c b/gst-libs/gst/gl/gstglmemory.c index e832994..0cdf8e5 100644 --- a/gst-libs/gst/gl/gstglmemory.c +++ b/gst-libs/gst/gl/gstglmemory.c @@ -22,6 +22,8 @@ #include "config.h" #endif +#include <string.h> + #include <gst/video/video.h> #include "gstglmemory.h" @@ -281,24 +283,33 @@ _gl_mem_copy (GstGLMemory * src, gssize offset, gssize size) GstGLMemory *dest; GstGLMemoryCopyParams copy_params; - copy_params = (GstGLMemoryCopyParams) { - src, 0,}; - - gst_gl_display_thread_add (src->display, _gl_mem_copy_thread, ©_params); - - dest = g_slice_alloc (sizeof (GstGLMemory)); - _gl_mem_init (dest, src->mem.allocator, NULL, src->display, src->v_format, - src->width, src->height, NULL, NULL); - - if (!copy_params.tex_id) - GST_CAT_WARNING (GST_CAT_GL_MEMORY, "Could not copy GL Memory"); - - dest->tex_id = copy_params.tex_id; - dest->data = g_malloc (src->mem.maxsize); - if (dest->data == NULL) { - GST_CAT_WARNING (GST_CAT_GL_MEMORY, "Could not copy GL Memory"); - gst_memory_unref ((GstMemory *) dest); - return NULL; + if (GST_GL_MEMORY_FLAG_IS_SET (src, GST_GL_MEMORY_FLAG_NEED_UPLOAD)) { + dest = _gl_mem_new (src->mem.allocator, NULL, src->display, src->v_format, + src->width, src->height, NULL, NULL); + dest->data = g_malloc (src->mem.maxsize); + memcpy (dest->data, src->data, src->mem.maxsize); + GST_GL_MEMORY_FLAG_SET (dest, GST_GL_MEMORY_FLAG_NEED_UPLOAD); + } else { + copy_params = (GstGLMemoryCopyParams) { + src, 0,}; + + gst_gl_display_thread_add (src->display, _gl_mem_copy_thread, ©_params); + + dest = g_slice_alloc (sizeof (GstGLMemory)); + _gl_mem_init (dest, src->mem.allocator, NULL, src->display, src->v_format, + src->width, src->height, NULL, NULL); + + if (!copy_params.tex_id) + GST_CAT_WARNING (GST_CAT_GL_MEMORY, "Could not copy GL Memory"); + + dest->tex_id = copy_params.tex_id; + dest->data = g_malloc (src->mem.maxsize); + if (dest->data == NULL) { + GST_CAT_WARNING (GST_CAT_GL_MEMORY, "Could not copy GL Memory"); + gst_memory_unref ((GstMemory *) dest); + return NULL; + } + GST_GL_MEMORY_FLAG_SET (dest, GST_GL_MEMORY_FLAG_NEED_DOWNLOAD); } GST_CAT_DEBUG (GST_CAT_GL_MEMORY, "copied texture:%u into texture %u", |