0.75f, 1.0f, 1.0f,
};
float out_data[6];
- EffectChainTester tester(data, 3, 2, COLORSPACE_sRGB, GAMMA_LINEAR);
- tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR);
+ EffectChainTester tester(data, 3, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
+ tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
expect_equal(data, out_data, 3, 2);
}
0.75f, 1.0f, 1.0f,
};
float out_data[6];
- EffectChainTester tester(data, 3, 2, COLORSPACE_sRGB, GAMMA_LINEAR);
+ EffectChainTester tester(data, 3, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
tester.get_chain()->add_effect(new IdentityEffect());
- tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR);
+ tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
expect_equal(data, out_data, 3, 2);
}
0.75f, 1.0f, 1.0f,
};
float out_data[6];
- EffectChainTester tester(data, 3, 2, COLORSPACE_sRGB, GAMMA_LINEAR);
+ EffectChainTester tester(data, 3, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
tester.get_chain()->add_effect(new BouncingIdentityEffect());
- tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR);
+ tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
expect_equal(data, out_data, 3, 2);
}
1.0f, 1.0f, 0.75f,
};
float out_data[6];
- EffectChainTester tester(data, 3, 2, COLORSPACE_sRGB, GAMMA_LINEAR);
+ EffectChainTester tester(data, 3, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
tester.get_chain()->add_effect(new MirrorEffect());
- tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR);
+ tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
expect_equal(expected_data, out_data, 3, 2);
}
0.040f, 0.041f,
};
float out_data[4];
- EffectChainTester tester(data, 2, 2, COLORSPACE_sRGB, GAMMA_LINEAR);
- tester.run(out_data, COLORSPACE_sRGB, GAMMA_sRGB);
+ EffectChainTester tester(data, 2, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
+ tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_sRGB);
expect_equal(expected_data, out_data, 2, 2);
}
for (unsigned i = 0; i < 256; ++i) {
data[i] = i / 255.0f;
}
- EffectChainTester tester(data, 256, 1, COLORSPACE_sRGB, GAMMA_LINEAR);
- tester.run(out_data, COLORSPACE_sRGB, GAMMA_sRGB);
+ EffectChainTester tester(data, 256, 1, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
+ tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_sRGB);
for (unsigned i = 1; i < 256; ++i) {
EXPECT_GT(out_data[i], out_data[i - 1])
0.080f, 0.082f,
};
float out_data[4];
- EffectChainTester tester(data, 2, 2, COLORSPACE_sRGB, GAMMA_LINEAR);
- tester.run(out_data, COLORSPACE_sRGB, GAMMA_REC_709);
+ EffectChainTester tester(data, 2, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
+ tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_REC_709);
expect_equal(expected_data, out_data, 2, 2);
}
for (unsigned i = 0; i < 256; ++i) {
data[i] = i / 255.0f;
}
- EffectChainTester tester(data, 256, 1, COLORSPACE_sRGB, GAMMA_LINEAR);
- tester.run(out_data, COLORSPACE_sRGB, GAMMA_REC_709);
+ EffectChainTester tester(data, 256, 1, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
+ tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_REC_709);
for (unsigned i = 1; i < 256; ++i) {
EXPECT_GT(out_data[i], out_data[i - 1])
0.00309f, 0.00317f,
};
float out_data[4];
- EffectChainTester tester(data, 2, 2, COLORSPACE_sRGB, GAMMA_sRGB);
- tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR);
+ EffectChainTester tester(data, 2, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_sRGB);
+ tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
expect_equal(expected_data, out_data, 2, 2);
}
for (unsigned i = 0; i < 256; ++i) {
data[i] = i / 255.0f;
}
- EffectChainTester tester(data, 256, 1, COLORSPACE_sRGB, GAMMA_sRGB);
- tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR);
+ EffectChainTester tester(data, 256, 1, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_sRGB);
+ tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
for (unsigned i = 1; i < 256; ++i) {
EXPECT_GT(out_data[i], out_data[i - 1])
0.017778f, 0.018167f,
};
float out_data[4];
- EffectChainTester tester(data, 2, 2, COLORSPACE_sRGB, GAMMA_REC_709);
- tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR);
+ EffectChainTester tester(data, 2, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_REC_709);
+ tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
expect_equal(expected_data, out_data, 2, 2);
}
for (unsigned i = 0; i < 256; ++i) {
data[i] = i / 255.0f;
}
- EffectChainTester tester(data, 256, 1, COLORSPACE_sRGB, GAMMA_REC_709);
- tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR);
+ EffectChainTester tester(data, 256, 1, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_REC_709);
+ tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
for (unsigned i = 1; i < 256; ++i) {
EXPECT_GT(out_data[i], out_data[i - 1])
0.75f, 0.8f,
};
float out_data[4];
- EffectChainTester tester(data_a, 2, 2, COLORSPACE_sRGB, GAMMA_LINEAR);
+ EffectChainTester tester(data_a, 2, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
Effect *input1 = tester.get_chain()->last_added_effect();
- Effect *input2 = tester.add_input(data_b, COLORSPACE_sRGB, GAMMA_LINEAR);
+ Effect *input2 = tester.add_input(data_b, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
Effect *mix_effect = tester.get_chain()->add_effect(new MixEffect(), input1, input2);
ASSERT_TRUE(mix_effect->set_float("strength_first", 0.5f));
ASSERT_TRUE(mix_effect->set_float("strength_second", 0.5f));
- tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR);
+ tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
expect_equal(expected_data, out_data, 2, 2);
}
0.75f, 0.6f,
};
float out_data[4];
- EffectChainTester tester(data_a, 2, 2, COLORSPACE_sRGB, GAMMA_LINEAR);
+ EffectChainTester tester(data_a, 2, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
Effect *input1 = tester.get_chain()->last_added_effect();
- Effect *input2 = tester.add_input(data_b, COLORSPACE_sRGB, GAMMA_LINEAR);
+ Effect *input2 = tester.add_input(data_b, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
Effect *mix_effect = tester.get_chain()->add_effect(new MixEffect(), input1, input2);
ASSERT_TRUE(mix_effect->set_float("strength_first", 1.0f));
ASSERT_TRUE(mix_effect->set_float("strength_second", 0.0f));
- tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR);
+ tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
expect_equal(data_a, out_data, 2, 2);
}
0.6f, 0.4f,
};
float out_data[4];
- EffectChainTester tester(data_a, 2, 2, COLORSPACE_sRGB, GAMMA_LINEAR);
+ EffectChainTester tester(data_a, 2, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
Effect *input1 = tester.get_chain()->last_added_effect();
- Effect *input2 = tester.add_input(data_b, COLORSPACE_sRGB, GAMMA_LINEAR);
+ Effect *input2 = tester.add_input(data_b, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
Effect *mix_effect = tester.get_chain()->add_effect(new MixEffect(), input1, input2);
ASSERT_TRUE(mix_effect->set_float("strength_first", 1.0f));
ASSERT_TRUE(mix_effect->set_float("strength_second", -1.0f));
- tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR);
+ tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
expect_equal(expected_data, out_data, 2, 2);
}
0.54807f, 0.73536f,
};
float out_data[4];
- EffectChainTester tester(data_a, 2, 2, COLORSPACE_sRGB, GAMMA_sRGB);
+ EffectChainTester tester(data_a, 2, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_sRGB);
Effect *input1 = tester.get_chain()->last_added_effect();
- Effect *input2 = tester.add_input(data_b, COLORSPACE_sRGB, GAMMA_sRGB);
+ Effect *input2 = tester.add_input(data_b, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_sRGB);
Effect *mix_effect = tester.get_chain()->add_effect(new MixEffect(), input1, input2);
ASSERT_TRUE(mix_effect->set_float("strength_first", 0.5f));
ASSERT_TRUE(mix_effect->set_float("strength_second", 0.5f));
- tester.run(out_data, COLORSPACE_sRGB, GAMMA_sRGB);
+ tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_sRGB);
expect_equal(expected_data, out_data, 2, 2);
}
#include <algorithm>
-EffectChainTester::EffectChainTester(const float *data, unsigned width, unsigned height, ColorSpace color_space, GammaCurve gamma_curve)
+EffectChainTester::EffectChainTester(const float *data, unsigned width, unsigned height, MovitPixelFormat pixel_format, ColorSpace color_space, GammaCurve gamma_curve)
: chain(width, height), width(width), height(height)
{
- add_input(data, color_space, gamma_curve);
+ add_input(data, pixel_format, color_space, gamma_curve);
glGenTextures(1, &texnum);
check_error();
check_error();
}
-Input *EffectChainTester::add_input(const float *data, ColorSpace color_space, GammaCurve gamma_curve)
+Input *EffectChainTester::add_input(const float *data, MovitPixelFormat pixel_format, ColorSpace color_space, GammaCurve gamma_curve)
{
ImageFormat format;
format.color_space = color_space;
format.gamma_curve = gamma_curve;
- FlatInput *input = new FlatInput(format, FORMAT_GRAYSCALE, GL_FLOAT, width, height);
+ FlatInput *input = new FlatInput(format, pixel_format, GL_FLOAT, width, height);
input->set_pixel_data(data);
chain.add_input(input);
return input;
}
-void EffectChainTester::run(float *out_data, ColorSpace color_space, GammaCurve gamma_curve)
+void EffectChainTester::run(float *out_data, GLenum format, ColorSpace color_space, GammaCurve gamma_curve)
{
- ImageFormat format;
- format.color_space = color_space;
- format.gamma_curve = gamma_curve;
- chain.add_output(format);
+ ImageFormat image_format;
+ image_format.color_space = color_space;
+ image_format.gamma_curve = gamma_curve;
+ chain.add_output(image_format);
chain.finalize();
chain.render_to_fbo(fbo, width, height);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
- glReadPixels(0, 0, width, height, GL_RED, GL_FLOAT, out_data);
+ glReadPixels(0, 0, width, height, format, GL_FLOAT, out_data);
// Flip upside-down to compensate for different origin.
for (unsigned y = 0; y < height / 2; ++y) {
class EffectChainTester {
public:
- EffectChainTester(const float *data, unsigned width, unsigned height, ColorSpace color_space, GammaCurve gamma_curve);
+ EffectChainTester(const float *data, unsigned width, unsigned height, MovitPixelFormat pixel_format, ColorSpace color_space, GammaCurve gamma_curve);
EffectChain *get_chain() { return &chain; }
- Input *add_input(const float *data, ColorSpace color_space, GammaCurve gamma_curve);
- void run(float *out_data, ColorSpace color_space, GammaCurve gamma_curve);
+ Input *add_input(const float *data, MovitPixelFormat pixel_format, ColorSpace color_space, GammaCurve gamma_curve);
+ void run(float *out_data, GLenum format, ColorSpace color_space, GammaCurve gamma_curve);
private:
EffectChain chain;