7 #include "flat_input.h"
8 #include "gtest/gtest.h"
10 #include "resource_pool.h"
11 #include "test_util.h"
18 // An effect that does nothing.
19 class IdentityComputeEffect : public Effect {
21 IdentityComputeEffect() {}
22 virtual string effect_type_id() const { return "IdentityComputeEffect"; }
23 virtual bool is_compute_shader() const { return true; }
24 string output_fragment_shader() { return read_file("identity.comp"); }
27 TEST(ComputeShaderTest, Identity) {
33 EffectChainTester tester(data, 3, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
34 if (!movit_compute_shaders_supported) {
35 fprintf(stderr, "Skipping test; no support for compile shaders.\n");
38 tester.get_chain()->add_effect(new IdentityComputeEffect());
39 tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
41 expect_equal(data, out_data, 3, 2);
44 // Like IdentityComputeEffect, but due to the alpha handling, this will be
45 // the very last effect in the chain, which means we can't output it directly
47 class IdentityAlphaComputeEffect : public IdentityComputeEffect {
48 AlphaHandling alpha_handling() const { return DONT_CARE_ALPHA_TYPE; }
51 TEST(ComputeShaderTest, LastEffectInChain) {
57 EffectChainTester tester(data, 3, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
58 if (!movit_compute_shaders_supported) {
59 fprintf(stderr, "Skipping test; no support for compile shaders.\n");
62 tester.get_chain()->add_effect(new IdentityAlphaComputeEffect());
63 tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
65 expect_equal(data, out_data, 3, 2);