diff options
author | Simon Ser <contact@emersion.fr> | 2023-02-22 18:38:19 +0100 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2023-02-22 13:37:44 -0500 |
commit | c2ccc0c9d4726a2d1f23f1696c7b6aa0f6cb1a63 (patch) | |
tree | bd5c40f008c3f74dbe2c22ab047dc7b0721da51c | |
parent | Constify pixman_region32_t for rendering functions (diff) | |
download | sway-c2ccc0c9d4726a2d1f23f1696c7b6aa0f6cb1a63.tar.gz sway-c2ccc0c9d4726a2d1f23f1696c7b6aa0f6cb1a63.tar.zst sway-c2ccc0c9d4726a2d1f23f1696c7b6aa0f6cb1a63.zip |
Move output commit out of output_render()
That way output_render() only does what it says on the tin.
-rw-r--r-- | include/sway/output.h | 3 | ||||
-rw-r--r-- | sway/desktop/output.c | 39 | ||||
-rw-r--r-- | sway/desktop/render.c | 29 |
3 files changed, 38 insertions, 33 deletions
diff --git a/include/sway/output.h b/include/sway/output.h index da625315..2aa1b278 100644 --- a/include/sway/output.h +++ b/include/sway/output.h | |||
@@ -112,8 +112,7 @@ bool output_has_opaque_overlay_layer_surface(struct sway_output *output); | |||
112 | 112 | ||
113 | struct sway_workspace *output_get_active_workspace(struct sway_output *output); | 113 | struct sway_workspace *output_get_active_workspace(struct sway_output *output); |
114 | 114 | ||
115 | void output_render(struct sway_output *output, struct timespec *when, | 115 | void output_render(struct sway_output *output, pixman_region32_t *damage); |
116 | pixman_region32_t *damage); | ||
117 | 116 | ||
118 | void output_surface_for_each_surface(struct sway_output *output, | 117 | void output_surface_for_each_surface(struct sway_output *output, |
119 | struct wlr_surface *surface, double ox, double oy, | 118 | struct wlr_surface *surface, double ox, double oy, |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 302f9fda..4b6e9122 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -517,13 +517,34 @@ static bool scan_out_fullscreen_view(struct sway_output *output, | |||
517 | return wlr_output_commit(wlr_output); | 517 | return wlr_output_commit(wlr_output); |
518 | } | 518 | } |
519 | 519 | ||
520 | static void get_frame_damage(struct sway_output *output, | ||
521 | pixman_region32_t *frame_damage) { | ||
522 | struct wlr_output *wlr_output = output->wlr_output; | ||
523 | |||
524 | int width, height; | ||
525 | wlr_output_transformed_resolution(wlr_output, &width, &height); | ||
526 | |||
527 | pixman_region32_init(frame_damage); | ||
528 | |||
529 | enum wl_output_transform transform = | ||
530 | wlr_output_transform_invert(wlr_output->transform); | ||
531 | wlr_region_transform(frame_damage, &output->damage_ring.current, | ||
532 | transform, width, height); | ||
533 | |||
534 | if (debug.damage != DAMAGE_DEFAULT) { | ||
535 | pixman_region32_union_rect(frame_damage, frame_damage, | ||
536 | 0, 0, wlr_output->width, wlr_output->height); | ||
537 | } | ||
538 | } | ||
539 | |||
520 | static int output_repaint_timer_handler(void *data) { | 540 | static int output_repaint_timer_handler(void *data) { |
521 | struct sway_output *output = data; | 541 | struct sway_output *output = data; |
522 | if (output->wlr_output == NULL) { | 542 | struct wlr_output *wlr_output = output->wlr_output; |
543 | if (wlr_output == NULL) { | ||
523 | return 0; | 544 | return 0; |
524 | } | 545 | } |
525 | 546 | ||
526 | output->wlr_output->frame_pending = false; | 547 | wlr_output->frame_pending = false; |
527 | 548 | ||
528 | struct sway_workspace *workspace = output->current.active_workspace; | 549 | struct sway_workspace *workspace = output->current.active_workspace; |
529 | if (workspace == NULL) { | 550 | if (workspace == NULL) { |
@@ -575,10 +596,22 @@ static int output_repaint_timer_handler(void *data) { | |||
575 | struct timespec now; | 596 | struct timespec now; |
576 | clock_gettime(CLOCK_MONOTONIC, &now); | 597 | clock_gettime(CLOCK_MONOTONIC, &now); |
577 | 598 | ||
578 | output_render(output, &now, &damage); | 599 | output_render(output, &damage); |
579 | 600 | ||
580 | pixman_region32_fini(&damage); | 601 | pixman_region32_fini(&damage); |
581 | 602 | ||
603 | pixman_region32_t frame_damage; | ||
604 | get_frame_damage(output, &frame_damage); | ||
605 | wlr_output_set_damage(wlr_output, &frame_damage); | ||
606 | pixman_region32_fini(&frame_damage); | ||
607 | |||
608 | if (!wlr_output_commit(wlr_output)) { | ||
609 | return 0; | ||
610 | } | ||
611 | |||
612 | wlr_damage_ring_rotate(&output->damage_ring); | ||
613 | output->last_frame = now; | ||
614 | |||
582 | return 0; | 615 | return 0; |
583 | } | 616 | } |
584 | 617 | ||
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index dedaa967..a4d633e0 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c | |||
@@ -1029,8 +1029,7 @@ static void render_seatops(struct sway_output *output, | |||
1029 | } | 1029 | } |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | void output_render(struct sway_output *output, struct timespec *when, | 1032 | void output_render(struct sway_output *output, pixman_region32_t *damage) { |
1033 | pixman_region32_t *damage) { | ||
1034 | struct wlr_output *wlr_output = output->wlr_output; | 1033 | struct wlr_output *wlr_output = output->wlr_output; |
1035 | struct wlr_renderer *renderer = output->server->renderer; | 1034 | struct wlr_renderer *renderer = output->server->renderer; |
1036 | 1035 | ||
@@ -1184,30 +1183,4 @@ renderer_end: | |||
1184 | wlr_renderer_scissor(renderer, NULL); | 1183 | wlr_renderer_scissor(renderer, NULL); |
1185 | wlr_output_render_software_cursors(wlr_output, damage); | 1184 | wlr_output_render_software_cursors(wlr_output, damage); |
1186 | wlr_renderer_end(renderer); | 1185 | wlr_renderer_end(renderer); |
1187 | |||
1188 | int width, height; | ||
1189 | wlr_output_transformed_resolution(wlr_output, &width, &height); | ||
1190 | |||
1191 | pixman_region32_t frame_damage; | ||
1192 | pixman_region32_init(&frame_damage); | ||
1193 | |||
1194 | enum wl_output_transform transform = | ||
1195 | wlr_output_transform_invert(wlr_output->transform); | ||
1196 | wlr_region_transform(&frame_damage, &output->damage_ring.current, | ||
1197 | transform, width, height); | ||
1198 | |||
1199 | if (debug.damage != DAMAGE_DEFAULT) { | ||
1200 | pixman_region32_union_rect(&frame_damage, &frame_damage, | ||
1201 | 0, 0, wlr_output->width, wlr_output->height); | ||
1202 | } | ||
1203 | |||
1204 | wlr_output_set_damage(wlr_output, &frame_damage); | ||
1205 | pixman_region32_fini(&frame_damage); | ||
1206 | |||
1207 | if (!wlr_output_commit(wlr_output)) { | ||
1208 | return; | ||
1209 | } | ||
1210 | |||
1211 | wlr_damage_ring_rotate(&output->damage_ring); | ||
1212 | output->last_frame = *when; | ||
1213 | } | 1186 | } |