]> git.sesse.net Git - movit/commitdiff
Split out some private utilities into effect_util.cpp, so we do not need to include...
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 2 Feb 2013 13:32:01 +0000 (14:32 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 2 Feb 2013 13:32:01 +0000 (14:32 +0100)
22 files changed:
Makefile
blur_effect.cpp
colorspace_conversion_effect.h
deconvolution_sharpen_effect.cpp
dither_effect.cpp
effect.cpp
effect.h
effect_chain.h
effect_chain_test.cpp
effect_util.cpp [new file with mode: 0644]
effect_util.h [new file with mode: 0644]
flat_input.cpp
gamma_compression_effect.h
gamma_expansion_effect.h
lift_gamma_gain_effect.cpp
padding_effect.cpp
resample_effect.cpp
test_util.cpp
util.cpp
vignette_effect.cpp
white_balance_effect.cpp
ycbcr_input.cpp

index cea223443588a324ef701b8d601dace68250d3af..0d36c7ee91b36c375b78080086708d6b49b8fadf 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -62,7 +62,7 @@ TESTS += flat_input_test
 TESTS += ycbcr_input_test
 
 # Core.
 TESTS += ycbcr_input_test
 
 # Core.
-LIB_OBJS=util.o widgets.o effect.o effect_chain.o init.o
+LIB_OBJS=effect_util.o util.o widgets.o effect.o effect_chain.o init.o
 
 # Inputs.
 LIB_OBJS += flat_input.o
 
 # Inputs.
 LIB_OBJS += flat_input.o
index a74cd41b0cd63bca7d37150d07ecfbee822ce563..0ec1b1dc857fbec5dbb30568d30058ebb274841b 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "blur_effect.h"
 #include "effect_chain.h"
 
 #include "blur_effect.h"
 #include "effect_chain.h"
+#include "effect_util.h"
 #include "util.h"
 
 // Must match blur_effect.frag.
 #include "util.h"
 
 // Must match blur_effect.frag.
index b1d6e060c75d5dee627425fad05b410c46563065..93b1859376966138ecbf76b6f69439df47c3c48c 100644 (file)
@@ -11,7 +11,6 @@
 #include <string>
 
 #include "effect.h"
 #include <string>
 
 #include "effect.h"
-#include "effect_chain.h"
 #include "image_format.h"
 
 class ColorspaceConversionEffect : public Effect {
 #include "image_format.h"
 
 class ColorspaceConversionEffect : public Effect {
index 260266403852a2beb22232e29924d4c25a873b2d..f3998d918e310ff523600252e2f037740d31846c 100644 (file)
@@ -13,6 +13,7 @@
 #include <new>
 
 #include "deconvolution_sharpen_effect.h"
 #include <new>
 
 #include "deconvolution_sharpen_effect.h"
+#include "effect_util.h"
 #include "util.h"
 
 using namespace Eigen;
 #include "util.h"
 
 using namespace Eigen;
index 44933b61cc4363470762daa05882301e1043fed2..1554356213ee1ec13815fd0c5581140010d15d74 100644 (file)
@@ -3,6 +3,7 @@
 #include <algorithm>
 
 #include "dither_effect.h"
 #include <algorithm>
 
 #include "dither_effect.h"
+#include "effect_util.h"
 #include "util.h"
 
 namespace {
 #include "util.h"
 
 namespace {
index 0fe09db0b2e3f14ccf1372e01a67680491e2a0e8..483828bda88fcabb03b1da4ec23946f4ccab274e 100644 (file)
@@ -1,4 +1,3 @@
-#include <Eigen/Core>
 #include <GL/glew.h>
 #include <assert.h>
 #include <stdio.h>
 #include <GL/glew.h>
 #include <assert.h>
 #include <stdio.h>
@@ -6,100 +5,9 @@
 #include <utility>
 
 #include "effect.h"
 #include <utility>
 
 #include "effect.h"
+#include "effect_util.h"
 #include "util.h"
 
 #include "util.h"
 
-GLint get_uniform_location(GLuint glsl_program_num, const std::string &prefix, const std::string &key)
-{
-       std::string name = prefix + "_" + key;
-       return glGetUniformLocation(glsl_program_num, name.c_str());
-}
-
-void set_uniform_int(GLuint glsl_program_num, const std::string &prefix, const std::string &key, int value)
-{
-       GLint location = get_uniform_location(glsl_program_num, prefix, key);
-       if (location == -1) {
-               return;
-       }
-       check_error();
-       glUniform1i(location, value);
-       check_error();
-}
-
-void set_uniform_float(GLuint glsl_program_num, const std::string &prefix, const std::string &key, float value)
-{
-       GLint location = get_uniform_location(glsl_program_num, prefix, key);
-       if (location == -1) {
-               return;
-       }
-       check_error();
-       glUniform1f(location, value);
-       check_error();
-}
-
-void set_uniform_vec2(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values)
-{
-       GLint location = get_uniform_location(glsl_program_num, prefix, key);
-       if (location == -1) {
-               return;
-       }
-       check_error();
-       glUniform2fv(location, 1, values);
-       check_error();
-}
-
-void set_uniform_vec3(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values)
-{
-       GLint location = get_uniform_location(glsl_program_num, prefix, key);
-       if (location == -1) {
-               return;
-       }
-       check_error();
-       glUniform3fv(location, 1, values);
-       check_error();
-}
-
-void set_uniform_vec4(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values)
-{
-       GLint location = get_uniform_location(glsl_program_num, prefix, key);
-       if (location == -1) {
-               return;
-       }
-       check_error();
-       glUniform4fv(location, 1, values);
-       check_error();
-}
-
-void set_uniform_vec4_array(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values, size_t num_values)
-{
-       GLint location = get_uniform_location(glsl_program_num, prefix, key);
-       if (location == -1) {
-               return;
-       }
-       check_error();
-       glUniform4fv(location, num_values, values);
-       check_error();
-}
-
-void set_uniform_mat3(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const Eigen::Matrix3d& matrix)
-{
-       GLint location = get_uniform_location(glsl_program_num, prefix, key);
-       if (location == -1) {
-               return;
-       }
-       check_error();
-
-       // Convert to float (GLSL has no double matrices).
-       float matrixf[9];
-       for (unsigned y = 0; y < 3; ++y) {
-               for (unsigned x = 0; x < 3; ++x) {
-                       matrixf[y + x * 3] = matrix(y, x);
-               }
-       }
-
-       glUniformMatrix3fv(location, 1, GL_FALSE, matrixf);
-       check_error();
-}
-
 bool Effect::set_int(const std::string &key, int value)
 {
        if (params_int.count(key) == 0) {
 bool Effect::set_int(const std::string &key, int value)
 {
        if (params_int.count(key) == 0) {
index 826dd6f24068c4aa23687f6071568b43356c1cd3..65fdf522af305491ca8e6abb594355aae9934e15 100644 (file)
--- a/effect.h
+++ b/effect.h
 #include <GL/glew.h>
 #include <assert.h>
 #include <stddef.h>
 #include <GL/glew.h>
 #include <assert.h>
 #include <stddef.h>
-#include <Eigen/Core>
 #include <map>
 #include <string>
 #include <map>
 #include <string>
-#include <vector>
 
 #include "util.h"
 
 
 #include "util.h"
 
@@ -47,16 +45,6 @@ struct RGBATriplet {
        float r, g, b, a;
 };
 
        float r, g, b, a;
 };
 
-// Convenience functions that deal with prepending the prefix.
-GLint get_uniform_location(GLuint glsl_program_num, const std::string &prefix, const std::string &key);
-void set_uniform_int(GLuint glsl_program_num, const std::string &prefix, const std::string &key, int value);
-void set_uniform_float(GLuint glsl_program_num, const std::string &prefix, const std::string &key, float value);
-void set_uniform_vec2(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values);
-void set_uniform_vec3(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values);
-void set_uniform_vec4(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values);
-void set_uniform_vec4_array(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values, size_t num_values);
-void set_uniform_mat3(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const Eigen::Matrix3d &matrix);
-
 class Effect {
 public:
        virtual ~Effect() {}
 class Effect {
 public:
        virtual ~Effect() {}
index 2199a5d8b28d56a1a0fe54c85cc2ae9505ede61d..ddabad959bb292b7798af46e69c6869ccca1c1c5 100644 (file)
@@ -8,12 +8,9 @@
 #include <string>
 #include <vector>
 
 #include <string>
 #include <vector>
 
-#include "effect.h"
 #include "image_format.h"
 #include "image_format.h"
-#include "input.h"
 
 class Effect;
 
 class Effect;
-class EffectChain;
 class Input;
 struct Phase;
 
 class Input;
 struct Phase;
 
index 49d431b98db0a067e01076ae5e2f1fcd0550c82c..442c2fb889fed5f82d2b6abff95269cfa76abce8 100644 (file)
@@ -4,7 +4,6 @@
 
 #include <GL/glew.h>
 #include <assert.h>
 
 #include <GL/glew.h>
 #include <assert.h>
-#include <stddef.h>
 
 #include "effect.h"
 #include "effect_chain.h"
 
 #include "effect.h"
 #include "effect_chain.h"
diff --git a/effect_util.cpp b/effect_util.cpp
new file mode 100644 (file)
index 0000000..e57a562
--- /dev/null
@@ -0,0 +1,97 @@
+#include <GL/glew.h>
+#include <Eigen/Core>
+#include <stddef.h>
+#include <string>
+#include "util.h"
+
+GLint get_uniform_location(GLuint glsl_program_num, const std::string &prefix, const std::string &key)
+{
+       std::string name = prefix + "_" + key;
+       return glGetUniformLocation(glsl_program_num, name.c_str());
+}
+
+void set_uniform_int(GLuint glsl_program_num, const std::string &prefix, const std::string &key, int value)
+{
+       GLint location = get_uniform_location(glsl_program_num, prefix, key);
+       if (location == -1) {
+               return;
+       }
+       check_error();
+       glUniform1i(location, value);
+       check_error();
+}
+
+void set_uniform_float(GLuint glsl_program_num, const std::string &prefix, const std::string &key, float value)
+{
+       GLint location = get_uniform_location(glsl_program_num, prefix, key);
+       if (location == -1) {
+               return;
+       }
+       check_error();
+       glUniform1f(location, value);
+       check_error();
+}
+
+void set_uniform_vec2(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values)
+{
+       GLint location = get_uniform_location(glsl_program_num, prefix, key);
+       if (location == -1) {
+               return;
+       }
+       check_error();
+       glUniform2fv(location, 1, values);
+       check_error();
+}
+
+void set_uniform_vec3(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values)
+{
+       GLint location = get_uniform_location(glsl_program_num, prefix, key);
+       if (location == -1) {
+               return;
+       }
+       check_error();
+       glUniform3fv(location, 1, values);
+       check_error();
+}
+
+void set_uniform_vec4(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values)
+{
+       GLint location = get_uniform_location(glsl_program_num, prefix, key);
+       if (location == -1) {
+               return;
+       }
+       check_error();
+       glUniform4fv(location, 1, values);
+       check_error();
+}
+
+void set_uniform_vec4_array(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values, size_t num_values)
+{
+       GLint location = get_uniform_location(glsl_program_num, prefix, key);
+       if (location == -1) {
+               return;
+       }
+       check_error();
+       glUniform4fv(location, num_values, values);
+       check_error();
+}
+
+void set_uniform_mat3(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const Eigen::Matrix3d& matrix)
+{
+       GLint location = get_uniform_location(glsl_program_num, prefix, key);
+       if (location == -1) {
+               return;
+       }
+       check_error();
+
+       // Convert to float (GLSL has no double matrices).
+       float matrixf[9];
+       for (unsigned y = 0; y < 3; ++y) {
+               for (unsigned x = 0; x < 3; ++x) {
+                       matrixf[y + x * 3] = matrix(y, x);
+               }
+       }
+
+       glUniformMatrix3fv(location, 1, GL_FALSE, matrixf);
+       check_error();
+}
diff --git a/effect_util.h b/effect_util.h
new file mode 100644 (file)
index 0000000..13a7754
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef _EFFECT_UTIL_H
+#define _EFFECT_UTIL_H 1
+
+// Utilities that are often useful for implementing Effect instances,
+// but don't need to be included from effect.h.
+
+#include <GL/glew.h>
+#include <assert.h>
+#include <stddef.h>
+#include <Eigen/Core>
+#include <map>
+#include <string>
+#include <vector>
+
+#include "util.h"
+
+class EffectChain;
+class Node;
+
+// Convenience functions that deal with prepending the prefix.
+GLint get_uniform_location(GLuint glsl_program_num, const std::string &prefix, const std::string &key);
+void set_uniform_int(GLuint glsl_program_num, const std::string &prefix, const std::string &key, int value);
+void set_uniform_float(GLuint glsl_program_num, const std::string &prefix, const std::string &key, float value);
+void set_uniform_vec2(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values);
+void set_uniform_vec3(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values);
+void set_uniform_vec4(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values);
+void set_uniform_vec4_array(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values, size_t num_values);
+void set_uniform_mat3(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const Eigen::Matrix3d &matrix);
+
+#endif // !defined(_EFFECT_UTIL_H)
index 9cb9b9c5b377f356f593346f18886ba19ef2d20f..40fb7333bcec17fec73683579e7c796925c5afe8 100644 (file)
@@ -2,6 +2,7 @@
 #include <assert.h>
 #include <GL/glew.h>
 
 #include <assert.h>
 #include <GL/glew.h>
 
+#include "effect_util.h"
 #include "flat_input.h"
 #include "util.h"
 
 #include "flat_input.h"
 #include "util.h"
 
index f34bca02eb76f51c633b237a789d9f5f18e418e3..6727e6e905c313e75f98209e1d6a55da56f958f6 100644 (file)
@@ -10,7 +10,6 @@
 #include <string>
 
 #include "effect.h"
 #include <string>
 
 #include "effect.h"
-#include "effect_chain.h"
 #include "image_format.h"
 
 #define COMPRESSION_CURVE_SIZE 4096
 #include "image_format.h"
 
 #define COMPRESSION_CURVE_SIZE 4096
index 059b246325f62bc24ad688edc8064effb575d418..cc65e4fa48924022cf5f3d05e70693cd06809b36 100644 (file)
@@ -10,7 +10,6 @@
 #include <string>
 
 #include "effect.h"
 #include <string>
 
 #include "effect.h"
-#include "effect_chain.h"
 #include "image_format.h"
 
 #define EXPANSION_CURVE_SIZE 256
 #include "image_format.h"
 
 #define EXPANSION_CURVE_SIZE 256
index 3597e6c76cc6eb288ce0016597cef1d3bb819309..f00da879dce630d6d2f0e95d176da455ce9fbbbd 100644 (file)
@@ -1,6 +1,7 @@
 #include <GL/glew.h>
 #include <math.h>
 
 #include <GL/glew.h>
 #include <math.h>
 
+#include "effect_util.h"
 #include "lift_gamma_gain_effect.h"
 #include "util.h"
 
 #include "lift_gamma_gain_effect.h"
 #include "util.h"
 
index f7f97078e608749ab1a70db4226e2984be6281fb..40876b89e9a6edca0cf2c89146894c1d72f15070 100644 (file)
@@ -1,6 +1,7 @@
 #include <GL/glew.h>
 #include <assert.h>
 
 #include <GL/glew.h>
 #include <assert.h>
 
+#include "effect_util.h"
 #include "padding_effect.h"
 #include "util.h"
 
 #include "padding_effect.h"
 #include "util.h"
 
index 264e5c10195dc65cd6bd82eca537c412bc611e7c..f0c57c78ad772d42a20bb50c887199ea77c34ab5 100644 (file)
@@ -9,6 +9,7 @@
 #include <algorithm>
 
 #include "effect_chain.h"
 #include <algorithm>
 
 #include "effect_chain.h"
+#include "effect_util.h"
 #include "resample_effect.h"
 #include "util.h"
 
 #include "resample_effect.h"
 #include "util.h"
 
index 05b61aff9bdc0ecdd793e9af01f7b92d70c3e3b0..190af9559bb8fa302e0cf7bd6251f8a277ab0488 100644 (file)
@@ -3,7 +3,6 @@
 #include <math.h>
 #include <stdio.h>
 #include <algorithm>
 #include <math.h>
 #include <stdio.h>
 #include <algorithm>
-#include <ostream>
 
 #include "flat_input.h"
 #include "gtest/gtest.h"
 
 #include "flat_input.h"
 #include "gtest/gtest.h"
index a1bc2fd3e868c8aa2e6a948237e5608ff11b491b..a1fac6da35473ed1a77d64b8ed39bc53a9024a09 100644 (file)
--- a/util.cpp
+++ b/util.cpp
@@ -2,7 +2,6 @@
 #include <assert.h>
 #include <math.h>
 #include <stdio.h>
 #include <assert.h>
 #include <math.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 #include <Eigen/Core>
 
 #include <string.h>
 #include <Eigen/Core>
 
index bbd61da4a41a528abc9e33ae40baec5ba735833e..ac5197781cc4fc17f95ad2f5211df6021c0bc700 100644 (file)
@@ -1,6 +1,7 @@
 #include <GL/glew.h>
 #include <math.h>
 
 #include <GL/glew.h>
 #include <math.h>
 
+#include "effect_util.h"
 #include "vignette_effect.h"
 #include "util.h"
 
 #include "vignette_effect.h"
 #include "util.h"
 
index 1583922461053dd1c793eaa51f93b28275b1cab5..56cd8c96b853306a776e878b0f6e481092053fd0 100644 (file)
@@ -4,6 +4,7 @@
 #include <assert.h>
 
 #include "d65.h"
 #include <assert.h>
 
 #include "d65.h"
+#include "effect_util.h"
 #include "util.h"
 #include "white_balance_effect.h"
 
 #include "util.h"
 #include "white_balance_effect.h"
 
index 3e691d812fa8acc6b31e0bd09fa4a57bb45e2701..4bc519ce7f20068e3b8da5faecd988e5708e693c 100644 (file)
@@ -5,6 +5,7 @@
 #include <stdio.h>
 #include <string.h>
 
 #include <stdio.h>
 #include <string.h>
 
+#include "effect_util.h"
 #include "util.h"
 #include "ycbcr_input.h"
 
 #include "util.h"
 #include "ycbcr_input.h"