]> git.sesse.net Git - movit/blobdiff - blur_effect_test.cpp
Release Movit 1.3.2. (From a branch, since I do not want to break ABI compatibility...
[movit] / blur_effect_test.cpp
index fb4e0250ef333a0b5e4586ae88ac681d0463340b..1c9193dfaa10cf8a600e05dd44a91eace3e88ba8 100644 (file)
@@ -22,12 +22,15 @@ TEST(BlurEffectTest, IdentityTransformDoesNothing) {
        };
        float out_data[size * size];
 
-       EffectChainTester tester(data, size, size, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
-       Effect *blur_effect = tester.get_chain()->add_effect(new BlurEffect());
-       ASSERT_TRUE(blur_effect->set_float("radius", 0.0f));
-       tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
-
-       expect_equal(data, out_data, size, size);
+       for (int num_taps = 2; num_taps < 20; num_taps += 2) {
+               EffectChainTester tester(data, size, size, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
+               Effect *blur_effect = tester.get_chain()->add_effect(new BlurEffect());
+               ASSERT_TRUE(blur_effect->set_float("radius", 0.0f));
+               ASSERT_TRUE(blur_effect->set_int("num_taps", num_taps));
+               tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
+
+               expect_equal(data, out_data, size, size);
+       }
 }
 
 namespace {
@@ -102,4 +105,32 @@ TEST(BlurEffectTest, BlurTwoDotsLargeRadius) {
        expect_equal(expected_data, out_data, size, size, 0.1f, 1e-3);
 }
 
+TEST(BlurEffectTest, BlurTwoDotsSmallRadiusFewerTaps) {
+       const float sigma = 3.0f;
+       const int size = 32;
+       const int x1 = 8;
+       const int y1 = 8;
+       const int x2 = 20;
+       const int y2 = 10;
+
+       float data[size * size], out_data[size * size], expected_data[size * size];
+       memset(data, 0, sizeof(data));
+       memset(expected_data, 0, sizeof(expected_data));
+
+       data[y1 * size + x1] = 1.0f;
+       data[y2 * size + x2] = 1.0f;
+
+       add_blurred_point(expected_data, size, x1, y1, 1.0f, sigma);
+       add_blurred_point(expected_data, size, x2, y2, 1.0f, sigma);
+
+       EffectChainTester tester(data, size, size, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
+       Effect *blur_effect = tester.get_chain()->add_effect(new BlurEffect());
+       ASSERT_TRUE(blur_effect->set_float("radius", sigma));
+       ASSERT_TRUE(blur_effect->set_int("num_taps", 10));
+       tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
+
+       // Set the limits a bit tighter than usual, since there is so little energy in here.
+       expect_equal(expected_data, out_data, size, size, 1e-3, 1e-5);
+}
+
 }  // namespace movit