+namespace {
+
+// Flip upside-down to compensate for different origin.
+template<class T>
+void vertical_flip(T *data, unsigned width, unsigned height)
+{
+ for (unsigned y = 0; y < height / 2; ++y) {
+ unsigned flip_y = height - y - 1;
+ for (unsigned x = 0; x < width; ++x) {
+ std::swap(data[y * width + x], data[flip_y * width + x]);
+ }
+ }
+}
+
+} // namespace
+
+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), finalized(false)
+{
+ init_movit();
+
+ if (data != NULL) {
+ add_input(data, pixel_format, color_space, gamma_curve);
+ }
+
+ glGenTextures(1, &texnum);
+ check_error();
+ glBindTexture(GL_TEXTURE_2D, texnum);
+ check_error();
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ check_error();
+
+ glGenFramebuffers(1, &fbo);
+ check_error();
+ glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+ check_error();
+ glFramebufferTexture2D(
+ GL_FRAMEBUFFER,
+ GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D,
+ texnum,
+ 0);
+ check_error();
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ check_error();
+}
+
+EffectChainTester::~EffectChainTester()
+{
+ glDeleteFramebuffers(1, &fbo);
+ check_error();
+ glDeleteTextures(1, &texnum);
+ check_error();
+}
+
+Input *EffectChainTester::add_input(const float *data, MovitPixelFormat pixel_format, Colorspace color_space, GammaCurve gamma_curve)