Skip to content

Commit

Permalink
style: moved damage creation to function
Browse files Browse the repository at this point in the history
  • Loading branch information
WillPower3309 committed Apr 4, 2023
1 parent 41df328 commit c24fccd
Showing 1 changed file with 14 additions and 25 deletions.
39 changes: 14 additions & 25 deletions sway/desktop/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,23 @@ static void set_scale_filter(struct wlr_output *wlr_output,
}
}

pixman_region32_t create_damage(const struct wlr_box damage_box, pixman_region32_t *output_damage) {
pixman_region32_t damage;
pixman_region32_init(&damage);
pixman_region32_union_rect(&damage, &damage, damage_box.x, damage_box.y,
damage_box.width, damage_box.height);
pixman_region32_intersect(&damage, &damage, output_damage);
return damage;
}

static void render_texture(struct wlr_output *wlr_output,
pixman_region32_t *output_damage, struct wlr_texture *texture,
const struct wlr_fbox *src_box, const struct wlr_box *dst_box,
const float matrix[static 9], struct decoration_data deco_data) {
struct sway_output *output = wlr_output->data;
struct fx_renderer *renderer = output->server->renderer;

pixman_region32_t damage;
pixman_region32_init(&damage);
pixman_region32_union_rect(&damage, &damage, dst_box->x, dst_box->y,
dst_box->width, dst_box->height);
pixman_region32_intersect(&damage, &damage, output_damage);
pixman_region32_t damage = create_damage(*dst_box, output_damage);
bool damaged = pixman_region32_not_empty(&damage);
if (!damaged) {
goto damage_finish;
Expand Down Expand Up @@ -242,11 +247,7 @@ void render_rect(struct sway_output *output,
box.x -= output->lx * wlr_output->scale;
box.y -= output->ly * wlr_output->scale;

pixman_region32_t damage;
pixman_region32_init(&damage);
pixman_region32_union_rect(&damage, &damage, box.x, box.y,
box.width, box.height);
pixman_region32_intersect(&damage, &damage, output_damage);
pixman_region32_t damage = create_damage(box, output_damage);
bool damaged = pixman_region32_not_empty(&damage);
if (!damaged) {
goto damage_finish;
Expand Down Expand Up @@ -274,11 +275,7 @@ void render_rounded_rect(struct sway_output *output, pixman_region32_t *output_d
box.x -= output->lx * wlr_output->scale;
box.y -= output->ly * wlr_output->scale;

pixman_region32_t damage;
pixman_region32_init(&damage);
pixman_region32_union_rect(&damage, &damage, box.x, box.y,
box.width, box.height);
pixman_region32_intersect(&damage, &damage, output_damage);
pixman_region32_t damage = create_damage(box, output_damage);
bool damaged = pixman_region32_not_empty(&damage);
if (!damaged) {
goto damage_finish;
Expand Down Expand Up @@ -309,11 +306,7 @@ void render_border_corner(struct sway_output *output, pixman_region32_t *output_
box.x -= output->lx * wlr_output->scale;
box.y -= output->ly * wlr_output->scale;

pixman_region32_t damage;
pixman_region32_init(&damage);
pixman_region32_union_rect(&damage, &damage, box.x, box.y,
box.width, box.height);
pixman_region32_intersect(&damage, &damage, output_damage);
pixman_region32_t damage = create_damage(box, output_damage);
bool damaged = pixman_region32_not_empty(&damage);
if (!damaged) {
goto damage_finish;
Expand Down Expand Up @@ -349,11 +342,7 @@ void render_box_shadow(struct sway_output *output, pixman_region32_t *output_dam
// Uses the outer radii of the window for a more realistic look
corner_radius = corner_radius + border_thickness;

pixman_region32_t damage;
pixman_region32_init(&damage);
pixman_region32_union_rect(&damage, &damage, box.x, box.y,
box.width, box.height);
pixman_region32_intersect(&damage, &damage, output_damage);
pixman_region32_t damage = create_damage(box, output_damage);
bool damaged = pixman_region32_not_empty(&damage);
if (!damaged) {
goto damage_finish;
Expand Down

0 comments on commit c24fccd

Please sign in to comment.