From c32993d87dbfa949e366723be9374c05565cbd1d Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Thu, 5 Mar 2020 21:57:46 +0000 Subject: [PATCH] Use transformed geometry for frame buffers --- src/main.c | 18 ++++++++++++------ src/render.c | 12 +++++++----- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/main.c b/src/main.c index 7f50ec0..fcbf763 100644 --- a/src/main.c +++ b/src/main.c @@ -434,8 +434,8 @@ int init_nvnc(struct wayvnc* self, const char* addr, uint16_t port) nvnc_set_name(self->nvnc, "WayVNC"); nvnc_set_dimensions(self->nvnc, - self->selected_output->width, - self->selected_output->height, + output_get_transformed_width(self->selected_output), + output_get_transformed_height(self->selected_output), format); if (self->cfg.enable_auth) @@ -508,11 +508,14 @@ void wayvnc_process_frame(struct wayvnc* self) uint32_t format = fourcc_from_gl_format(self->renderer.read_format); struct dmabuf_frame* frame = &self->dmabuf_backend.frame; - struct nvnc_fb* fb = nvnc_fb_new(frame->width, frame->height, format); + uint32_t fb_width = output_get_transformed_width(self->selected_output); + uint32_t fb_height = + output_get_transformed_height(self->selected_output); + struct nvnc_fb* fb = nvnc_fb_new(fb_width, fb_height, format); void* addr = nvnc_fb_get_addr(fb); render_dmabuf_frame(&self->renderer, frame); - render_copy_pixels(&self->renderer, addr, 0, frame->height); + render_copy_pixels(&self->renderer, addr, 0, fb_height); wayvnc_update_vnc(self, fb); } @@ -529,12 +532,15 @@ void wayvnc_process_screen(struct wayvnc* self) uint32_t stride = self->capture_backend->frame_info.stride; uint32_t frame_format = self->capture_backend->frame_info.fourcc_format; - struct nvnc_fb* fb = nvnc_fb_new(width, height, renderer_format); + uint32_t fb_width = output_get_transformed_width(self->selected_output); + uint32_t fb_height = + output_get_transformed_height(self->selected_output); + struct nvnc_fb* fb = nvnc_fb_new(fb_width, fb_height, renderer_format); void* addr = nvnc_fb_get_addr(fb); render_framebuffer(&self->renderer, pixels, frame_format, width, height, stride); - render_copy_pixels(&self->renderer, addr, 0, height); + render_copy_pixels(&self->renderer, addr, 0, fb_height); wayvnc_update_vnc(self, fb); } diff --git a/src/render.c b/src/render.c index 15e0b69..7958bde 100644 --- a/src/render.c +++ b/src/render.c @@ -414,8 +414,8 @@ int renderer_init(struct renderer* self, const struct output* output, return -1; EGLint surf_attr[] = { - EGL_WIDTH, output->width, - EGL_HEIGHT, output->width, + EGL_WIDTH, output_get_transformed_width(output), + EGL_HEIGHT, output_get_transformed_height(output), EGL_NONE }; @@ -576,8 +576,10 @@ int render_framebuffer(struct renderer* self, const void* addr, uint32_t format, void render_copy_pixels(struct renderer* self, void* dst, uint32_t y, uint32_t height) { - assert(y + height <= self->output->height); + assert(y + height <= output_get_transformed_height(self->output)); - glReadPixels(0, y, self->output->width, height, self->read_format, - self->read_type, dst); + uint32_t width = output_get_transformed_width(self->output); + + glReadPixels(0, y, width, height, self->read_format, self->read_type, + dst); }