X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=blur_effect_test.cpp;h=1c9193dfaa10cf8a600e05dd44a91eace3e88ba8;hp=fb4e0250ef333a0b5e4586ae88ac681d0463340b;hb=refs%2Fheads%2F1.3.x-release;hpb=b757191bc6d258887445d88cdfe5b18666295660 diff --git a/blur_effect_test.cpp b/blur_effect_test.cpp index fb4e025..1c9193d 100644 --- a/blur_effect_test.cpp +++ b/blur_effect_test.cpp @@ -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