[cogl] cogl-gst: Don't replace previous layers in default shader
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl] cogl-gst: Don't replace previous layers in default shader
- Date: Thu, 25 Apr 2013 19:18:12 +0000 (UTC)
commit f5da8d2caf4b2fbaf6941642a5d5ea7b93d0dd0f
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.
Reviewed-by: Robert Bragg <robert linux intel com>
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 5b17e53..c36111c 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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]