Modified low processor sleep to 8000 and made it customizable (should be customizable for editor too)

This commit is contained in:
Juan Linietsky 2017-11-22 14:40:43 -03:00
parent 81213917d1
commit 62d86b1588
3 changed files with 18 additions and 1 deletions

View File

@ -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;

View File

@ -50,6 +50,7 @@ class OS {
List<String> _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<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false) = 0;

View File

@ -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)