[Cogl] [PATCH] Fix interleaved snippet generation bug

Plamena Manolova plamena.n.manolova at intel.com
Wed Mar 20 06:45:55 PDT 2013


Having declartion snippets interleaved with either
vertex or fragment ones used to cause a bug during
snippet code generation.
---
 cogl/cogl-pipeline-snippet.c | 161 ++++++++++++++++++++++---------------------
 1 file changed, 82 insertions(+), 79 deletions(-)

diff --git a/cogl/cogl-pipeline-snippet.c b/cogl/cogl-pipeline-snippet.c
index 0e0f620..aea0bbe 100644
--- a/cogl/cogl-pipeline-snippet.c
+++ b/cogl/cogl-pipeline-snippet.c
@@ -63,6 +63,7 @@ _cogl_pipeline_snippet_generate_code (const CoglPipelineSnippetData *data)
           n_snippets++;
       }
 
+
   /* If there weren't any snippets then generate a stub function with
      the final name */
   if (n_snippets == 0)
@@ -94,93 +95,95 @@ _cogl_pipeline_snippet_generate_code (const CoglPipelineSnippetData *data)
                                 data->argument_declarations : "",
                                 data->chain_function,
                                 data->arguments ? data->arguments : "");
-
       return;
     }
 
   for (snippet = first_snippet, snippet_num = 0;
        snippet_num < n_snippets;
-       snippet = COGL_LIST_NEXT (snippet, list_node), snippet_num++)
-    if (snippet->snippet->hook == data->hook)
-      {
-        const char *source;
-
-        if ((source = cogl_snippet_get_declarations (snippet->snippet)))
-          g_string_append (data->source_buf, source);
-
-        g_string_append_printf (data->source_buf,
-                                "\n"
-                                "%s\n",
-                                data->return_type ?
-                                data->return_type :
-                                "void");
-
-        if (snippet_num + 1 < n_snippets)
-          g_string_append_printf (data->source_buf,
-                                  "%s_%i",
-                                  data->function_prefix,
-                                  snippet_num);
-        else
-          g_string_append (data->source_buf, data->final_name);
-
-        g_string_append (data->source_buf, " (");
-
-        if (data->argument_declarations)
-          g_string_append (data->source_buf, data->argument_declarations);
-
-        g_string_append (data->source_buf,
-                         ")\n"
-                         "{\n");
-
-        if (data->return_type && !data->return_variable_is_argument)
-          g_string_append_printf (data->source_buf,
-                                  "  %s %s;\n"
-                                  "\n",
-                                  data->return_type,
-                                  data->return_variable);
-
-        if ((source = cogl_snippet_get_pre (snippet->snippet)))
-          g_string_append (data->source_buf, source);
-
-        /* Chain on to the next function, or bypass it if there is
-           a replace string */
-        if ((source = cogl_snippet_get_replace (snippet->snippet)))
-          g_string_append (data->source_buf, source);
-        else
-          {
-            g_string_append (data->source_buf, "  ");
-
-            if (data->return_type)
-              g_string_append_printf (data->source_buf,
-                                      "%s = ",
-                                      data->return_variable);
-
-            if (snippet_num > 0)
-              g_string_append_printf (data->source_buf,
-                                      "%s_%i",
-                                      data->function_prefix,
-                                      snippet_num - 1);
-            else
-              g_string_append (data->source_buf, data->chain_function);
-
-            g_string_append (data->source_buf, " (");
-
-            if (data->arguments)
-              g_string_append (data->source_buf, data->arguments);
-
-            g_string_append (data->source_buf, ");\n");
-          }
+       snippet = COGL_LIST_NEXT (snippet, list_node))
+    {
+      if (snippet->snippet->hook == data->hook)
+        {
+          const char *source;
 
-        if ((source = cogl_snippet_get_post (snippet->snippet)))
-          g_string_append (data->source_buf, source);
+          if ((source = cogl_snippet_get_declarations (snippet->snippet)))
+            g_string_append (data->source_buf, source);
 
-        if (data->return_type)
           g_string_append_printf (data->source_buf,
-                                  "  return %s;\n",
-                                  data->return_variable);
-
-        g_string_append (data->source_buf, "}\n");
-      }
+                                  "\n"
+                                  "%s\n",
+                                  data->return_type ?
+                                  data->return_type :
+                                  "void");
+
+          if (snippet_num + 1 < n_snippets)
+            g_string_append_printf (data->source_buf,
+                                    "%s_%i",
+                                    data->function_prefix,
+                                    snippet_num);
+          else
+            g_string_append (data->source_buf, data->final_name);
+
+          g_string_append (data->source_buf, " (");
+
+          if (data->argument_declarations)
+            g_string_append (data->source_buf, data->argument_declarations);
+
+          g_string_append (data->source_buf,
+                          ")\n"
+                          "{\n");
+
+          if (data->return_type && !data->return_variable_is_argument)
+            g_string_append_printf (data->source_buf,
+                                    "  %s %s;\n"
+                                    "\n",
+                                    data->return_type,
+                                    data->return_variable);
+
+          if ((source = cogl_snippet_get_pre (snippet->snippet)))
+            g_string_append (data->source_buf, source);
+
+          /* Chain on to the next function, or bypass it if there is
+            a replace string */
+          if ((source = cogl_snippet_get_replace (snippet->snippet)))
+            g_string_append (data->source_buf, source);
+          else
+            {
+              g_string_append (data->source_buf, "  ");
+
+              if (data->return_type)
+                g_string_append_printf (data->source_buf,
+                                        "%s = ",
+                                        data->return_variable);
+
+              if (snippet_num > 0)
+                g_string_append_printf (data->source_buf,
+                                        "%s_%i",
+                                        data->function_prefix,
+                                        snippet_num - 1);
+              else
+                g_string_append (data->source_buf, data->chain_function);
+
+              g_string_append (data->source_buf, " (");
+
+              if (data->arguments)
+                g_string_append (data->source_buf, data->arguments);
+
+              g_string_append (data->source_buf, ");\n");
+            }
+
+          if ((source = cogl_snippet_get_post (snippet->snippet)))
+            g_string_append (data->source_buf, source);
+
+          if (data->return_type)
+            g_string_append_printf (data->source_buf,
+                                    "  return %s;\n",
+                                    data->return_variable);
+
+          g_string_append (data->source_buf, "}\n");
+          snippet_num++;
+        }
+    }
 }
 
 void
-- 
1.8.1.2

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.



More information about the Cogl mailing list