1 // Unit tests for AlphaDivisionEffect.
4 #include "gtest/gtest.h"
5 #include "image_format.h"
8 TEST(AlphaDivisionEffectTest, SimpleTest) {
10 float data[4 * size] = {
11 0.1f, 0.5f, 0.1f, 0.5f,
12 0.2f, 0.2f, 1.0f, 1.0f,
14 float expected_data[4 * size] = {
15 0.2f, 1.0f, 0.2f, 0.5f,
16 0.2f, 0.2f, 1.0f, 1.0f,
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);
22 expect_equal(expected_data, out_data, 4, size);
25 TEST(AlphaDivisionEffectTest, ZeroAlphaIsPreserved) {
27 float data[4 * size] = {
28 0.1f, 0.5f, 0.1f, 0.0f,
29 0.0f, 0.0f, 0.0f, 0.0f,
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);
35 EXPECT_EQ(0.0f, out_data[3]);
36 EXPECT_EQ(0.0f, out_data[7]);