diff options
Diffstat (limited to 'include/utils.h')
-rw-r--r-- | include/utils.h | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/include/utils.h b/include/utils.h index 392591a..b6f51c1 100644 --- a/include/utils.h +++ b/include/utils.h @@ -3,36 +3,25 @@ #include "vec2.h" #include "../include/egl.h" +#include "../include/defs.h" #include <stdbool.h> #include <stdint.h> -#include <X11/extensions/Xrandr.h> -typedef enum { - GSR_GPU_VENDOR_AMD, - GSR_GPU_VENDOR_INTEL, - GSR_GPU_VENDOR_NVIDIA -} gsr_gpu_vendor; +#define CONNECTOR_TYPE_COUNTS 32 -typedef struct { - gsr_gpu_vendor vendor; - int gpu_version; /* 0 if unknown */ -} gsr_gpu_info; +typedef struct AVCodecContext AVCodecContext; +typedef struct AVFrame AVFrame; typedef struct { const char *name; int name_len; - vec2i pos; + vec2i pos; /* This is 0, 0 on wayland. Use |drm_monitor_get_display_server_data| to get the position */ vec2i size; - XRRCrtcInfo *crt_info; /* Only on x11 */ - uint32_t connector_id; /* Only on drm */ + uint32_t connector_id; /* Only on x11 and drm */ + gsr_monitor_rotation rotation; /* Only on x11 and wayland */ + uint32_t monitor_identifier; /* On x11 this is the crtc id */ } gsr_monitor; -typedef enum { - GSR_CONNECTION_X11, - GSR_CONNECTION_WAYLAND, - GSR_CONNECTION_DRM -} gsr_connection_type; - typedef struct { const char *name; int name_len; @@ -40,19 +29,42 @@ typedef struct { bool found_monitor; } get_monitor_by_name_userdata; +typedef struct { + int type; + int count; + int count_active; +} drm_connector_type_count; + double clock_get_monotonic_seconds(void); +bool generate_random_characters(char *buffer, int buffer_size, const char *alphabet, size_t alphabet_size); +bool generate_random_characters_standard_alphabet(char *buffer, int buffer_size); 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); +void for_each_active_monitor_output_x11_not_cached(Display *display, active_monitor_callback callback, void *userdata); +void for_each_active_monitor_output(const gsr_window *window, const char *card_path, gsr_connection_type connection_type, active_monitor_callback callback, void *userdata); +bool get_monitor_by_name(const gsr_egl *egl, gsr_connection_type connection_type, const char *name, gsr_monitor *monitor); +bool drm_monitor_get_display_server_data(const gsr_window *window, const gsr_monitor *monitor, gsr_monitor_rotation *monitor_rotation, vec2i *monitor_position); + +int get_connector_type_by_name(const char *name); +drm_connector_type_count* drm_connector_types_get_index(drm_connector_type_count *type_counts, int *num_type_counts, int connector_type); +uint32_t monitor_identifier_from_type_and_count(int monitor_type_index, int monitor_type_count); bool gl_get_gpu_info(gsr_egl *egl, gsr_gpu_info *info); +bool try_card_has_valid_plane(const char *card_path); /* |output| should be at least 128 bytes in size */ -bool gsr_get_valid_card_path(char *output); +bool gsr_get_valid_card_path(gsr_egl *egl, char *output, bool is_monitor_capture); /* |render_path| should be at least 128 bytes in size */ bool gsr_card_path_get_render_path(const char *card_path, char *render_path); -int even_number_ceil(int value); +int create_directory_recursive(char *path); + +/* |img_attr| needs to be at least 44 in size */ +void setup_dma_buf_attrs(intptr_t *img_attr, uint32_t format, uint32_t width, uint32_t height, const int *fds, const uint32_t *offsets, const uint32_t *pitches, const uint64_t *modifiers, int num_planes, bool use_modifier); +bool video_codec_context_is_vaapi(AVCodecContext *video_codec_context); + +vec2i scale_keep_aspect_ratio(vec2i from, vec2i to); + +unsigned int gl_create_texture(gsr_egl *egl, int width, int height, int internal_format, unsigned int format, int filter); #endif /* GSR_UTILS_H */ |