main: Extract function: window_damage_region

pull/12/head
Andri Yngvason 2022-06-29 17:22:15 +00:00
parent 47ba673c8b
commit 505b03a47e
1 changed files with 17 additions and 12 deletions

View File

@ -532,6 +532,22 @@ static void apply_buffer_damage(struct pixman_region16* damage)
&window->buffers[i]->damage, damage); &window->buffers[i]->damage, damage);
} }
static void window_damage_region(struct window* w,
struct pixman_region16* damage)
{
int n_rects = 0;
struct pixman_box16* box = pixman_region_rectangles(damage, &n_rects);
for (int i = 0; i < n_rects; ++i) {
int x = box[i].x1;
int y = box[i].y1;
int width = box[i].x2 - x;
int height = box[i].y2 - y;
window_damage(w, x, y, width, height);
}
}
void on_vnc_client_update_fb(struct vnc_client* client) void on_vnc_client_update_fb(struct vnc_client* client)
{ {
if (!pixman_region_not_empty(&client->damage) && if (!pixman_region_not_empty(&client->damage) &&
@ -558,18 +574,7 @@ void on_vnc_client_update_fb(struct vnc_client* client)
pixman_region_fini(&damage_scaled); pixman_region_fini(&damage_scaled);
apply_buffer_damage(&damage); apply_buffer_damage(&damage);
window_damage_region(window, &damage);
int n_rects = 0;
struct pixman_box16* box = pixman_region_rectangles(&damage, &n_rects);
for (int i = 0; i < n_rects; ++i) {
int x = box[i].x1;
int y = box[i].y1;
int width = box[i].x2 - x;
int height = box[i].y2 - y;
window_damage(window, x, y, width, height);
}
pixman_region_fini(&damage); pixman_region_fini(&damage);