mirror of
https://repo.dec05eba.com/gpu-screen-recorder
synced 2026-05-05 22:40:42 +09:00
Window capture: move window to center of video (if possible)
This commit is contained in:
@@ -429,10 +429,14 @@ static int gsr_capture_xcomposite_cuda_capture(gsr_capture *cap, AVFrame *frame)
|
|||||||
|
|
||||||
if(cap_xcomp->window_texture.texture_id != 0) {
|
if(cap_xcomp->window_texture.texture_id != 0) {
|
||||||
while(cap_xcomp->params.egl->glGetError()) {}
|
while(cap_xcomp->params.egl->glGetError()) {}
|
||||||
|
|
||||||
|
const int target_x = max_int(0, frame->width / 2 - cap_xcomp->texture_size.x / 2);
|
||||||
|
const int target_y = max_int(0, frame->height / 2 - cap_xcomp->texture_size.y / 2);
|
||||||
|
|
||||||
/* TODO: Remove this copy, which is only possible by using nvenc directly and encoding window_pixmap.target_texture_id */
|
/* TODO: Remove this copy, which is only possible by using nvenc directly and encoding window_pixmap.target_texture_id */
|
||||||
cap_xcomp->params.egl->glCopyImageSubData(
|
cap_xcomp->params.egl->glCopyImageSubData(
|
||||||
window_texture_get_opengl_texture_id(&cap_xcomp->window_texture), GL_TEXTURE_2D, 0, source_pos.x, source_pos.y, 0,
|
window_texture_get_opengl_texture_id(&cap_xcomp->window_texture), GL_TEXTURE_2D, 0, source_pos.x, source_pos.y, 0,
|
||||||
cap_xcomp->target_texture_id, GL_TEXTURE_2D, 0, 0, 0, 0,
|
cap_xcomp->target_texture_id, GL_TEXTURE_2D, 0, target_x, target_y, 0,
|
||||||
source_size.x, source_size.y, 1);
|
source_size.x, source_size.y, 1);
|
||||||
unsigned int err = cap_xcomp->params.egl->glGetError();
|
unsigned int err = cap_xcomp->params.egl->glGetError();
|
||||||
if(err != 0) {
|
if(err != 0) {
|
||||||
|
|||||||
@@ -441,11 +441,13 @@ static int gsr_capture_xcomposite_vaapi_capture(gsr_capture *cap, AVFrame *frame
|
|||||||
(void)frame;
|
(void)frame;
|
||||||
gsr_capture_xcomposite_vaapi *cap_xcomp = cap->priv;
|
gsr_capture_xcomposite_vaapi *cap_xcomp = cap->priv;
|
||||||
|
|
||||||
float texture_rotation = 0.0f;
|
const int target_x = max_int(0, frame->width / 2 - cap_xcomp->texture_size.x / 2);
|
||||||
|
const int target_y = max_int(0, frame->height / 2 - cap_xcomp->texture_size.y / 2);
|
||||||
|
|
||||||
gsr_color_conversion_draw(&cap_xcomp->color_conversion, window_texture_get_opengl_texture_id(&cap_xcomp->window_texture),
|
gsr_color_conversion_draw(&cap_xcomp->color_conversion, window_texture_get_opengl_texture_id(&cap_xcomp->window_texture),
|
||||||
|
(vec2i){target_x, target_y}, cap_xcomp->texture_size,
|
||||||
(vec2i){0, 0}, cap_xcomp->texture_size,
|
(vec2i){0, 0}, cap_xcomp->texture_size,
|
||||||
(vec2i){0, 0}, cap_xcomp->texture_size,
|
0.0f, false);
|
||||||
texture_rotation, false);
|
|
||||||
|
|
||||||
cap_xcomp->params.egl->eglSwapBuffers(cap_xcomp->params.egl->egl_display, cap_xcomp->params.egl->egl_surface);
|
cap_xcomp->params.egl->eglSwapBuffers(cap_xcomp->params.egl->egl_display, cap_xcomp->params.egl->egl_surface);
|
||||||
//cap_xcomp->params.egl->glFlush();
|
//cap_xcomp->params.egl->glFlush();
|
||||||
|
|||||||
Reference in New Issue
Block a user