gl: initial support for texture targets other than GL_TEXTURE_2D
authorAlessandro Decina <alessandro.d@gmail.com>
Tue, 27 Jan 2015 13:13:46 +0000 (00:13 +1100)
committerAlessandro Decina <alessandro.d@gmail.com>
Thu, 29 Jan 2015 13:34:08 +0000 (00:34 +1100)
Make GstGLMemory hold the texture target (tex_target) the texture it represents
(tex_id) is bound to. Modify gst_gl_memory_wrapped_texture and
gst_gl_download_perform_with_data to take the texture target as an argument.

This change is needed to support wrapping textures created outside libgstgl,
which might be bound to a target other than GL_TEXTURE_2D. For example on OSX
textures coming from VideoToolbox have target GL_TEXTURE_RECTANGLE.

With this change we still keep (and sometimes imply) GL_TEXTURE_2D as the
target of textures created with libgstgl.

API: modify GstGLMemory
API: modify gst_gl_memory_wrapped_texture
API: gst_gl_download_perform_with_data

ext/gl/gstglmixer.c

index 5fdcc3d..a122f8f 100644 (file)
@@ -1127,7 +1127,7 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
 {
   guint i;
   GList *walk;
-  guint out_tex;
+  guint out_tex, out_tex_target;
   gboolean res = TRUE;
   guint array_index = 0;
   GstVideoFrame out_frame;
@@ -1153,6 +1153,8 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
 
   if (!to_download) {
     out_tex = *(guint *) out_frame.data[0];
+    out_tex_target =
+        ((GstGLMemory *) gst_buffer_peek_memory (outbuf, 0))->tex_target;
   } else {
     GST_INFO ("Output Buffer does not contain correct memory, "
         "attempting to wrap for download");
@@ -1162,6 +1164,7 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
 
     gst_gl_download_set_format (mix->download, &out_frame.info);
     out_tex = mix->out_tex_id;
+    out_tex_target = GL_TEXTURE_2D;
   }
 
   GST_OBJECT_LOCK (mix);
@@ -1215,8 +1218,8 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
   g_mutex_unlock (&priv->gl_resource_lock);
 
   if (to_download) {
-    if (!gst_gl_download_perform_with_data (mix->download, out_tex,
-            out_frame.data)) {
+    if (!gst_gl_download_perform_with_data (mix->download,
+            out_tex, out_tex_target, out_frame.data)) {
       GST_ELEMENT_ERROR (mix, RESOURCE, NOT_FOUND, ("%s",
               "Failed to download video frame"), (NULL));
       res = FALSE;