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
#include "blur_effect.h"
#include "effect_chain.h"
+#include "effect_util.h"
#include "util.h"
// Must match blur_effect.frag.
#include <string>
#include "effect.h"
-#include "effect_chain.h"
#include "image_format.h"
class ColorspaceConversionEffect : public Effect {
#include <new>
#include "deconvolution_sharpen_effect.h"
+#include "effect_util.h"
#include "util.h"
using namespace Eigen;
#include <algorithm>
#include "dither_effect.h"
+#include "effect_util.h"
#include "util.h"
namespace {
-#include <Eigen/Core>
#include <GL/glew.h>
#include <assert.h>
#include <stdio.h>
#include <utility>
#include "effect.h"
+#include "effect_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) {
#include <GL/glew.h>
#include <assert.h>
#include <stddef.h>
-#include <Eigen/Core>
#include <map>
#include <string>
-#include <vector>
#include "util.h"
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() {}
#include <string>
#include <vector>
-#include "effect.h"
#include "image_format.h"
-#include "input.h"
class Effect;
-class EffectChain;
class Input;
struct Phase;
#include <GL/glew.h>
#include <assert.h>
-#include <stddef.h>
#include "effect.h"
#include "effect_chain.h"
--- /dev/null
+#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();
+}
--- /dev/null
+#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)
#include <assert.h>
#include <GL/glew.h>
+#include "effect_util.h"
#include "flat_input.h"
#include "util.h"
#include <string>
#include "effect.h"
-#include "effect_chain.h"
#include "image_format.h"
#define COMPRESSION_CURVE_SIZE 4096
#include <string>
#include "effect.h"
-#include "effect_chain.h"
#include "image_format.h"
#define EXPANSION_CURVE_SIZE 256
#include <GL/glew.h>
#include <math.h>
+#include "effect_util.h"
#include "lift_gamma_gain_effect.h"
#include "util.h"
#include <GL/glew.h>
#include <assert.h>
+#include "effect_util.h"
#include "padding_effect.h"
#include "util.h"
#include <algorithm>
#include "effect_chain.h"
+#include "effect_util.h"
#include "resample_effect.h"
#include "util.h"
#include <math.h>
#include <stdio.h>
#include <algorithm>
-#include <ostream>
#include "flat_input.h"
#include "gtest/gtest.h"
#include <assert.h>
#include <math.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include <Eigen/Core>
#include <GL/glew.h>
#include <math.h>
+#include "effect_util.h"
#include "vignette_effect.h"
#include "util.h"
#include <assert.h>
#include "d65.h"
+#include "effect_util.h"
#include "util.h"
#include "white_balance_effect.h"
#include <stdio.h>
#include <string.h>
+#include "effect_util.h"
#include "util.h"
#include "ycbcr_input.h"