output: add cage_output_damage_surface

This commit is contained in:
Jente Hidskes 2020-07-04 16:06:27 +02:00
parent 5feeb33505
commit 0e9dae18e6
No known key found for this signature in database
GPG key ID: 04BE5A29F32D91EA
3 changed files with 30 additions and 19 deletions

View file

@ -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;
};

View file

@ -5,6 +5,7 @@
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_damage.h>
#include <wlr/types/wlr_surface.h>
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);

View file

@ -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