[Cogl] [PATCH 3/4] cogl-gst: Add the global function even for the RGB cap

Neil Roberts neil at linux.intel.com
Tue Feb 26 12:07:38 PST 2013


Previously if the RGB cap was used then CoglGst wouldn't add any
snippets to the pipeline. Although this would work it would mean that
the application can't add it's own snippets which use the sampling
function. To fix that this patch just makes it always add the snippet
if the driver supports GLSL. When using the RGB cap the sampling
function is now just a dummy function that directly returns the texel
from the texture.
---
 cogl-gst/cogl-gst-shader.c     | 6 ++++++
 cogl-gst/cogl-gst-shader.h     | 3 +++
 cogl-gst/cogl-gst-video-sink.c | 9 ++++++++-
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/cogl-gst/cogl-gst-shader.c b/cogl-gst/cogl-gst-shader.c
index d964c72..652b3a8 100644
--- a/cogl-gst/cogl-gst-shader.c
+++ b/cogl-gst/cogl-gst-shader.c
@@ -37,6 +37,12 @@
 #include "cogl-gst-shader.h"
 
 const char
+_cogl_gst_shader_rgba_to_rgba_decl[] =
+  "vec4 cogl_gst_sample_video (vec2 UV) {\n"
+  "  return texture2D (cogl_sampler0, UV);\n"
+  "}";
+
+const char
 _cogl_gst_shader_yv12_to_rgba_decl[] =
   "vec4 cogl_gst_sample_video (vec2 UV) {\n"
   "  float y = 1.1640625 * (texture2D (cogl_sampler0, UV).g - 0.0625);\n"
diff --git a/cogl-gst/cogl-gst-shader.h b/cogl-gst/cogl-gst-shader.h
index e380814..bdf7164 100644
--- a/cogl-gst/cogl-gst-shader.h
+++ b/cogl-gst/cogl-gst-shader.h
@@ -34,6 +34,9 @@
 #define __COGL_GST_SHADER_PRIVATE_H__
 
 extern const char
+_cogl_gst_shader_rgba_to_rgba_decl[];
+
+extern const char
 _cogl_gst_shader_yv12_to_rgba_decl[];
 
 extern const char
diff --git a/cogl-gst/cogl-gst-video-sink.c b/cogl-gst/cogl-gst-video-sink.c
index 61b2e3f..47d87c6 100644
--- a/cogl-gst/cogl-gst-video-sink.c
+++ b/cogl-gst/cogl-gst-video-sink.c
@@ -378,7 +378,14 @@ cogl_gst_dummy_deinit (CoglGstVideoSink *sink)
 static void
 cogl_gst_rgb_init (CoglGstVideoSink *sink)
 {
-  create_template_pipeline (sink, NULL, 1);
+  CoglGstVideoSinkPrivate *priv = sink->priv;
+
+  if (cogl_has_feature (priv->ctx, COGL_FEATURE_ID_GLSL))
+    create_template_pipeline (sink,
+                              _cogl_gst_shader_rgba_to_rgba_decl,
+                              1);
+  else
+    create_template_pipeline (sink, NULL, 1);
 }
 
 static void
-- 
1.7.11.3.g3c3efa5



More information about the Cogl mailing list