diff options
author | Ivan Molodetskikh <yalterz@gmail.com> | 2019-09-25 17:35:41 +0300 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2019-11-17 20:18:42 +0100 |
commit | bd9a53f1a3e7dba247aab0a4e4268724acc12c38 (patch) | |
tree | 1547b79a82b1c4e22512d0262cbb133a14ef10a3 /sway/desktop/output.c | |
parent | Add sway_surface (diff) | |
download | sway-bd9a53f1a3e7dba247aab0a4e4268724acc12c38.tar.gz sway-bd9a53f1a3e7dba247aab0a4e4268724acc12c38.tar.zst sway-bd9a53f1a3e7dba247aab0a4e4268724acc12c38.zip |
view: add max_render_time
Diffstat (limited to 'sway/desktop/output.c')
-rw-r--r-- | sway/desktop/output.c | 55 |
1 files changed, 41 insertions, 14 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 0f715c19..6498198b 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include "sway/layers.h" | 23 | #include "sway/layers.h" |
24 | #include "sway/output.h" | 24 | #include "sway/output.h" |
25 | #include "sway/server.h" | 25 | #include "sway/server.h" |
26 | #include "sway/surface.h" | ||
26 | #include "sway/tree/arrange.h" | 27 | #include "sway/tree/arrange.h" |
27 | #include "sway/tree/container.h" | 28 | #include "sway/tree/container.h" |
28 | #include "sway/tree/root.h" | 29 | #include "sway/tree/root.h" |
@@ -80,6 +81,7 @@ struct surface_iterator_data { | |||
80 | void *user_data; | 81 | void *user_data; |
81 | 82 | ||
82 | struct sway_output *output; | 83 | struct sway_output *output; |
84 | struct sway_view *view; | ||
83 | double ox, oy; | 85 | double ox, oy; |
84 | int width, height; | 86 | int width, height; |
85 | float rotation; | 87 | float rotation; |
@@ -134,7 +136,7 @@ static void output_for_each_surface_iterator(struct wlr_surface *surface, | |||
134 | return; | 136 | return; |
135 | } | 137 | } |
136 | 138 | ||
137 | data->user_iterator(data->output, surface, &box, data->rotation, | 139 | data->user_iterator(data->output, data->view, surface, &box, data->rotation, |
138 | data->user_data); | 140 | data->user_data); |
139 | } | 141 | } |
140 | 142 | ||
@@ -145,6 +147,7 @@ void output_surface_for_each_surface(struct sway_output *output, | |||
145 | .user_iterator = iterator, | 147 | .user_iterator = iterator, |
146 | .user_data = user_data, | 148 | .user_data = user_data, |
147 | .output = output, | 149 | .output = output, |
150 | .view = NULL, | ||
148 | .ox = ox, | 151 | .ox = ox, |
149 | .oy = oy, | 152 | .oy = oy, |
150 | .width = surface->current.width, | 153 | .width = surface->current.width, |
@@ -163,6 +166,7 @@ void output_view_for_each_surface(struct sway_output *output, | |||
163 | .user_iterator = iterator, | 166 | .user_iterator = iterator, |
164 | .user_data = user_data, | 167 | .user_data = user_data, |
165 | .output = output, | 168 | .output = output, |
169 | .view = view, | ||
166 | .ox = view->container->surface_x - output->lx | 170 | .ox = view->container->surface_x - output->lx |
167 | - view->geometry.x, | 171 | - view->geometry.x, |
168 | .oy = view->container->surface_y - output->ly | 172 | .oy = view->container->surface_y - output->ly |
@@ -182,6 +186,7 @@ void output_view_for_each_popup(struct sway_output *output, | |||
182 | .user_iterator = iterator, | 186 | .user_iterator = iterator, |
183 | .user_data = user_data, | 187 | .user_data = user_data, |
184 | .output = output, | 188 | .output = output, |
189 | .view = view, | ||
185 | .ox = view->container->surface_x - output->lx | 190 | .ox = view->container->surface_x - output->lx |
186 | - view->geometry.x, | 191 | - view->geometry.x, |
187 | .oy = view->container->surface_y - output->ly | 192 | .oy = view->container->surface_y - output->ly |
@@ -224,6 +229,7 @@ void output_layer_for_each_surface(struct sway_output *output, | |||
224 | .user_iterator = iterator, | 229 | .user_iterator = iterator, |
225 | .user_data = user_data, | 230 | .user_data = user_data, |
226 | .output = output, | 231 | .output = output, |
232 | .view = NULL, | ||
227 | .ox = popup_sx, | 233 | .ox = popup_sx, |
228 | .oy = popup_sy, | 234 | .oy = popup_sy, |
229 | .width = surface->current.width, | 235 | .width = surface->current.width, |
@@ -291,6 +297,7 @@ static void output_for_each_surface(struct sway_output *output, | |||
291 | .user_iterator = iterator, | 297 | .user_iterator = iterator, |
292 | .user_data = user_data, | 298 | .user_data = user_data, |
293 | .output = output, | 299 | .output = output, |
300 | .view = NULL, | ||
294 | }; | 301 | }; |
295 | 302 | ||
296 | struct sway_workspace *workspace = output_get_active_workspace(output); | 303 | struct sway_workspace *workspace = output_get_active_workspace(output); |
@@ -401,18 +408,37 @@ bool output_has_opaque_overlay_layer_surface(struct sway_output *output) { | |||
401 | return false; | 408 | return false; |
402 | } | 409 | } |
403 | 410 | ||
404 | static void send_frame_done_iterator(struct sway_output *output, | 411 | struct send_frame_done_data { |
412 | struct timespec when; | ||
413 | int msec_until_refresh; | ||
414 | }; | ||
415 | |||
416 | static void send_frame_done_iterator(struct sway_output *output, struct sway_view *view, | ||
405 | struct wlr_surface *surface, struct wlr_box *box, float rotation, | 417 | struct wlr_surface *surface, struct wlr_box *box, float rotation, |
406 | void *data) { | 418 | void *user_data) { |
407 | struct timespec *when = data; | 419 | int view_max_render_time = 0; |
408 | wlr_surface_send_frame_done(surface, when); | 420 | if (view != NULL) { |
421 | view_max_render_time = view->max_render_time; | ||
422 | } | ||
423 | |||
424 | struct send_frame_done_data *data = user_data; | ||
425 | |||
426 | int delay = data->msec_until_refresh - output->max_render_time | ||
427 | - view_max_render_time; | ||
428 | |||
429 | if (output->max_render_time == 0 || view_max_render_time == 0 || delay < 1) { | ||
430 | wlr_surface_send_frame_done(surface, &data->when); | ||
431 | } else { | ||
432 | struct sway_surface *sway_surface = surface->data; | ||
433 | wl_event_source_timer_update(sway_surface->frame_done_timer, delay); | ||
434 | } | ||
409 | } | 435 | } |
410 | 436 | ||
411 | static void send_frame_done(struct sway_output *output, struct timespec *when) { | 437 | static void send_frame_done(struct sway_output *output, struct send_frame_done_data *data) { |
412 | output_for_each_surface(output, send_frame_done_iterator, when); | 438 | output_for_each_surface(output, send_frame_done_iterator, data); |
413 | } | 439 | } |
414 | 440 | ||
415 | static void count_surface_iterator(struct sway_output *output, | 441 | static void count_surface_iterator(struct sway_output *output, struct sway_view *view, |
416 | struct wlr_surface *surface, struct wlr_box *_box, float rotation, | 442 | struct wlr_surface *surface, struct wlr_box *_box, float rotation, |
417 | void *data) { | 443 | void *data) { |
418 | size_t *n = data; | 444 | size_t *n = data; |
@@ -533,7 +559,7 @@ int output_repaint_timer_handler(void *data) { | |||
533 | return 0; | 559 | return 0; |
534 | } | 560 | } |
535 | 561 | ||
536 | static void damage_handle_frame(struct wl_listener *listener, void *data) { | 562 | static void damage_handle_frame(struct wl_listener *listener, void *user_data) { |
537 | struct sway_output *output = | 563 | struct sway_output *output = |
538 | wl_container_of(listener, output, damage_frame); | 564 | wl_container_of(listener, output, damage_frame); |
539 | if (!output->enabled || !output->wlr_output->enabled) { | 565 | if (!output->enabled || !output->wlr_output->enabled) { |
@@ -592,9 +618,10 @@ static void damage_handle_frame(struct wl_listener *listener, void *data) { | |||
592 | } | 618 | } |
593 | 619 | ||
594 | // Send frame done to all visible surfaces | 620 | // Send frame done to all visible surfaces |
595 | struct timespec now; | 621 | struct send_frame_done_data data = {0}; |
596 | clock_gettime(CLOCK_MONOTONIC, &now); | 622 | clock_gettime(CLOCK_MONOTONIC, &data.when); |
597 | send_frame_done(output, &now); | 623 | data.msec_until_refresh = msec_until_refresh; |
624 | send_frame_done(output, &data); | ||
598 | } | 625 | } |
599 | 626 | ||
600 | void output_damage_whole(struct sway_output *output) { | 627 | void output_damage_whole(struct sway_output *output) { |
@@ -605,7 +632,7 @@ void output_damage_whole(struct sway_output *output) { | |||
605 | } | 632 | } |
606 | } | 633 | } |
607 | 634 | ||
608 | static void damage_surface_iterator(struct sway_output *output, | 635 | static void damage_surface_iterator(struct sway_output *output, struct sway_view *view, |
609 | struct wlr_surface *surface, struct wlr_box *_box, float rotation, | 636 | struct wlr_surface *surface, struct wlr_box *_box, float rotation, |
610 | void *_data) { | 637 | void *_data) { |
611 | bool *data = _data; | 638 | bool *data = _data; |
@@ -811,7 +838,7 @@ static void handle_scale(struct wl_listener *listener, void *data) { | |||
811 | update_output_manager_config(output->server); | 838 | update_output_manager_config(output->server); |
812 | } | 839 | } |
813 | 840 | ||
814 | static void send_presented_iterator(struct sway_output *output, | 841 | static void send_presented_iterator(struct sway_output *output, struct sway_view *view, |
815 | struct wlr_surface *surface, struct wlr_box *box, float rotation, | 842 | struct wlr_surface *surface, struct wlr_box *box, float rotation, |
816 | void *data) { | 843 | void *data) { |
817 | struct wlr_presentation_event *event = data; | 844 | struct wlr_presentation_event *event = data; |