1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
--- a/plugins/cube/cube.cpp
+++ b/plugins/cube/cube.cpp
@@ -145,14 +145,23 @@
std::vector<wf::scene::render_instruction_t>& instructions,
const wf::render_target_t& target, wf::regionf_t& damage) override
{
+ auto bbox = self->get_bounding_box();
+ auto our_damage = damage & bbox;
+ if (our_damage.empty())
+ {
+ return;
+ }
+
+ // The cube renders in output-local coordinates, including its
+ // damage. Never repaint pixels occluded by a higher layer.
+ our_damage += -wf::origin(bbox);
instructions.push_back(wf::scene::render_instruction_t{
.instance = this,
- .target = target.translated(-wf::origin(self->get_bounding_box())),
- .damage = damage & self->get_bounding_box(),
+ .target = target.translated(-wf::origin(bbox)),
+ .damage = our_damage,
});
- wf::regionf_t background_damage =
- output_background->get_bounding_box();
+ wf::regionf_t background_damage = our_damage;
auto background_target =
target.translated(-wf::origin(self->get_bounding_box()));
for (auto& instance : output_background_instances)
@@ -161,15 +170,22 @@
instructions, background_target, background_damage);
}
- auto bbox = self->get_bounding_box();
-
damage ^= bbox;
for (int i = 0; i < (int)ws_instances.size(); i++)
{
const float scale = self->cube->output->handle->scale;
auto bbox = self->workspaces[i]->get_bounding_box();
- framebuffers[i].allocate(wf::dimensions(bbox), scale);
+ if (framebuffers[i].allocate(wf::dimensions(bbox), scale) ==
+ wf::buffer_reallocation_result_t::REALLOCATED)
+ {
+ ws_damage[i] |= bbox;
+ }
+
+ if (ws_damage[i].empty())
+ {
+ continue;
+ }
wf::render_target_t target{framebuffers[i]};
target.geometry = self->workspaces[i]->get_bounding_box();
@@ -177,14 +193,14 @@
wf::render_pass_params_t params;
params.instances = &ws_instances[i];
- params.damage = self->workspaces[i]->get_bounding_box();
+ params.damage = ws_damage[i];
params.reference_output = self->cube->output;
params.target = target;
params.background_color = wf::color_t{0.0, 0.0, 0.0, 0.0};
params.flags = wf::RPASS_CLEAR_BACKGROUND | wf::RPASS_EMIT_SIGNALS;
+ ws_damage[i].clear();
wf::render_pass_t::run(params);
- ws_damage[i].clear();
}
}
@@ -532,11 +548,12 @@
input_is_grabbed = false;
}
- void add_cube_render_node()
+ void add_desktop_render_node(const wf::scene::node_ptr& node,
+ const wf::scene::node_ptr& before = nullptr)
{
auto root = wf::get_core().scene();
auto children = root->get_children();
- auto overlay_layer =
+ auto anchor = before ? before :
root->layers[(int)wf::scene::layer::OVERLAY];
std::vector<wf::scene::node_ptr> updated;
@@ -544,9 +561,9 @@
bool inserted = false;
for (auto& child : children)
{
- if (!inserted && (child == overlay_layer))
- {
- updated.push_back(render_node);
+ if (!inserted && (child == anchor))
+ {
+ updated.push_back(node);
inserted = true;
}
@@ -555,11 +572,18 @@
if (!inserted)
{
- updated.insert(updated.begin(), render_node);
+ // The built-in overlay layer is always present. Do not place
+ // desktop content above screensavers or locks if that changes.
+ updated.push_back(node);
}
root->set_children_list(updated);
wf::scene::update(root, wf::scene::update_flag::CHILDREN_LIST);
+ }
+
+ void add_cube_render_node()
+ {
+ add_desktop_render_node(render_node);
}
void rebuild_cube_render_node()
@@ -705,7 +729,7 @@
fixed_overlay_node = std::make_shared<wf::scene::translation_node_t>();
fixed_overlay_node->set_children_list({overlay});
fixed_overlay_node->set_offset(wf::origin(output->get_layout_geometry()));
- wf::scene::add_front(wf::get_core().scene(), fixed_overlay_node);
+ add_desktop_render_node(fixed_overlay_node, render_node);
}
/* Tries to initialize renderer, activate plugin, etc. */
@@ -1027,7 +1051,6 @@
load_program();
}
- GL_CALL(glClear(GL_DEPTH_BUFFER_BIT));
/* The fixed output background is scheduled behind the cube. */
auto vp = calculate_vp_matrix(data.target);
@@ -1070,8 +1093,12 @@
GL_CALL(glEnable(GL_BLEND));
GL_CALL(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
GL_CALL(glEnable(GL_CULL_FACE));
- render_cube(GL_CCW, buffers);
- render_cube(GL_CW, buffers);
+ wf::gles::for_each_scissor_rect(data.target, data.damage, [&]
+ {
+ GL_CALL(glClear(GL_DEPTH_BUFFER_BIT));
+ render_cube(GL_CCW, buffers);
+ render_cube(GL_CW, buffers);
+ });
GL_CALL(glDisable(GL_CULL_FACE));
GL_CALL(glDisable(GL_BLEND));
@@ -1080,13 +1107,21 @@
});
}
+ bool animation_was_running = false;
wf::effect_hook_t pre_hook = [=] ()
{
update_view_matrix();
- wf::scene::damage_node(render_node, render_node->get_bounding_box());
- if (animation.cube_animation.running())
- {
- output->render->damage_whole();
+ const bool running = animation.cube_animation.running();
+ if (render_node && (running || animation_was_running))
+ {
+ // Repaint moving geometry and its final settled frame. At rest,
+ // workspace/background damage already schedules the needed frames.
+ wf::scene::damage_node(render_node, render_node->get_bounding_box());
+ }
+
+ animation_was_running = running;
+ if (running)
+ {
output->render->schedule_redraw();
} else if (animation.in_exit)
{
@@ -1099,8 +1134,6 @@
clear_fixed_workspace_overlay();
rebuild_cube_render_node();
}
-
- output->render->schedule_redraw();
}
};
|