1 // Unit tests for AlphaDivisionEffect.
4 #include "gtest/gtest.h"
5 #include "image_format.h"
10 TEST(AlphaDivisionEffectTest, SimpleTest) {
12 float data[4 * size] = {
13 0.1f, 0.5f, 0.1f, 0.5f,
14 0.2f, 0.2f, 1.0f, 1.0f,
16 float expected_data[4 * size] = {
17 0.2f, 1.0f, 0.2f, 0.5f,
18 0.2f, 0.2f, 1.0f, 1.0f,
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);
24 expect_equal(expected_data, out_data, 4, size);
27 TEST(AlphaDivisionEffectTest, ZeroAlphaIsPreserved) {
29 float data[4 * size] = {
30 0.1f, 0.5f, 0.1f, 0.0f,
31 0.0f, 0.0f, 0.0f, 0.0f,
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);
37 EXPECT_EQ(0.0f, out_data[3]);
38 EXPECT_EQ(0.0f, out_data[7]);