diff options
Diffstat (limited to 'src/capture/xcomposite.c')
-rw-r--r-- | src/capture/xcomposite.c | 55 |
1 files changed, 16 insertions, 39 deletions
diff --git a/src/capture/xcomposite.c b/src/capture/xcomposite.c index 94e691b..db41f63 100644 --- a/src/capture/xcomposite.c +++ b/src/capture/xcomposite.c @@ -12,9 +12,6 @@ #include <X11/Xlib.h> -#include <libavutil/frame.h> -#include <libavcodec/avcodec.h> - typedef struct { gsr_capture_xcomposite_params params; Display *display; @@ -37,7 +34,6 @@ typedef struct { gsr_cursor cursor; bool clear_background; - bool fast_path_failed; } gsr_capture_xcomposite; static void gsr_capture_xcomposite_stop(gsr_capture_xcomposite *self) { @@ -113,18 +109,13 @@ static int gsr_capture_xcomposite_start(gsr_capture *cap, gsr_capture_metadata * self->params.egl->glBindTexture(GL_TEXTURE_2D, 0); if(self->params.output_resolution.x == 0 && self->params.output_resolution.y == 0) { - self->params.output_resolution = self->texture_size; - capture_metadata->width = FFALIGN(self->texture_size.x, 2); - capture_metadata->height = FFALIGN(self->texture_size.y, 2); + capture_metadata->width = self->texture_size.x; + capture_metadata->height = self->texture_size.y; } else { - capture_metadata->width = FFALIGN(self->params.output_resolution.x, 2); - capture_metadata->height = FFALIGN(self->params.output_resolution.y, 2); + capture_metadata->width = self->params.output_resolution.x; + capture_metadata->height = self->params.output_resolution.y; } - self->fast_path_failed = self->params.egl->gpu_info.vendor == GSR_GPU_VENDOR_AMD && !gl_driver_version_greater_than(&self->params.egl->gpu_info, 24, 0, 9); - if(self->fast_path_failed) - fprintf(stderr, "gsr warning: gsr_capture_kms_start: your amd driver (mesa) version is known to be buggy (<= version 24.0.9), falling back to opengl copy\n"); - self->window_resize_timer = clock_get_monotonic_seconds(); return 0; } @@ -262,25 +253,13 @@ static int gsr_capture_xcomposite_capture(gsr_capture *cap, gsr_capture_metadata const vec2i target_pos = { max_int(0, capture_metdata->width / 2 - output_size.x / 2), max_int(0, capture_metdata->height / 2 - output_size.y / 2) }; - self->params.egl->glFlush(); - self->params.egl->glFinish(); + //self->params.egl->glFlush(); + //self->params.egl->glFinish(); - /* Fast opengl free path */ - if(!self->fast_path_failed && video_codec_context_is_vaapi(capture_metdata->video_codec_context) && self->params.egl->gpu_info.vendor == GSR_GPU_VENDOR_AMD) { - if(!vaapi_copy_egl_image_to_video_surface(self->params.egl, self->window_texture.image, (vec2i){0, 0}, self->texture_size, target_pos, output_size, capture_metdata->video_codec_context, capture_metdata->frame)) { - fprintf(stderr, "gsr error: gsr_capture_xcomposite_capture: vaapi_copy_egl_image_to_video_surface failed, falling back to opengl copy. Please report this as an issue at https://github.com/dec05eba/gpu-screen-recorder-issues\n"); - self->fast_path_failed = true; - } - } else { - self->fast_path_failed = true; - } - - if(self->fast_path_failed) { - gsr_color_conversion_draw(color_conversion, window_texture_get_opengl_texture_id(&self->window_texture), - target_pos, output_size, - (vec2i){0, 0}, self->texture_size, - 0.0f, false, GSR_SOURCE_COLOR_RGB); - } + gsr_color_conversion_draw(color_conversion, window_texture_get_opengl_texture_id(&self->window_texture), + target_pos, output_size, + (vec2i){0, 0}, self->texture_size, self->texture_size, + GSR_ROT_0, GSR_SOURCE_COLOR_RGB, false, false); if(self->params.record_cursor && self->cursor.visible) { const vec2d scale = { @@ -295,19 +274,17 @@ static int gsr_capture_xcomposite_capture(gsr_capture *cap, gsr_capture_metadata target_pos.y + (self->cursor.position.y - self->cursor.hotspot.y) * scale.y }; - self->params.egl->glEnable(GL_SCISSOR_TEST); - self->params.egl->glScissor(target_pos.x, target_pos.y, output_size.x, output_size.y); + if(cursor_pos.x < target_pos.x || cursor_pos.x + self->cursor.size.x > target_pos.x + output_size.x || cursor_pos.y < target_pos.y || cursor_pos.y + self->cursor.size.y > target_pos.y + output_size.y) + self->clear_background = true; gsr_color_conversion_draw(color_conversion, self->cursor.texture_id, cursor_pos, (vec2i){self->cursor.size.x * scale.x, self->cursor.size.y * scale.y}, - (vec2i){0, 0}, self->cursor.size, - 0.0f, false, GSR_SOURCE_COLOR_RGB); - - self->params.egl->glDisable(GL_SCISSOR_TEST); + (vec2i){0, 0}, self->cursor.size, self->cursor.size, + GSR_ROT_0, GSR_SOURCE_COLOR_RGB, false, true); } - self->params.egl->glFlush(); - self->params.egl->glFinish(); + //self->params.egl->glFlush(); + //self->params.egl->glFinish(); return 0; } |