Use the ResourcePool to allocate RTT textures in EffectChain.
[movit] / alpha_division_effect_test.cpp
1 // Unit tests for AlphaDivisionEffect.
2
3 #include <GL/glew.h>
4 #include "gtest/gtest.h"
5 #include "image_format.h"
6 #include "test_util.h"
7
8 TEST(AlphaDivisionEffectTest, SimpleTest) {
9         const int size = 2;
10         float data[4 * size] = {
11                 0.1f, 0.5f, 0.1f, 0.5f,
12                 0.2f, 0.2f, 1.0f, 1.0f,
13         };
14         float expected_data[4 * size] = {
15                 0.2f, 1.0f, 0.2f, 0.5f,
16                 0.2f, 0.2f, 1.0f, 1.0f,
17         };
18         float out_data[4 * size];
19         EffectChainTester tester(data, 1, size, FORMAT_RGBA_PREMULTIPLIED_ALPHA, COLORSPACE_sRGB, GAMMA_LINEAR);
20         tester.run(out_data, GL_RGBA, COLORSPACE_sRGB, GAMMA_LINEAR);
21
22         expect_equal(expected_data, out_data, 4, size);
23 }
24
25 TEST(AlphaDivisionEffectTest, ZeroAlphaIsPreserved) {
26         const int size = 2;
27         float data[4 * size] = {
28                 0.1f, 0.5f, 0.1f, 0.0f,
29                 0.0f, 0.0f, 0.0f, 0.0f,
30         };
31         float out_data[4 * size];
32         EffectChainTester tester(data, 1, size, FORMAT_RGBA_PREMULTIPLIED_ALPHA, COLORSPACE_sRGB, GAMMA_LINEAR);
33         tester.run(out_data, GL_RGBA, COLORSPACE_sRGB, GAMMA_LINEAR);
34
35         EXPECT_EQ(0.0f, out_data[3]);
36         EXPECT_EQ(0.0f, out_data[7]);
37 }