gpu-screen-recorder/include/utils.h

56 lines
1.4 KiB
C
Raw Normal View History

2023-04-07 03:31:46 +00:00
#ifndef GSR_UTILS_H
#define GSR_UTILS_H
#include "vec2.h"
#include <stdbool.h>
2023-07-17 20:27:14 +00:00
#include <stdint.h>
2023-04-07 03:31:46 +00:00
#include <X11/extensions/Xrandr.h>
typedef enum {
GSR_GPU_VENDOR_AMD,
GSR_GPU_VENDOR_INTEL,
GSR_GPU_VENDOR_NVIDIA
} gsr_gpu_vendor;
typedef struct {
gsr_gpu_vendor vendor;
int gpu_version; /* 0 if unknown */
} gsr_gpu_info;
2023-04-07 03:31:46 +00:00
typedef struct {
2023-07-17 20:27:14 +00:00
const char *name;
int name_len;
2023-04-07 03:31:46 +00:00
vec2i pos;
vec2i size;
2023-07-17 20:27:14 +00:00
XRRCrtcInfo *crt_info; /* Only on x11 */
uint32_t connector_id; /* Only on drm */
2023-04-07 03:31:46 +00:00
} gsr_monitor;
2023-07-17 20:27:14 +00:00
typedef enum {
GSR_CONNECTION_X11,
GSR_CONNECTION_WAYLAND,
GSR_CONNECTION_DRM
} gsr_connection_type;
2023-04-07 03:31:46 +00:00
typedef struct {
const char *name;
int name_len;
gsr_monitor *monitor;
bool found_monitor;
} get_monitor_by_name_userdata;
double clock_get_monotonic_seconds(void);
2023-07-17 20:27:14 +00:00
typedef void (*active_monitor_callback)(const gsr_monitor *monitor, void *userdata);
void for_each_active_monitor_output(void *connection, gsr_connection_type connection_type, active_monitor_callback callback, void *userdata);
bool get_monitor_by_name(void *connection, gsr_connection_type connection_type, const char *name, gsr_monitor *monitor);
2023-04-07 03:31:46 +00:00
2023-07-17 20:27:14 +00:00
bool gl_get_gpu_info(Display *dpy, gsr_gpu_info *info, bool wayland);
/* |output| should be at least 128 bytes in size */
bool gsr_get_valid_card_path(char *output);
int even_number_ceil(int value);
2023-04-07 03:31:46 +00:00
#endif /* GSR_UTILS_H */