| 58 | |
| 59 | public: |
| 60 | void init() override |
| 61 | { |
| 62 | if (!wf::get_core().is_gles2()) |
| 63 | { |
| 64 | const char *render_type = |
| 65 | wf::get_core().is_vulkan() ? "vulkan" : (wf::get_core().is_pixman() ? "pixman" : "unknown"); |
| 66 | LOGE("invert: requires GLES2 support, but current renderer is ", render_type); |
| 67 | return; |
| 68 | } |
| 69 | |
| 70 | wf::option_wrapper_t<wf::activatorbinding_t> toggle_key{"invert/toggle"}; |
| 71 | |
| 72 | hook = [=] (wf::auxilliary_buffer_t& source, |
| 73 | const wf::render_buffer_t& destination) |
| 74 | { |
| 75 | render(source, destination); |
| 76 | }; |
| 77 | |
| 78 | toggle_cb = [=] (auto) |
| 79 | { |
| 80 | if (!output->can_activate_plugin(&grab_interface)) |
| 81 | { |
| 82 | return false; |
| 83 | } |
| 84 | |
| 85 | if (active) |
| 86 | { |
| 87 | output->render->rem_post(&hook); |
| 88 | } else |
| 89 | { |
| 90 | output->render->add_post(&hook); |
| 91 | } |
| 92 | |
| 93 | active = !active; |
| 94 | |
| 95 | return true; |
| 96 | }; |
| 97 | |
| 98 | wf::gles::run_in_context([&] |
| 99 | { |
| 100 | program.set_simple(OpenGL::compile_program(vertex_shader, fragment_shader)); |
| 101 | }); |
| 102 | |
| 103 | output->add_activator(toggle_key, &toggle_cb); |
| 104 | } |
| 105 | |
| 106 | void render(wf::auxilliary_buffer_t& source, const wf::render_buffer_t& destination) |
| 107 | { |
nothing calls this directly
no test coverage detected