Add damage checking

shader-damage
Andri Yngvason 2019-10-07 23:44:55 +00:00
parent 3ba5884954
commit c02a6512ea
1 changed files with 34 additions and 5 deletions

View File

@ -45,6 +45,9 @@ struct wayvnc {
uv_signal_t signal_handler; uv_signal_t signal_handler;
struct nvnc* nvnc; struct nvnc* nvnc;
struct nvnc_fb* current_fb;
struct nvnc_fb* last_fb;
}; };
void on_capture_done(struct dmabuf_capture* capture); void on_capture_done(struct dmabuf_capture* capture);
@ -310,6 +313,19 @@ int wayvnc_start_capture(struct wayvnc* self)
return 0; return 0;
} }
void on_damage_check_done(struct pixman_region16* damage, void* userdata)
{
struct wayvnc* self = userdata;
if (pixman_region_not_empty(damage))
nvnc_feed_frame(self->nvnc, self->current_fb, damage);
if (wayvnc_start_capture(self) < 0) {
log_error("Failed to start capture. Exiting...\n");
wayvnc_exit();
}
}
void wayvnc_process_frame(struct wayvnc* self, struct dmabuf_frame* frame) void wayvnc_process_frame(struct wayvnc* self, struct dmabuf_frame* frame)
{ {
uint32_t format = fourcc_from_gl_format(self->renderer.read_format); uint32_t format = fourcc_from_gl_format(self->renderer.read_format);
@ -320,12 +336,22 @@ void wayvnc_process_frame(struct wayvnc* self, struct dmabuf_frame* frame)
render_dmabuf_frame(&self->renderer, frame); render_dmabuf_frame(&self->renderer, frame);
render_copy_pixels(&self->renderer, addr, 0, frame->height); render_copy_pixels(&self->renderer, addr, 0, frame->height);
if (self->last_fb)
nvnc_fb_unref(self->last_fb);
self->last_fb = self->current_fb;
self->current_fb = fb;
if (self->last_fb) {
nvnc_check_damage(self->current_fb, self->last_fb, 0, 0,
frame->width, frame->height,
on_damage_check_done, self);
return;
}
struct pixman_region16 damage; struct pixman_region16 damage;
pixman_region_init_rect(&damage, 0, 0, frame->width, frame->height); pixman_region_init_rect(&damage, 0, 0, frame->width, frame->height);
nvnc_feed_frame(self->nvnc, self->current_fb, &damage);
nvnc_feed_frame(self->nvnc, fb, &damage);
nvnc_fb_unref(fb);
pixman_region_fini(&damage); pixman_region_fini(&damage);
if (wayvnc_start_capture(self) < 0) { if (wayvnc_start_capture(self) < 0) {
@ -359,7 +385,7 @@ void on_capture_done(struct dmabuf_capture* capture)
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
struct wayvnc self; struct wayvnc self = { 0 };
if (init_wayland(&self) < 0) { if (init_wayland(&self) < 0) {
log_error("Failed to initialise wayland\n"); log_error("Failed to initialise wayland\n");
@ -401,6 +427,9 @@ int main(int argc, char* argv[])
if (self.capture) if (self.capture)
dmabuf_capture_stop(self.capture); dmabuf_capture_stop(self.capture);
if (self.current_fb) nvnc_fb_unref(self.current_fb);
if (self.last_fb) nvnc_fb_unref(self.last_fb);
nvnc_close(self.nvnc); nvnc_close(self.nvnc);
renderer_destroy(&self.renderer); renderer_destroy(&self.renderer);
wayvnc_destroy(&self); wayvnc_destroy(&self);