Factor out partial view damage

The code for apply effective surface damage has been duplicated in several
places.
This commit is contained in:
raichoo 2021-03-28 15:09:13 +00:00
parent 0e0ccfbffc
commit 337400b7c9
6 changed files with 26 additions and 37 deletions

View File

@ -95,4 +95,19 @@ hikari_output_schedule_frame(struct hikari_output *output)
wlr_output_schedule_frame(output->wlr_output);
}
static inline void
hikari_output_add_effective_surface_damage(
struct hikari_output *output, struct wlr_surface *surface, int x, int y)
{
assert(surface != NULL);
assert(output->enabled);
pixman_region32_t damage;
pixman_region32_init(&damage);
wlr_surface_get_effective_damage(surface, &damage);
pixman_region32_translate(&damage, x, y);
wlr_output_damage_add(output->damage, &damage);
pixman_region32_fini(&damage);
}
#endif

View File

@ -298,12 +298,8 @@ damage(struct hikari_layer *layer, bool whole)
hikari_output_add_damage(layer->output, &geometry);
} else {
pixman_region32_t damage;
pixman_region32_init(&damage);
wlr_surface_get_effective_damage(surface, &damage);
pixman_region32_translate(&damage, layer->geometry.x, layer->geometry.y);
wlr_output_damage_add(layer->output->damage, &damage);
pixman_region32_fini(&damage);
hikari_output_add_effective_surface_damage(
layer->output, surface, layer->geometry.x, layer->geometry.y);
}
}
@ -349,12 +345,7 @@ done:
hikari_output_add_damage(output, &geometry);
} else {
pixman_region32_t damage;
pixman_region32_init(&damage);
wlr_surface_get_effective_damage(surface, &damage);
pixman_region32_translate(&damage, ox, oy);
wlr_output_damage_add(layer->output->damage, &damage);
pixman_region32_fini(&damage);
hikari_output_add_effective_surface_damage(layer->output, surface, ox, oy);
}
}

View File

@ -1620,14 +1620,9 @@ damage_surface(struct wlr_surface *surface, int sx, int sy, void *data)
damage_whole_surface(surface, sx, sy, data);
} else {
struct wlr_box *geometry = damage_data->geometry;
struct hikari_output *output = damage_data->output;
pixman_region32_t damage;
pixman_region32_init(&damage);
wlr_surface_get_effective_damage(surface, &damage);
pixman_region32_translate(&damage, geometry->x + sx, geometry->y + sy);
wlr_output_damage_add(output->damage, &damage);
pixman_region32_fini(&damage);
hikari_output_add_effective_surface_damage(
output, surface, geometry->x + sx, geometry->y + sy);
}
}

View File

@ -99,12 +99,8 @@ commit_handler(struct wl_listener *listener, void *data)
}
} else if (output->enabled) {
if (visible) {
pixman_region32_t damage;
pixman_region32_init(&damage);
wlr_surface_get_effective_damage(surface->surface, &damage);
pixman_region32_translate(&damage, geometry->x, geometry->y);
wlr_output_damage_add(output->damage, &damage);
pixman_region32_fini(&damage);
hikari_output_add_effective_surface_damage(
output, surface->surface, geometry->x, geometry->y);
} else {
hikari_output_schedule_frame(output);
}

View File

@ -47,12 +47,8 @@ commit_handler(struct wl_listener *listener, void *data)
hikari_output_add_damage(output, geometry);
} else if (output->enabled) {
pixman_region32_t damage;
pixman_region32_init(&damage);
wlr_surface_get_effective_damage(surface->surface, &damage);
pixman_region32_translate(&damage, geometry->x, geometry->y);
wlr_output_damage_add(output->damage, &damage);
pixman_region32_fini(&damage);
hikari_output_add_effective_surface_damage(
output, surface->surface, geometry->x, geometry->y);
}
}

View File

@ -113,12 +113,8 @@ commit_handler(struct wl_listener *listener, void *data)
bool visible = !hikari_view_is_hidden(view);
if (visible) {
pixman_region32_t damage;
pixman_region32_init(&damage);
wlr_surface_get_effective_damage(surface->surface, &damage);
pixman_region32_translate(&damage, geometry->x, geometry->y);
wlr_output_damage_add(output->damage, &damage);
pixman_region32_fini(&damage);
hikari_output_add_effective_surface_damage(
output, surface->surface, geometry->x, geometry->y);
} else {
hikari_output_schedule_frame(output);
}