diff options
author | Simon Ser <contact@emersion.fr> | 2023-02-21 10:21:16 +0100 |
---|---|---|
committer | Alexander Orzechowski <alex@ozal.ski> | 2023-06-30 04:31:50 +0000 |
commit | 7811f22250667af4cfb38b47413319be87bf112d (patch) | |
tree | 21be8b56d04da6b79950036c7cd3c163083eb1ed /backend | |
parent | 13f096b0ace99e3709bc29ea3287afef6ebaf238 (diff) |
backend/wayland: handle output layer damage
Diffstat (limited to 'backend')
-rw-r--r-- | backend/wayland/output.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/backend/wayland/output.c b/backend/wayland/output.c index f8424868..bf668cc4 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -400,6 +400,23 @@ static void output_layer_unmap(struct wlr_wl_output_layer *layer) { layer->mapped = false; } +static void damage_surface(struct wl_surface *surface, + const pixman_region32_t *damage) { + if (damage == NULL) { + wl_surface_damage_buffer(surface, + 0, 0, INT32_MAX, INT32_MAX); + return; + } + + int rects_len; + const pixman_box32_t *rects = pixman_region32_rectangles(damage, &rects_len); + for (int i = 0; i < rects_len; i++) { + const pixman_box32_t *r = &rects[i]; + wl_surface_damage_buffer(surface, r->x1, r->y1, + r->x2 - r->x1, r->y2 - r->y1); + } +} + static bool output_layer_commit(struct wlr_wl_output *output, struct wlr_wl_output_layer *layer, const struct wlr_output_layer_state *state) { @@ -443,7 +460,7 @@ static bool output_layer_commit(struct wlr_wl_output *output, } wl_surface_attach(layer->surface, buffer->wl_buffer, 0, 0); - wl_surface_damage_buffer(layer->surface, 0, 0, INT32_MAX, INT32_MAX); + damage_surface(layer->surface, state->damage); wl_surface_commit(layer->surface); layer->mapped = true; return true; @@ -511,20 +528,7 @@ static bool output_commit(struct wlr_output *wlr_output, } wl_surface_attach(output->surface, buffer->wl_buffer, 0, 0); - - if (damage == NULL) { - wl_surface_damage_buffer(output->surface, - 0, 0, INT32_MAX, INT32_MAX); - } else { - int rects_len; - const pixman_box32_t *rects = - pixman_region32_rectangles(damage, &rects_len); - for (int i = 0; i < rects_len; i++) { - const pixman_box32_t *r = &rects[i]; - wl_surface_damage_buffer(output->surface, r->x1, r->y1, - r->x2 - r->x1, r->y2 - r->y1); - } - } + damage_surface(output->surface, damage); } if ((state->committed & WLR_OUTPUT_STATE_LAYERS) && |