Factor out partial view damage
The code for apply effective surface damage has been duplicated in several places.
This commit is contained in:
parent
0e0ccfbffc
commit
337400b7c9
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue