MCPcopy Create free account
hub / github.com/WayfireWM/wayfire / init

Method init

plugins/single_plugins/invert.cpp:60–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 10

run_in_contextFunction · 0.85
compile_programFunction · 0.85
is_gles2Method · 0.80
is_vulkanMethod · 0.80
is_pixmanMethod · 0.80
can_activate_pluginMethod · 0.80
set_simpleMethod · 0.80
rem_postMethod · 0.45
add_postMethod · 0.45
add_activatorMethod · 0.45

Tested by

no test coverage detected