[cogl/wip/neil/snippets] snippet: Fix detecting the last snippet



commit 6c4c527f10c715d7e594d82eb0f11498d14212a1
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.

 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]