[cogl] snippet: Fix detecting the last snippet



commit cdc4bd6361cc1037a31da813f3bb8ee25cef7523
Author: Neil Roberts <neil linux intel com>
Date:   Fri Nov 25 20:59:05 2011 +0000

    snippet: Fix detecting the last snippet
    
    The function for generating the GLSL for a list of snippets was trying
    to detect the last snippet so that it could use a different function
    name. However this wouldn't work if the last snippet has a different
    hook. To fix this it now just counts the snippets that have the same
    hook beforehand and detects the last one using the count.
    
    Reviewed-by: Robert Bragg <robert linux intel com>

 cogl/cogl-pipeline-snippet.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/cogl/cogl-pipeline-snippet.c b/cogl/cogl-pipeline-snippet.c
index 794e163..a5d1340 100644
--- a/cogl/cogl-pipeline-snippet.c
+++ b/cogl/cogl-pipeline-snippet.c
@@ -42,6 +42,13 @@ _cogl_pipeline_snippet_generate_code (const CoglPipelineSnippetData *data)
 {
   CoglPipelineSnippet *snippet;
   int snippet_num = 0;
+  int n_snippets = 0;
+
+  /* First count the number of snippets so we can easily tell when
+     we're at the last one */
+  COGL_LIST_FOREACH (snippet, data->snippets, list_node)
+    if (snippet->snippet->hook == data->hook)
+      n_snippets++;
 
   COGL_LIST_FOREACH (snippet, data->snippets, list_node)
     if (snippet->snippet->hook == data->hook)
@@ -58,7 +65,7 @@ _cogl_pipeline_snippet_generate_code (const CoglPipelineSnippetData *data)
                                 data->return_type :
                                 "void");
 
-        if (COGL_LIST_NEXT (snippet, list_node))
+        if (snippet_num + 1 < n_snippets)
           g_string_append_printf (data->source_buf,
                                   "%s_%i",
                                   data->function_prefix,



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