[Cogl] [PATCH 09/15] cogl-gst: Don't replace previous layers in default shader
Lionel Landwerlin
llandwerlin at gmail.com
Sat Jun 22 01:58:53 PDT 2013
From: Neil Roberts <neil at linux.intel.com>
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.
Reviewed-by: Robert Bragg <robert at linux.intel.com>
(cherry picked from commit f5da8d2caf4b2fbaf6941642a5d5ea7b93d0dd0f)
---
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 8b97ef6..a17259a 100644
--- a/cogl-gst/cogl-gst-video-sink.c
+++ b/cogl-gst/cogl-gst-video-sink.c
@@ -226,6 +226,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
@@ -246,16 +247,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,
--
1.8.3.1
More information about the Cogl
mailing list