From ba096a3ba7815eff41159eedfb646c97451fbef7 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 11 Mar 2024 19:01:46 +0100 Subject: Add -cursor option to not record cursor --- src/capture/kms.c | 4 ++-- src/capture/kms_cuda.c | 2 +- src/capture/kms_vaapi.c | 2 +- src/capture/nvfbc.c | 2 ++ src/capture/xcomposite.c | 4 ++-- 5 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/capture') diff --git a/src/capture/kms.c b/src/capture/kms.c index 0b75b1f..16b20b7 100644 --- a/src/capture/kms.c +++ b/src/capture/kms.c @@ -193,7 +193,7 @@ static vec2i swap_vec2i(vec2i value) { return value; } -bool gsr_capture_kms_capture(gsr_capture_kms *self, AVFrame *frame, bool hdr, bool screen_plane_use_modifiers, bool cursor_texture_is_external) { +bool gsr_capture_kms_capture(gsr_capture_kms *self, AVFrame *frame, bool hdr, bool screen_plane_use_modifiers, bool cursor_texture_is_external, bool record_cursor) { //egl->glClearColor(0.0f, 0.0f, 0.0f, 1.0f); self->base.egl->glClear(0); @@ -300,7 +300,7 @@ bool gsr_capture_kms_capture(gsr_capture_kms *self, AVFrame *frame, bool hdr, bo capture_pos, self->capture_size, texture_rotation, false); - if(cursor_drm_fd) { + if(record_cursor && cursor_drm_fd) { const vec2i cursor_size = {cursor_drm_fd->width, cursor_drm_fd->height}; vec2i cursor_pos = {cursor_drm_fd->x, cursor_drm_fd->y}; switch(self->monitor_rotation) { diff --git a/src/capture/kms_cuda.c b/src/capture/kms_cuda.c index c206fde..0349228 100644 --- a/src/capture/kms_cuda.c +++ b/src/capture/kms_cuda.c @@ -90,7 +90,7 @@ static void gsr_capture_kms_unload_cuda_graphics(gsr_capture_kms_cuda *cap_kms) static int gsr_capture_kms_cuda_capture(gsr_capture *cap, AVFrame *frame) { gsr_capture_kms_cuda *cap_kms = cap->priv; - gsr_capture_kms_capture(&cap_kms->kms, frame, cap_kms->params.hdr, true, true); + gsr_capture_kms_capture(&cap_kms->kms, frame, cap_kms->params.hdr, true, true, cap_kms->params.record_cursor); const int div[2] = {1, 2}; // divide UV texture size by 2 because chroma is half size for(int i = 0; i < 2; ++i) { diff --git a/src/capture/kms_vaapi.c b/src/capture/kms_vaapi.c index bd0e99d..a7e8182 100644 --- a/src/capture/kms_vaapi.c +++ b/src/capture/kms_vaapi.c @@ -57,7 +57,7 @@ static bool gsr_capture_kms_vaapi_should_stop(gsr_capture *cap, bool *err) { static int gsr_capture_kms_vaapi_capture(gsr_capture *cap, AVFrame *frame) { gsr_capture_kms_vaapi *cap_kms = cap->priv; - gsr_capture_kms_capture(&cap_kms->kms, frame, cap_kms->params.hdr, false, false); + gsr_capture_kms_capture(&cap_kms->kms, frame, cap_kms->params.hdr, false, false, cap_kms->params.record_cursor); return 0; } diff --git a/src/capture/nvfbc.c b/src/capture/nvfbc.c index 7ba0438..5acf083 100644 --- a/src/capture/nvfbc.c +++ b/src/capture/nvfbc.c @@ -272,6 +272,8 @@ static int gsr_capture_nvfbc_start(gsr_capture *cap, AVCodecContext *video_codec create_capture_params.dwVersion = NVFBC_CREATE_CAPTURE_SESSION_PARAMS_VER; create_capture_params.eCaptureType = NVFBC_CAPTURE_TO_GL; create_capture_params.bWithCursor = (!direct_capture || supports_direct_cursor) ? NVFBC_TRUE : NVFBC_FALSE; + if(!cap_nvfbc->params.record_cursor) + create_capture_params.bWithCursor = false; if(capture_region) create_capture_params.captureBox = (NVFBC_BOX){ x, y, width, height }; create_capture_params.eTrackingType = tracking_type; diff --git a/src/capture/xcomposite.c b/src/capture/xcomposite.c index f1d620c..ae7481b 100644 --- a/src/capture/xcomposite.c +++ b/src/capture/xcomposite.c @@ -275,7 +275,7 @@ int gsr_capture_xcomposite_capture(gsr_capture_xcomposite *self, AVFrame *frame) will not get overdrawn the next frame causing a cursor trail to be visible since we dont clear the background. To fix this we detect if the cursor is partially inside the window and clear the background only in that case. */ - if(!cursor_completely_inside_window && cursor_inside_window) + if(!cursor_completely_inside_window && cursor_inside_window && self->params.record_cursor) self->clear_next_frame = true; gsr_color_conversion_draw(&self->base.color_conversion, window_texture_get_opengl_texture_id(&self->window_texture), @@ -283,7 +283,7 @@ int gsr_capture_xcomposite_capture(gsr_capture_xcomposite *self, AVFrame *frame) (vec2i){0, 0}, self->texture_size, 0.0f, false); - if(cursor_inside_window) { + if(cursor_inside_window && self->params.record_cursor) { gsr_color_conversion_draw(&self->base.color_conversion, self->cursor.texture_id, cursor_pos, self->cursor.size, (vec2i){0, 0}, self->cursor.size, -- cgit v1.2.3