]> git.sesse.net Git - movit/blob - alpha_division_effect_test.cpp
Support rendering compute shaders straight to textures (skipping the dummy phase).
[movit] / alpha_division_effect_test.cpp
1 // Unit tests for AlphaDivisionEffect.
2
3 #include <epoxy/gl.h>
4 #include "gtest/gtest.h"
5 #include "image_format.h"
6 #include "test_util.h"
7
8 namespace movit {
9
10 TEST(AlphaDivisionEffectTest, SimpleTest) {
11         const int size = 2;
12         float data[4 * size] = {
13                 0.1f, 0.5f, 0.1f, 0.5f,
14                 0.2f, 0.2f, 1.0f, 1.0f,
15         };
16         float expected_data[4 * size] = {
17                 0.2f, 1.0f, 0.2f, 0.5f,
18                 0.2f, 0.2f, 1.0f, 1.0f,
19         };
20         float out_data[4 * size];
21         EffectChainTester tester(data, 1, size, FORMAT_RGBA_PREMULTIPLIED_ALPHA, COLORSPACE_sRGB, GAMMA_LINEAR);
22         tester.run(out_data, GL_RGBA, COLORSPACE_sRGB, GAMMA_LINEAR);
23
24         expect_equal(expected_data, out_data, 4, size);
25 }
26
27 TEST(AlphaDivisionEffectTest, ZeroAlphaIsPreserved) {
28         const int size = 2;
29         float data[4 * size] = {
30                 0.1f, 0.5f, 0.1f, 0.0f,
31                 0.0f, 0.0f, 0.0f, 0.0f,
32         };
33         float out_data[4 * size];
34         EffectChainTester tester(data, 1, size, FORMAT_RGBA_PREMULTIPLIED_ALPHA, COLORSPACE_sRGB, GAMMA_LINEAR);
35         tester.run(out_data, GL_RGBA, COLORSPACE_sRGB, GAMMA_LINEAR);
36
37         EXPECT_EQ(0.0f, out_data[3]);
38         EXPECT_EQ(0.0f, out_data[7]);
39 }
40
41 }  // namespace movit