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 /sway/desktop/output.c | |
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
Diffstat (limited to 'sway/desktop/output.c')
-rw-r--r-- | sway/desktop/output.c | 75 |
1 files changed, 62 insertions, 13 deletions
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, |