From 023333a4d1a74d3e76a29401fee265ad42f9c423 Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Fri, 26 Jun 2020 18:05:54 +0000 Subject: [PATCH] Move damage hints into buffer abstraction --- include/frame-capture.h | 7 ------- src/main.c | 17 ++++------------- src/screencopy.c | 15 +++------------ 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/include/frame-capture.h b/include/frame-capture.h index ef8ca4d..871f01e 100644 --- a/include/frame-capture.h +++ b/include/frame-capture.h @@ -51,13 +51,6 @@ struct frame_capture { uint32_t stride; } frame_info; - struct { - uint32_t x; - uint32_t y; - uint32_t width; - uint32_t height; - } damage_hint; - struct { void (*render)(struct frame_capture*, struct renderer*, struct nvnc_fb* fb); diff --git a/src/main.c b/src/main.c index 9a77234..68fd6a6 100644 --- a/src/main.c +++ b/src/main.c @@ -58,9 +58,6 @@ #define DEFAULT_ADDRESS "127.0.0.1" #define DEFAULT_PORT 5900 -#define UDIV_UP(a, b) (((a) + (b) - 1) / (b)) -#define ALIGN_UP(n, a) (UDIV_UP(n, a) * a) - struct wayvnc { bool do_exit; @@ -501,16 +498,11 @@ void wayvnc_process_frame(struct wayvnc* self) assert(height == nvnc_fb_get_height(self->buffer)); } - int damx = self->capture_backend->damage_hint.x; - int damy = self->capture_backend->damage_hint.y; - int damw = self->capture_backend->damage_hint.width; - int damh = self->capture_backend->damage_hint.height; - - struct pixman_region16 hint, txdamage, refined; - pixman_region_init_rect(&hint, damx, damy, damw, damh); + struct pixman_region16 txdamage, refined; pixman_region_init(&txdamage); pixman_region_init(&refined); - damage_refine(&self->damage_refinery, &refined, &hint, + damage_refine(&self->damage_refinery, &refined, + &self->screencopy_backend.back->damage, self->screencopy_backend.back); wv_region_transform(&txdamage, &refined, self->selected_output->transform, @@ -520,7 +512,6 @@ void wayvnc_process_frame(struct wayvnc* self) wayvnc_damage_region(self, &txdamage); pixman_region_fini(&refined); pixman_region_fini(&txdamage); - pixman_region_fini(&hint); if (wayvnc_start_capture(self, 0) < 0) { log_error("Failed to start capture. Exiting...\n"); @@ -621,7 +612,7 @@ int main(int argc, char* argv[]) bool overlay_cursor = false; - static const char* shortopts = "C:c:o:k:s:rh"; + static const char* shortopts = "C:o:k:s:rh"; int drm_fd = -1; static const struct option longopts[] = { diff --git a/src/screencopy.c b/src/screencopy.c index a906503..5952f99 100644 --- a/src/screencopy.c +++ b/src/screencopy.c @@ -157,14 +157,8 @@ static void screencopy_ready(void* data, double delay = (self->last_time - self->start_time) * 1.0e-6; self->delay = smooth(&self->delay_smoother, delay); - if (self->is_immediate_copy) { - self->frame_capture.damage_hint.x = 0; - self->frame_capture.damage_hint.y = 0; - self->frame_capture.damage_hint.width = - self->frame_capture.frame_info.width; - self->frame_capture.damage_hint.height = - self->frame_capture.frame_info.height; - } + if (self->is_immediate_copy) + wv_buffer_damage_whole(self->front); if (self->back) wv_buffer_pool_release(self->pool, self->back); @@ -198,10 +192,7 @@ static void screencopy_damage(void* data, DTRACE_PROBE1(wayvnc, screencopy_damage, self); - self->frame_capture.damage_hint.x = x; - self->frame_capture.damage_hint.y = y; - self->frame_capture.damage_hint.width = width; - self->frame_capture.damage_hint.height = height; + wv_buffer_damage_rect(self->front, x, y, width, height); } static int screencopy__start_capture(struct frame_capture* fc)