[cogl/wip/cogl-gst-1.x] cogl-gst: Don't replace previous layers in default shader



commit a8ae539a9cc1688a2b696f1a8b576022617771f2
Author: Neil Roberts <neil linux intel com>
Date:   Wed Apr 10 13:45:42 2013 +0100

    cogl-gst: Don't replace previous layers in default shader
    
    Previously, when CoglGST generated the default sampling snippet it
    would set the replace string so that Cogl wouldn't generate any
    redundant code for the other layers. However this also meant that it
    wouldn't modulate with the default colour. This patch changes it to
    set the combine mode on all of the layers to REPLACE(PREVIOUS) so that
    it just copies the previous layer without generating any texture
    sampling. That way the fragment snippet for the final layer can just
    modulate the previous value with the video sampling function. This
    makes it possible to set a color on the pipeline and have it modulate
    the video. Also if we eventually add a way to insert layers before the
    GST sampling layer then it can modulate with those.

 cogl-gst/cogl-gst-shader.c     |    2 +-
 cogl-gst/cogl-gst-video-sink.c |   20 +++++++++++++-------
 2 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/cogl-gst/cogl-gst-shader.c b/cogl-gst/cogl-gst-shader.c
index 49d4671..7c34376 100644
--- a/cogl-gst/cogl-gst-shader.c
+++ b/cogl-gst/cogl-gst-shader.c
@@ -78,4 +78,4 @@ _cogl_gst_shader_ayuv_to_rgba_decl[] =
 
 const char
 _cogl_gst_shader_default_sample[] =
-  "  cogl_layer = cogl_gst_sample_video (cogl_tex_coord0_in.st);\n";
+  "  cogl_layer *= cogl_gst_sample_video (cogl_tex_coord0_in.st);\n";
diff --git a/cogl-gst/cogl-gst-video-sink.c b/cogl-gst/cogl-gst-video-sink.c
index 07601ed..a121b11 100644
--- a/cogl-gst/cogl-gst-video-sink.c
+++ b/cogl-gst/cogl-gst-video-sink.c
@@ -229,6 +229,7 @@ create_template_pipeline (CoglGstVideoSink *sink,
   if (decl)
     {
       static CoglSnippet *default_sample_snippet = NULL;
+      int i;
 
       /* The global sampling function gets added to both the fragment
        * and vertex stages. The hope is that the GLSL compiler will
@@ -249,16 +250,21 @@ create_template_pipeline (CoglGstVideoSink *sink,
       cogl_pipeline_add_snippet (priv->pipeline,
                                  snippet_cache->fragment_snippet);
 
-      /* Set the replace string for the last layer so that no
-       * redundant code for the previous layers will be generated. The
-       * application can also replace this default sampling by adding
-       * another layer */
+      /* Set all of the layers to just directly copy from the previous
+       * layer so that it won't redundantly generate code to sample
+       * the intermediate textures */
+      for (i = 0; i < n_layers; i++)
+        cogl_pipeline_set_layer_combine (priv->pipeline,
+                                         i,
+                                         "RGBA=REPLACE(PREVIOUS)",
+                                         NULL);
+
       if (default_sample_snippet == NULL)
         {
           default_sample_snippet =
-            cogl_snippet_new (COGL_SNIPPET_HOOK_LAYER_FRAGMENT, NULL, NULL);
-          cogl_snippet_set_replace (default_sample_snippet,
-                                    _cogl_gst_shader_default_sample);
+            cogl_snippet_new (COGL_SNIPPET_HOOK_LAYER_FRAGMENT,
+                              NULL, /* declarations */
+                              _cogl_gst_shader_default_sample);
         }
       cogl_pipeline_add_layer_snippet (priv->pipeline,
                                        n_layers - 1,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]