diff options
author | emersion <contact@emersion.fr> | 2018-07-27 18:59:14 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2018-07-29 14:33:26 +0100 |
commit | e9d674cfd294f13a32893dd584826ed7481e05e3 (patch) | |
tree | a3aa66326c5d11a7cb86a491ac4bf49795003a98 | |
parent | wip: redesign output_layer_for_each_surface iterator (diff) | |
download | sway-e9d674cfd294f13a32893dd584826ed7481e05e3.tar.gz sway-e9d674cfd294f13a32893dd584826ed7481e05e3.tar.zst sway-e9d674cfd294f13a32893dd584826ed7481e05e3.zip |
wip: redesign output_view_for_each_surface iterator
-rw-r--r-- | include/sway/output.h | 6 | ||||
-rw-r--r-- | sway/desktop/output.c | 75 | ||||
-rw-r--r-- | sway/desktop/render.c | 3 |
3 files changed, 66 insertions, 18 deletions
diff --git a/include/sway/output.h b/include/sway/output.h index c1763b26..7a458a84 100644 --- a/include/sway/output.h +++ b/include/sway/output.h | |||
@@ -89,9 +89,9 @@ void output_surface_for_each_surface2(struct sway_output *output, | |||
89 | struct wlr_surface *surface, double ox, double oy, float rotation, | 89 | struct wlr_surface *surface, double ox, double oy, float rotation, |
90 | sway_surface_iterator_func_t iterator, void *user_data); | 90 | sway_surface_iterator_func_t iterator, void *user_data); |
91 | 91 | ||
92 | void output_view_for_each_surface(struct sway_view *view, | 92 | void output_view_for_each_surface(struct sway_output *output, |
93 | struct sway_output *output, struct root_geometry *geo, | 93 | struct sway_view *view, sway_surface_iterator_func_t iterator, |
94 | wlr_surface_iterator_func_t iterator, void *user_data); | 94 | void *user_data); |
95 | 95 | ||
96 | void output_layer_for_each_surface(struct sway_output *output, | 96 | void output_layer_for_each_surface(struct sway_output *output, |
97 | struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator, | 97 | struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator, |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 5e309250..31033ee3 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -155,16 +155,22 @@ void output_surface_for_each_surface2(struct sway_output *output, | |||
155 | output_surface_for_each_surface2_iterator, &data); | 155 | output_surface_for_each_surface2_iterator, &data); |
156 | } | 156 | } |
157 | 157 | ||
158 | void output_view_for_each_surface(struct sway_view *view, | 158 | void output_view_for_each_surface(struct sway_output *output, |
159 | struct sway_output *output, struct root_geometry *geo, | 159 | struct sway_view *view, sway_surface_iterator_func_t iterator, |
160 | wlr_surface_iterator_func_t iterator, void *user_data) { | 160 | void *user_data) { |
161 | geo->x = view->swayc->current.view_x - output->swayc->current.swayc_x; | 161 | struct surface_iterator_data data = { |
162 | geo->y = view->swayc->current.view_y - output->swayc->current.swayc_y; | 162 | .user_iterator = iterator, |
163 | geo->width = view->swayc->current.view_width; | 163 | .user_data = user_data, |
164 | geo->height = view->swayc->current.view_height; | 164 | .output = output, |
165 | geo->rotation = 0; // TODO | 165 | .ox = view->swayc->current.view_x - output->swayc->current.swayc_x, |
166 | .oy = view->swayc->current.view_y - output->swayc->current.swayc_y, | ||
167 | .width = view->swayc->current.view_width, | ||
168 | .height = view->swayc->current.view_height, | ||
169 | .rotation = 0, // TODO | ||
170 | }; | ||
166 | 171 | ||
167 | view_for_each_surface(view, iterator, user_data); | 172 | view_for_each_surface(view, |
173 | output_surface_for_each_surface2_iterator, &data); | ||
168 | } | 174 | } |
169 | 175 | ||
170 | void output_layer_for_each_surface(struct sway_output *output, | 176 | void output_layer_for_each_surface(struct sway_output *output, |
@@ -319,8 +325,8 @@ static void send_frame_done_container_iterator(struct sway_container *con, | |||
319 | return; | 325 | return; |
320 | } | 326 | } |
321 | 327 | ||
322 | output_view_for_each_surface(con->sway_view, data->output, &data->root_geo, | 328 | output_view_for_each_surface(data->output, con->sway_view, |
323 | send_frame_done_iterator, data); | 329 | send_frame_done_iterator2, data); |
324 | } | 330 | } |
325 | 331 | ||
326 | static void send_frame_done_container(struct send_frame_done_data *data, | 332 | static void send_frame_done_container(struct send_frame_done_data *data, |
@@ -463,6 +469,50 @@ static void damage_surface_iterator(struct wlr_surface *surface, int sx, int sy, | |||
463 | wlr_output_schedule_frame(output->wlr_output); | 469 | wlr_output_schedule_frame(output->wlr_output); |
464 | } | 470 | } |
465 | 471 | ||
472 | static void damage_surface_iterator2(struct sway_output *output, | ||
473 | struct wlr_surface *surface, struct wlr_box *_box, float rotation, | ||
474 | void *_data) { | ||
475 | struct damage_data *data = _data; | ||
476 | bool whole = data->whole; | ||
477 | |||
478 | struct wlr_box box = *_box; | ||
479 | scale_box(&box, output->wlr_output->scale); | ||
480 | |||
481 | int center_x = box.x + box.width/2; | ||
482 | int center_y = box.y + box.height/2; | ||
483 | |||
484 | if (pixman_region32_not_empty(&surface->buffer_damage)) { | ||
485 | enum wl_output_transform transform = | ||
486 | wlr_output_transform_invert(surface->current.transform); | ||
487 | |||
488 | pixman_region32_t damage; | ||
489 | pixman_region32_init(&damage); | ||
490 | pixman_region32_copy(&damage, &surface->buffer_damage); | ||
491 | wlr_region_transform(&damage, &damage, transform, | ||
492 | surface->current.buffer_width, surface->current.buffer_height); | ||
493 | wlr_region_scale(&damage, &damage, | ||
494 | output->wlr_output->scale / (float)surface->current.scale); | ||
495 | if (ceil(output->wlr_output->scale) > surface->current.scale) { | ||
496 | // When scaling up a surface, it'll become blurry so we need to | ||
497 | // expand the damage region | ||
498 | wlr_region_expand(&damage, &damage, | ||
499 | ceil(output->wlr_output->scale) - surface->current.scale); | ||
500 | } | ||
501 | pixman_region32_translate(&damage, box.x, box.y); | ||
502 | wlr_region_rotated_bounds(&damage, &damage, rotation, | ||
503 | center_x, center_y); | ||
504 | wlr_output_damage_add(output->damage, &damage); | ||
505 | pixman_region32_fini(&damage); | ||
506 | } | ||
507 | |||
508 | if (whole) { | ||
509 | wlr_box_rotated_bounds(&box, rotation, &box); | ||
510 | wlr_output_damage_add_box(output->damage, &box); | ||
511 | } | ||
512 | |||
513 | wlr_output_schedule_frame(output->wlr_output); | ||
514 | } | ||
515 | |||
466 | void output_damage_surface(struct sway_output *output, double ox, double oy, | 516 | void output_damage_surface(struct sway_output *output, double ox, double oy, |
467 | struct wlr_surface *surface, bool whole) { | 517 | struct wlr_surface *surface, bool whole) { |
468 | struct damage_data data = { | 518 | struct damage_data data = { |
@@ -489,8 +539,7 @@ static void output_damage_view(struct sway_output *output, | |||
489 | .whole = whole, | 539 | .whole = whole, |
490 | }; | 540 | }; |
491 | 541 | ||
492 | output_view_for_each_surface(view, output, &data.root_geo, | 542 | output_view_for_each_surface(output, view, damage_surface_iterator2, &data); |
493 | damage_surface_iterator, &data); | ||
494 | } | 543 | } |
495 | 544 | ||
496 | void output_damage_from_view(struct sway_output *output, | 545 | void output_damage_from_view(struct sway_output *output, |
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 35dc3edc..18d076df 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c | |||
@@ -231,8 +231,7 @@ static void render_view_surfaces(struct sway_view *view, | |||
231 | .view = view, | 231 | .view = view, |
232 | .alpha = alpha, | 232 | .alpha = alpha, |
233 | }; | 233 | }; |
234 | output_view_for_each_surface(view, output, &data.root_geo, | 234 | output_view_for_each_surface(output, view, render_surface_iterator2, &data); |
235 | render_surface_iterator, &data); | ||
236 | } | 235 | } |
237 | 236 | ||
238 | static void render_saved_view(struct sway_view *view, | 237 | static void render_saved_view(struct sway_view *view, |