diff options
author | Alexander Orzechowski <orzechowski.alexander@gmail.com> | 2023-04-06 22:23:53 +0200 |
---|---|---|
committer | Kirill Primak <vyivel@eclair.cafe> | 2024-01-18 18:36:54 +0300 |
commit | 1e018e72b4d57c8f354b9be9686a7a75797cdcab (patch) | |
tree | 46e6c588d30ddfc43793d1980b38b8d53bf9bdd7 /sway/desktop/output.c | |
parent | scene_graph: Port view saved buffers (diff) | |
download | sway-1e018e72b4d57c8f354b9be9686a7a75797cdcab.tar.gz sway-1e018e72b4d57c8f354b9be9686a7a75797cdcab.tar.zst sway-1e018e72b4d57c8f354b9be9686a7a75797cdcab.zip |
Delete old damage tracking code
The new scene graph abstraction handles this for us.
Diffstat (limited to 'sway/desktop/output.c')
-rw-r--r-- | sway/desktop/output.c | 240 |
1 files changed, 0 insertions, 240 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 36c8f52c..aea2a8d7 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -71,127 +71,6 @@ struct sway_output *all_output_by_name_or_id(const char *name_or_id) { | |||
71 | return NULL; | 71 | return NULL; |
72 | } | 72 | } |
73 | 73 | ||
74 | struct surface_iterator_data { | ||
75 | sway_surface_iterator_func_t user_iterator; | ||
76 | void *user_data; | ||
77 | |||
78 | struct sway_output *output; | ||
79 | struct sway_view *view; | ||
80 | double ox, oy; | ||
81 | int width, height; | ||
82 | }; | ||
83 | |||
84 | static bool get_surface_box(struct surface_iterator_data *data, | ||
85 | struct wlr_surface *surface, int sx, int sy, | ||
86 | struct wlr_box *surface_box) { | ||
87 | struct sway_output *output = data->output; | ||
88 | |||
89 | if (!wlr_surface_has_buffer(surface)) { | ||
90 | return false; | ||
91 | } | ||
92 | |||
93 | int sw = surface->current.width; | ||
94 | int sh = surface->current.height; | ||
95 | |||
96 | struct wlr_box box = { | ||
97 | .x = floor(data->ox + sx), | ||
98 | .y = floor(data->oy + sy), | ||
99 | .width = sw, | ||
100 | .height = sh, | ||
101 | }; | ||
102 | if (surface_box != NULL) { | ||
103 | memcpy(surface_box, &box, sizeof(struct wlr_box)); | ||
104 | } | ||
105 | |||
106 | struct wlr_box output_box = { | ||
107 | .width = output->width, | ||
108 | .height = output->height, | ||
109 | }; | ||
110 | |||
111 | struct wlr_box intersection; | ||
112 | return wlr_box_intersection(&intersection, &output_box, &box); | ||
113 | } | ||
114 | |||
115 | static void output_for_each_surface_iterator(struct wlr_surface *surface, | ||
116 | int sx, int sy, void *_data) { | ||
117 | struct surface_iterator_data *data = _data; | ||
118 | |||
119 | struct wlr_box box; | ||
120 | bool intersects = get_surface_box(data, surface, sx, sy, &box); | ||
121 | if (!intersects) { | ||
122 | return; | ||
123 | } | ||
124 | |||
125 | data->user_iterator(data->output, data->view, surface, &box, | ||
126 | data->user_data); | ||
127 | } | ||
128 | |||
129 | void output_surface_for_each_surface(struct sway_output *output, | ||
130 | struct wlr_surface *surface, double ox, double oy, | ||
131 | sway_surface_iterator_func_t iterator, void *user_data) { | ||
132 | struct surface_iterator_data data = { | ||
133 | .user_iterator = iterator, | ||
134 | .user_data = user_data, | ||
135 | .output = output, | ||
136 | .view = NULL, | ||
137 | .ox = ox, | ||
138 | .oy = oy, | ||
139 | .width = surface->current.width, | ||
140 | .height = surface->current.height, | ||
141 | }; | ||
142 | |||
143 | wlr_surface_for_each_surface(surface, | ||
144 | output_for_each_surface_iterator, &data); | ||
145 | } | ||
146 | |||
147 | void output_view_for_each_surface(struct sway_output *output, | ||
148 | struct sway_view *view, sway_surface_iterator_func_t iterator, | ||
149 | void *user_data) { | ||
150 | struct surface_iterator_data data = { | ||
151 | .user_iterator = iterator, | ||
152 | .user_data = user_data, | ||
153 | .output = output, | ||
154 | .view = view, | ||
155 | .ox = view->container->surface_x - output->lx | ||
156 | - view->geometry.x, | ||
157 | .oy = view->container->surface_y - output->ly | ||
158 | - view->geometry.y, | ||
159 | .width = view->container->current.content_width, | ||
160 | .height = view->container->current.content_height, | ||
161 | }; | ||
162 | |||
163 | view_for_each_surface(view, output_for_each_surface_iterator, &data); | ||
164 | } | ||
165 | |||
166 | void output_view_for_each_popup_surface(struct sway_output *output, | ||
167 | struct sway_view *view, sway_surface_iterator_func_t iterator, | ||
168 | void *user_data) { | ||
169 | struct surface_iterator_data data = { | ||
170 | .user_iterator = iterator, | ||
171 | .user_data = user_data, | ||
172 | .output = output, | ||
173 | .view = view, | ||
174 | .ox = view->container->surface_x - output->lx | ||
175 | - view->geometry.x, | ||
176 | .oy = view->container->surface_y - output->ly | ||
177 | - view->geometry.y, | ||
178 | .width = view->container->current.content_width, | ||
179 | .height = view->container->current.content_height, | ||
180 | }; | ||
181 | |||
182 | view_for_each_popup_surface(view, output_for_each_surface_iterator, &data); | ||
183 | } | ||
184 | |||
185 | static int scale_length(int length, int offset, float scale) { | ||
186 | return roundf((offset + length) * scale) - roundf(offset * scale); | ||
187 | } | ||
188 | |||
189 | void scale_box(struct wlr_box *box, float scale) { | ||
190 | box->width = scale_length(box->width, box->x, scale); | ||
191 | box->height = scale_length(box->height, box->y, scale); | ||
192 | box->x = roundf(box->x * scale); | ||
193 | box->y = roundf(box->y * scale); | ||
194 | } | ||
195 | 74 | ||
196 | struct sway_workspace *output_get_active_workspace(struct sway_output *output) { | 75 | struct sway_workspace *output_get_active_workspace(struct sway_output *output) { |
197 | struct sway_seat *seat = input_manager_current_seat(); | 76 | struct sway_seat *seat = input_manager_current_seat(); |
@@ -339,9 +218,6 @@ static int output_repaint_timer_handler(void *data) { | |||
339 | } | 218 | } |
340 | 219 | ||
341 | wlr_scene_output_commit(output->scene_output, NULL); | 220 | wlr_scene_output_commit(output->scene_output, NULL); |
342 | |||
343 | wlr_damage_ring_rotate(&output->damage_ring); | ||
344 | |||
345 | return 0; | 221 | return 0; |
346 | } | 222 | } |
347 | 223 | ||
@@ -409,107 +285,6 @@ static void handle_frame(struct wl_listener *listener, void *user_data) { | |||
409 | wlr_scene_output_for_each_buffer(output->scene_output, send_frame_done_iterator, &data); | 285 | wlr_scene_output_for_each_buffer(output->scene_output, send_frame_done_iterator, &data); |
410 | } | 286 | } |
411 | 287 | ||
412 | void output_damage_whole(struct sway_output *output) { | ||
413 | // The output can exist with no wlr_output if it's just been disconnected | ||
414 | // and the transaction to evacuate it has't completed yet. | ||
415 | if (output != NULL && output->wlr_output != NULL) { | ||
416 | wlr_damage_ring_add_whole(&output->damage_ring); | ||
417 | wlr_output_schedule_frame(output->wlr_output); | ||
418 | } | ||
419 | } | ||
420 | |||
421 | static void damage_surface_iterator(struct sway_output *output, | ||
422 | struct sway_view *view, struct wlr_surface *surface, | ||
423 | struct wlr_box *_box, void *_data) { | ||
424 | bool *data = _data; | ||
425 | bool whole = *data; | ||
426 | |||
427 | struct wlr_box box = *_box; | ||
428 | scale_box(&box, output->wlr_output->scale); | ||
429 | |||
430 | pixman_region32_t damage; | ||
431 | pixman_region32_init(&damage); | ||
432 | wlr_surface_get_effective_damage(surface, &damage); | ||
433 | wlr_region_scale(&damage, &damage, output->wlr_output->scale); | ||
434 | if (ceilf(output->wlr_output->scale) > surface->current.scale) { | ||
435 | // When scaling up a surface, it'll become blurry so we need to | ||
436 | // expand the damage region | ||
437 | wlr_region_expand(&damage, &damage, | ||
438 | ceilf(output->wlr_output->scale) - surface->current.scale); | ||
439 | } | ||
440 | pixman_region32_translate(&damage, box.x, box.y); | ||
441 | if (wlr_damage_ring_add(&output->damage_ring, &damage)) { | ||
442 | wlr_output_schedule_frame(output->wlr_output); | ||
443 | } | ||
444 | pixman_region32_fini(&damage); | ||
445 | |||
446 | if (whole) { | ||
447 | if (wlr_damage_ring_add_box(&output->damage_ring, &box)) { | ||
448 | wlr_output_schedule_frame(output->wlr_output); | ||
449 | } | ||
450 | } | ||
451 | |||
452 | if (!wl_list_empty(&surface->current.frame_callback_list)) { | ||
453 | wlr_output_schedule_frame(output->wlr_output); | ||
454 | } | ||
455 | } | ||
456 | |||
457 | void output_damage_surface(struct sway_output *output, double ox, double oy, | ||
458 | struct wlr_surface *surface, bool whole) { | ||
459 | output_surface_for_each_surface(output, surface, ox, oy, | ||
460 | damage_surface_iterator, &whole); | ||
461 | } | ||
462 | |||
463 | void output_damage_from_view(struct sway_output *output, | ||
464 | struct sway_view *view) { | ||
465 | if (!view_is_visible(view)) { | ||
466 | return; | ||
467 | } | ||
468 | bool whole = false; | ||
469 | output_view_for_each_surface(output, view, damage_surface_iterator, &whole); | ||
470 | } | ||
471 | |||
472 | // Expecting an unscaled box in layout coordinates | ||
473 | void output_damage_box(struct sway_output *output, struct wlr_box *_box) { | ||
474 | struct wlr_box box; | ||
475 | memcpy(&box, _box, sizeof(struct wlr_box)); | ||
476 | box.x -= output->lx; | ||
477 | box.y -= output->ly; | ||
478 | scale_box(&box, output->wlr_output->scale); | ||
479 | if (wlr_damage_ring_add_box(&output->damage_ring, &box)) { | ||
480 | wlr_output_schedule_frame(output->wlr_output); | ||
481 | } | ||
482 | } | ||
483 | |||
484 | static void damage_child_views_iterator(struct sway_container *con, | ||
485 | void *data) { | ||
486 | if (!con->view || !view_is_visible(con->view)) { | ||
487 | return; | ||
488 | } | ||
489 | struct sway_output *output = data; | ||
490 | bool whole = true; | ||
491 | output_view_for_each_surface(output, con->view, damage_surface_iterator, | ||
492 | &whole); | ||
493 | } | ||
494 | |||
495 | void output_damage_whole_container(struct sway_output *output, | ||
496 | struct sway_container *con) { | ||
497 | // Pad the box by 1px, because the width is a double and might be a fraction | ||
498 | struct wlr_box box = { | ||
499 | .x = con->current.x - output->lx - 1, | ||
500 | .y = con->current.y - output->ly - 1, | ||
501 | .width = con->current.width + 2, | ||
502 | .height = con->current.height + 2, | ||
503 | }; | ||
504 | scale_box(&box, output->wlr_output->scale); | ||
505 | // Damage subsurfaces as well, which may extend outside the box | ||
506 | if (con->view) { | ||
507 | damage_child_views_iterator(con, output); | ||
508 | } else { | ||
509 | container_for_each_child(con, damage_child_views_iterator, output); | ||
510 | } | ||
511 | } | ||
512 | |||
513 | static void update_output_manager_config(struct sway_server *server) { | 288 | static void update_output_manager_config(struct sway_server *server) { |
514 | struct wlr_output_configuration_v1 *config = | 289 | struct wlr_output_configuration_v1 *config = |
515 | wlr_output_configuration_v1_create(); | 290 | wlr_output_configuration_v1_create(); |
@@ -553,8 +328,6 @@ static void begin_destroy(struct sway_output *output) { | |||
553 | wl_list_remove(&output->frame.link); | 328 | wl_list_remove(&output->frame.link); |
554 | wl_list_remove(&output->request_state.link); | 329 | wl_list_remove(&output->request_state.link); |
555 | 330 | ||
556 | wlr_damage_ring_finish(&output->damage_ring); | ||
557 | |||
558 | wlr_scene_output_destroy(output->scene_output); | 331 | wlr_scene_output_destroy(output->scene_output); |
559 | output->scene_output = NULL; | 332 | output->scene_output = NULL; |
560 | output->wlr_output->data = NULL; | 333 | output->wlr_output->data = NULL; |
@@ -594,15 +367,6 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
594 | update_output_manager_config(output->server); | 367 | update_output_manager_config(output->server); |
595 | } | 368 | } |
596 | 369 | ||
597 | if (event->state->committed & ( | ||
598 | WLR_OUTPUT_STATE_MODE | | ||
599 | WLR_OUTPUT_STATE_TRANSFORM)) { | ||
600 | int width, height; | ||
601 | wlr_output_transformed_resolution(output->wlr_output, &width, &height); | ||
602 | wlr_damage_ring_set_bounds(&output->damage_ring, width, height); | ||
603 | wlr_output_schedule_frame(output->wlr_output); | ||
604 | } | ||
605 | |||
606 | // Next time the output is enabled, try to re-apply the gamma LUT | 370 | // Next time the output is enabled, try to re-apply the gamma LUT |
607 | if ((event->state->committed & WLR_OUTPUT_STATE_ENABLED) && !output->wlr_output->enabled) { | 371 | if ((event->state->committed & WLR_OUTPUT_STATE_ENABLED) && !output->wlr_output->enabled) { |
608 | output->gamma_lut_changed = true; | 372 | output->gamma_lut_changed = true; |
@@ -684,7 +448,6 @@ void handle_new_output(struct wl_listener *listener, void *data) { | |||
684 | 448 | ||
685 | output->server = server; | 449 | output->server = server; |
686 | output->scene_output = scene_output; | 450 | output->scene_output = scene_output; |
687 | wlr_damage_ring_init(&output->damage_ring); | ||
688 | 451 | ||
689 | wl_signal_add(&root->output_layout->events.destroy, &output->layout_destroy); | 452 | wl_signal_add(&root->output_layout->events.destroy, &output->layout_destroy); |
690 | output->layout_destroy.notify = handle_layout_destroy; | 453 | output->layout_destroy.notify = handle_layout_destroy; |
@@ -712,9 +475,6 @@ void handle_new_output(struct wl_listener *listener, void *data) { | |||
712 | 475 | ||
713 | transaction_commit_dirty(); | 476 | transaction_commit_dirty(); |
714 | 477 | ||
715 | int width, height; | ||
716 | wlr_output_transformed_resolution(output->wlr_output, &width, &height); | ||
717 | wlr_damage_ring_set_bounds(&output->damage_ring, width, height); | ||
718 | update_output_manager_config(server); | 478 | update_output_manager_config(server); |
719 | } | 479 | } |
720 | 480 | ||