From 0e9dae18e663efd1e3b6194e1ae87e8a93cb2710 Mon Sep 17 00:00:00 2001 From: Jente Hidskes Date: Sat, 4 Jul 2020 16:06:27 +0200 Subject: [PATCH] output: add cage_output_damage_surface --- desktop/output.c | 27 +++++++++++++++++++++++++++ desktop/output.h | 2 ++ desktop/view.c | 20 +------------------- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/desktop/output.c b/desktop/output.c index 9eab6ac..984441e 100644 --- a/desktop/output.c +++ b/desktop/output.c @@ -48,6 +48,33 @@ cage_output_damage_region(struct cg_output *output, struct wlr_box *region) wlr_output_damage_add_box(output->damage, region); } +void +cage_output_damage_surface(struct cg_output *output, struct wlr_surface *surface, int sx, int sy) +{ + assert(output != NULL); + assert(surface != NULL); + struct wlr_output *wlr_output = output->wlr_output; + + assert(wlr_output->enabled); + + if (pixman_region32_not_empty(&surface->buffer_damage)) { + pixman_region32_t damage; + pixman_region32_init(&damage); + wlr_surface_get_effective_damage(surface, &damage); + + wlr_region_scale(&damage, &damage, wlr_output->scale); + if (ceil(wlr_output->scale) > surface->current.scale) { + /* When scaling up a surface it'll becomevblurry, so we + * need to expand the damage region. */ + wlr_region_expand(&damage, &damage, ceil(wlr_output->scale) - surface->current.scale); + } + + pixman_region32_translate(&damage, sx, sy); + wlr_output_damage_add(output->damage, &damage); + pixman_region32_fini(&damage); + } +} + struct send_frame_done_data { struct timespec when; }; diff --git a/desktop/output.h b/desktop/output.h index 307f3f9..fa7701a 100644 --- a/desktop/output.h +++ b/desktop/output.h @@ -5,6 +5,7 @@ #include #include #include +#include struct cg_output { struct wlr_output *wlr_output; @@ -26,6 +27,7 @@ struct cg_output { void cage_output_damage_whole(struct cg_output *output); void cage_output_damage_region(struct cg_output *output, struct wlr_box *region); +void cage_output_damage_surface(struct cg_output *output, struct wlr_surface *surface, int sx, int sy); void cage_output_get_geometry(struct cg_output *output, struct wlr_box *geometry); void cage_output_disable(struct cg_output *output); void cage_output_enable(struct cg_output *output); diff --git a/desktop/view.c b/desktop/view.c index d4f8e20..c82dbb0 100644 --- a/desktop/view.c +++ b/desktop/view.c @@ -70,25 +70,7 @@ static void damage_surface_iterator(struct wlr_surface *surface, int sx, int sy, void *user_data) { struct cg_view *view = (struct cg_view *) surface->data; - struct cg_output *output = view->output; - struct wlr_output *wlr_output = output->wlr_output; - - if (pixman_region32_not_empty(&surface->buffer_damage)) { - pixman_region32_t damage; - pixman_region32_init(&damage); - wlr_surface_get_effective_damage(surface, &damage); - - wlr_region_scale(&damage, &damage, wlr_output->scale); - if (ceil(wlr_output->scale) > surface->current.scale) { - /* When scaling up a surface it'll become - blurry, so we need to expand the damage - region. */ - wlr_region_expand(&damage, &damage, ceil(wlr_output->scale) - surface->current.scale); - } - pixman_region32_translate(&damage, sx, sy); - wlr_output_damage_add(output->damage, &damage); - pixman_region32_fini(&damage); - } + cage_output_damage_surface(view->output, surface, sx, sy); } void