mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-22 14:35:57 +01:00
ab8ff54f4c
The goal is to control the rate of capture while in screencast, as it can represent a performance issue and can cause input lag and the feeling of having a laggy mouse. This commit addresses the issue reported in #66. The code measures the time elapsed to make a single screen capture, and calculates how much to wait for the next capture to achieve the targeted frame rate. To delay the capturing of the next frame, the code introduces timers into the event loop based on the event loop in https://github.com/emersion/mako Added a command-line argument and an entry in the config file as well for the max FPS. The default value is 0, meaning no rate control. Added code to measure the average FPS every 5 seconds and print it with DEBUG level.
18 lines
369 B
C
18 lines
369 B
C
#ifndef FPS_LIMIT_H
|
|
#define FPS_LIMIT_H
|
|
|
|
#include <stdint.h>
|
|
#include <time.h>
|
|
|
|
struct fps_limit_state {
|
|
struct timespec frame_last_time;
|
|
|
|
struct timespec fps_last_time;
|
|
uint64_t fps_frame_count;
|
|
};
|
|
|
|
void fps_limit_measure_start(struct fps_limit_state *state, double max_fps);
|
|
|
|
uint64_t fps_limit_measure_end(struct fps_limit_state *state, double max_fps);
|
|
|
|
#endif
|