]> git.sesse.net Git - movit/blobdiff - effect_chain.cpp
Clamp alpha in MixEffect.
[movit] / effect_chain.cpp
index f79c09a478360b5b59aa158ecae0111702ee9e43..8767f7e28a2bdcfa757ae45e8b9ca3bd9f0a6570 100644 (file)
@@ -3,6 +3,7 @@
 #include <stdio.h>
 #include <math.h>
 #include <string.h>
+#include <locale.h>
 #include <assert.h>
 #include <GL/glew.h>
 
@@ -317,7 +318,7 @@ Phase *EffectChain::compile_glsl_program(
 // without any explicit recursion.
 void EffectChain::construct_glsl_programs(Node *output)
 {
-       // Which effects have already been completed in this phase?
+       // Which effects have already been completed?
        // We need to keep track of it, as an effect with multiple outputs
        // could otherwise be calculated multiple times.
        std::set<Node *> completed_effects;
@@ -348,10 +349,13 @@ void EffectChain::construct_glsl_programs(Node *output)
                        // This should currently only happen for effects that are inputs
                        // (either true inputs or phase outputs). We special-case inputs,
                        // and then deduplicate phase outputs in compile_glsl_program().
-                       if (node->effect->num_inputs() == 0 && completed_effects.count(node)) {
-                               continue;
+                       if (node->effect->num_inputs() == 0) {
+                               if (find(this_phase_effects.begin(), this_phase_effects.end(), node) != this_phase_effects.end()) {
+                                       continue;
+                               }
+                       } else {
+                               assert(completed_effects.count(node) == 0);
                        }
-                       assert(completed_effects.count(node) == 0);
 
                        this_phase_effects.push_back(node);
                        completed_effects.insert(node);
@@ -1304,6 +1308,10 @@ Node *EffectChain::find_output_node()
 
 void EffectChain::finalize()
 {
+       // Save the current locale, and set it to C, so that we can output decimal
+       // numbers with printf and be sure to get them in the format mandated by GLSL.
+       char *saved_locale = setlocale(LC_NUMERIC, "C");
+
        // Output the graph as it is before we do any conversions on it.
        output_dot("step0-start.dot");
 
@@ -1396,6 +1404,7 @@ void EffectChain::finalize()
        assert(phases[0]->inputs.empty());
        
        finalized = true;
+       setlocale(LC_NUMERIC, saved_locale);
 }
 
 void EffectChain::render_to_fbo(GLuint dest_fbo, unsigned width, unsigned height)