mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
Use system timer/wait functions for frame delay when screen reader is active.
This commit is contained in:
parent
1b37dacc18
commit
98f377d9d0
9 changed files with 70 additions and 13 deletions
|
|
@ -658,7 +658,25 @@ void OS::close_midi_inputs() {
|
|||
}
|
||||
}
|
||||
|
||||
void OS::add_frame_delay(bool p_can_draw) {
|
||||
uint64_t OS::get_frame_delay(bool p_can_draw) const {
|
||||
const uint32_t frame_delay = Engine::get_singleton()->get_frame_delay();
|
||||
|
||||
// Add a dynamic frame delay to decrease CPU/GPU usage. This takes the
|
||||
// previous frame time into account for a smoother result.
|
||||
uint64_t dynamic_delay = 0;
|
||||
if (is_in_low_processor_usage_mode() || !p_can_draw) {
|
||||
dynamic_delay = get_low_processor_usage_mode_sleep_usec();
|
||||
}
|
||||
const int max_fps = Engine::get_singleton()->get_max_fps();
|
||||
if (max_fps > 0 && !Engine::get_singleton()->is_editor_hint()) {
|
||||
// Override the low processor usage mode sleep delay if the target FPS is lower.
|
||||
dynamic_delay = MAX(dynamic_delay, (uint64_t)(1000000 / max_fps));
|
||||
}
|
||||
|
||||
return frame_delay + dynamic_delay;
|
||||
}
|
||||
|
||||
void OS::add_frame_delay(bool p_can_draw, bool p_wake_for_events) {
|
||||
const uint32_t frame_delay = Engine::get_singleton()->get_frame_delay();
|
||||
if (frame_delay) {
|
||||
// Add fixed frame delay to decrease CPU/GPU usage. This doesn't take
|
||||
|
|
|
|||
|
|
@ -247,7 +247,8 @@ public:
|
|||
virtual double get_unix_time() const;
|
||||
|
||||
virtual void delay_usec(uint32_t p_usec) const = 0;
|
||||
virtual void add_frame_delay(bool p_can_draw);
|
||||
virtual void add_frame_delay(bool p_can_draw, bool p_wake_for_events);
|
||||
virtual uint64_t get_frame_delay(bool p_can_draw) const;
|
||||
|
||||
virtual uint64_t get_ticks_usec() const = 0;
|
||||
uint64_t get_ticks_msec() const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue