From 62d86b15887371c59f99bfa37dbe2fcaf80478f7 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Wed, 22 Nov 2017 14:40:43 -0300 Subject: [PATCH] Modified low processor sleep to 8000 and made it customizable (should be customizable for editor too) --- core/os/os.cpp | 11 +++++++++++ core/os/os.h | 3 +++ main/main.cpp | 5 ++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/core/os/os.cpp b/core/os/os.cpp index 84937c0e596..a39dfcc003c 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -122,6 +122,16 @@ bool OS::is_in_low_processor_usage_mode() const { return low_processor_usage_mode; } +void OS::set_low_processor_usage_mode_sleep_usec(int p_usec) { + + low_processor_usage_mode_sleep_usec = p_usec; +} + +int OS::get_low_processor_usage_mode_sleep_usec() const { + + return low_processor_usage_mode_sleep_usec; +} + void OS::set_clipboard(const String &p_text) { _local_clipboard = p_text; @@ -599,6 +609,7 @@ OS::OS() { singleton = this; _keep_screen_on = true; // set default value to true, because this had been true before godot 2.0. low_processor_usage_mode = false; + low_processor_usage_mode_sleep_usec = 10000; _verbose_stdout = false; _no_window = false; _exit_code = 0; diff --git a/core/os/os.h b/core/os/os.h index fe4ffb2922e..d7a1512e39b 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -50,6 +50,7 @@ class OS { List _cmdline; bool _keep_screen_on; bool low_processor_usage_mode; + int low_processor_usage_mode_sleep_usec; bool _verbose_stdout; String _local_clipboard; uint64_t _msec_splash; @@ -202,6 +203,8 @@ public: virtual bool is_keep_screen_on() const; virtual void set_low_processor_usage_mode(bool p_enabled); virtual bool is_in_low_processor_usage_mode() const; + virtual void set_low_processor_usage_mode_sleep_usec(int p_usec); + virtual int get_low_processor_usage_mode_sleep_usec() const; virtual String get_executable_path() const; virtual Error execute(const String &p_path, const List &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false) = 0; diff --git a/main/main.cpp b/main/main.cpp index 8b866e160f8..cc20e650252 100755 --- a/main/main.cpp +++ b/main/main.cpp @@ -910,6 +910,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph frame_delay = GLOBAL_DEF("application/run/frame_delay_msec", 0); } + OS::get_singleton()->set_low_processor_usage_mode(GLOBAL_DEF("application/run/low_processor_mode", false)); + OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(GLOBAL_DEF("application/run/low_processor_mode_sleep_usec", 8000)); + Engine::get_singleton()->set_frame_delay(frame_delay); message_queue = memnew(MessageQueue); @@ -1773,7 +1776,7 @@ bool Main::iteration() { return exit; if (OS::get_singleton()->is_in_low_processor_usage_mode() || !OS::get_singleton()->can_draw()) - OS::get_singleton()->delay_usec(16600); //apply some delay to force idle time (results in about 60 FPS max) + OS::get_singleton()->delay_usec(OS::get_singleton()->get_low_processor_usage_mode_sleep_usec()); //apply some delay to force idle time (results in about 60 FPS max) else { uint32_t frame_delay = Engine::get_singleton()->get_frame_delay(); if (frame_delay)