mirror of
https://repo.dec05eba.com/gpu-screen-recorder
synced 2026-05-06 06:50:43 +09:00
Move card path to egl struct, use egl struct for monitor enumeration
This commit is contained in:
@@ -66,8 +66,8 @@ static Window get_focused_window(Display *display, Atom net_active_window_atom)
|
||||
|
||||
static bool drm_create_codec_context(gsr_capture_xcomposite_vaapi *cap_xcomp, AVCodecContext *video_codec_context) {
|
||||
char render_path[128];
|
||||
if(!gsr_card_path_get_render_path(cap_xcomp->params.card_path, render_path)) {
|
||||
fprintf(stderr, "gsr error: failed to get /dev/dri/renderDXXX file from %s\n", cap_xcomp->params.card_path);
|
||||
if(!gsr_card_path_get_render_path(cap_xcomp->params.egl->card_path, render_path)) {
|
||||
fprintf(stderr, "gsr error: failed to get /dev/dri/renderDXXX file from %s\n", cap_xcomp->params.egl->card_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -117,12 +117,12 @@ static int gsr_capture_xcomposite_vaapi_start(gsr_capture *cap, AVCodecContext *
|
||||
gsr_capture_xcomposite_vaapi *cap_xcomp = cap->priv;
|
||||
|
||||
if(cap_xcomp->params.follow_focused) {
|
||||
cap_xcomp->net_active_window_atom = XInternAtom(cap_xcomp->params.dpy, "_NET_ACTIVE_WINDOW", False);
|
||||
cap_xcomp->net_active_window_atom = XInternAtom(cap_xcomp->params.egl->x11.dpy, "_NET_ACTIVE_WINDOW", False);
|
||||
if(!cap_xcomp->net_active_window_atom) {
|
||||
fprintf(stderr, "gsr error: gsr_capture_xcomposite_vaapi_start failed: failed to get _NET_ACTIVE_WINDOW atom\n");
|
||||
return -1;
|
||||
}
|
||||
cap_xcomp->window = get_focused_window(cap_xcomp->params.dpy, cap_xcomp->net_active_window_atom);
|
||||
cap_xcomp->window = get_focused_window(cap_xcomp->params.egl->x11.dpy, cap_xcomp->net_active_window_atom);
|
||||
} else {
|
||||
cap_xcomp->window = cap_xcomp->params.window;
|
||||
}
|
||||
@@ -130,7 +130,7 @@ static int gsr_capture_xcomposite_vaapi_start(gsr_capture *cap, AVCodecContext *
|
||||
/* TODO: Do these in tick, and allow error if follow_focused */
|
||||
|
||||
XWindowAttributes attr;
|
||||
if(!XGetWindowAttributes(cap_xcomp->params.dpy, cap_xcomp->params.window, &attr) && !cap_xcomp->params.follow_focused) {
|
||||
if(!XGetWindowAttributes(cap_xcomp->params.egl->x11.dpy, cap_xcomp->params.window, &attr) && !cap_xcomp->params.follow_focused) {
|
||||
fprintf(stderr, "gsr error: gsr_capture_xcomposite_vaapi_start failed: invalid window id: %lu\n", cap_xcomp->params.window);
|
||||
return -1;
|
||||
}
|
||||
@@ -139,10 +139,10 @@ static int gsr_capture_xcomposite_vaapi_start(gsr_capture *cap, AVCodecContext *
|
||||
cap_xcomp->window_size.y = max_int(attr.height, 0);
|
||||
|
||||
if(cap_xcomp->params.follow_focused)
|
||||
XSelectInput(cap_xcomp->params.dpy, DefaultRootWindow(cap_xcomp->params.dpy), PropertyChangeMask);
|
||||
XSelectInput(cap_xcomp->params.egl->x11.dpy, DefaultRootWindow(cap_xcomp->params.egl->x11.dpy), PropertyChangeMask);
|
||||
|
||||
// TODO: Get select and add these on top of it and then restore at the end. Also do the same in other xcomposite
|
||||
XSelectInput(cap_xcomp->params.dpy, cap_xcomp->params.window, StructureNotifyMask | ExposureMask);
|
||||
XSelectInput(cap_xcomp->params.egl->x11.dpy, cap_xcomp->params.window, StructureNotifyMask | ExposureMask);
|
||||
|
||||
if(!cap_xcomp->params.egl->eglExportDMABUFImageQueryMESA) {
|
||||
fprintf(stderr, "gsr error: gsr_capture_xcomposite_vaapi_start: could not find eglExportDMABUFImageQueryMESA\n");
|
||||
@@ -156,7 +156,7 @@ static int gsr_capture_xcomposite_vaapi_start(gsr_capture *cap, AVCodecContext *
|
||||
|
||||
/* Disable vsync */
|
||||
cap_xcomp->params.egl->eglSwapInterval(cap_xcomp->params.egl->egl_display, 0);
|
||||
if(window_texture_init(&cap_xcomp->window_texture, cap_xcomp->params.dpy, cap_xcomp->params.window, cap_xcomp->params.egl) != 0 && !cap_xcomp->params.follow_focused) {
|
||||
if(window_texture_init(&cap_xcomp->window_texture, cap_xcomp->params.egl->x11.dpy, cap_xcomp->params.window, cap_xcomp->params.egl) != 0 && !cap_xcomp->params.follow_focused) {
|
||||
fprintf(stderr, "gsr error: gsr_capture_xcomposite_vaapi_start: failed to get window texture for window %ld\n", cap_xcomp->params.window);
|
||||
return -1;
|
||||
}
|
||||
@@ -198,13 +198,12 @@ static uint32_t fourcc(uint32_t a, uint32_t b, uint32_t c, uint32_t d) {
|
||||
static void gsr_capture_xcomposite_vaapi_tick(gsr_capture *cap, AVCodecContext *video_codec_context, AVFrame **frame) {
|
||||
gsr_capture_xcomposite_vaapi *cap_xcomp = cap->priv;
|
||||
|
||||
// TODO:
|
||||
cap_xcomp->params.egl->glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
cap_xcomp->params.egl->glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
bool init_new_window = false;
|
||||
while(XPending(cap_xcomp->params.dpy)) {
|
||||
XNextEvent(cap_xcomp->params.dpy, &cap_xcomp->xev);
|
||||
while(XPending(cap_xcomp->params.egl->x11.dpy)) {
|
||||
XNextEvent(cap_xcomp->params.egl->x11.dpy, &cap_xcomp->xev);
|
||||
|
||||
switch(cap_xcomp->xev.type) {
|
||||
case DestroyNotify: {
|
||||
@@ -248,17 +247,17 @@ static void gsr_capture_xcomposite_vaapi_tick(gsr_capture *cap, AVCodecContext *
|
||||
}
|
||||
|
||||
if(init_new_window) {
|
||||
Window focused_window = get_focused_window(cap_xcomp->params.dpy, cap_xcomp->net_active_window_atom);
|
||||
Window focused_window = get_focused_window(cap_xcomp->params.egl->x11.dpy, cap_xcomp->net_active_window_atom);
|
||||
if(focused_window != cap_xcomp->window || !cap_xcomp->follow_focused_initialized) {
|
||||
cap_xcomp->follow_focused_initialized = true;
|
||||
XSelectInput(cap_xcomp->params.dpy, cap_xcomp->window, 0);
|
||||
XSelectInput(cap_xcomp->params.egl->x11.dpy, cap_xcomp->window, 0);
|
||||
cap_xcomp->window = focused_window;
|
||||
XSelectInput(cap_xcomp->params.dpy, cap_xcomp->window, StructureNotifyMask | ExposureMask);
|
||||
XSelectInput(cap_xcomp->params.egl->x11.dpy, cap_xcomp->window, StructureNotifyMask | ExposureMask);
|
||||
|
||||
XWindowAttributes attr;
|
||||
attr.width = 0;
|
||||
attr.height = 0;
|
||||
if(!XGetWindowAttributes(cap_xcomp->params.dpy, cap_xcomp->window, &attr))
|
||||
if(!XGetWindowAttributes(cap_xcomp->params.egl->x11.dpy, cap_xcomp->window, &attr))
|
||||
fprintf(stderr, "gsr error: gsr_capture_xcomposite_vaapi_tick failed: invalid window id: %lu\n", cap_xcomp->window);
|
||||
|
||||
cap_xcomp->window_size.x = max_int(attr.width, 0);
|
||||
@@ -266,7 +265,7 @@ static void gsr_capture_xcomposite_vaapi_tick(gsr_capture *cap, AVCodecContext *
|
||||
cap_xcomp->window_resized = true;
|
||||
|
||||
window_texture_deinit(&cap_xcomp->window_texture);
|
||||
window_texture_init(&cap_xcomp->window_texture, cap_xcomp->params.dpy, cap_xcomp->window, cap_xcomp->params.egl); // TODO: Do not do the below window_texture_on_resize after this
|
||||
window_texture_init(&cap_xcomp->window_texture, cap_xcomp->params.egl->x11.dpy, cap_xcomp->window, cap_xcomp->params.egl); // TODO: Do not do the below window_texture_on_resize after this
|
||||
|
||||
cap_xcomp->texture_size.x = 0;
|
||||
cap_xcomp->texture_size.y = 0;
|
||||
|
||||
Reference in New Issue
Block a user