diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2019-11-08 18:36:06 +0100 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2019-11-08 18:53:25 +0100 |
commit | e6d53ba75fe8d58d72fb6f4c261c7fcf73290104 (patch) | |
tree | c43ebb5a4f51a23dbaaadb2fa1f4df0d525633b4 | |
parent | 9d4e596c69b0b03e94af4ea4cfb49e0371776ec6 (diff) |
Expose the `OS.low_processor_usage_mode_sleep_usec` property
This makes it possible to change it at runtime in projects.
-rw-r--r-- | core/bind/core_bind.cpp | 15 | ||||
-rw-r--r-- | core/bind/core_bind.h | 3 | ||||
-rw-r--r-- | doc/classes/OS.xml | 3 |
3 files changed, 21 insertions, 0 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index c539f912aa..1544503045 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -468,6 +468,16 @@ bool _OS::is_in_low_processor_usage_mode() const { return OS::get_singleton()->is_in_low_processor_usage_mode(); } +void _OS::set_low_processor_usage_mode_sleep_usec(int p_usec) { + + OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(p_usec); +} + +int _OS::get_low_processor_usage_mode_sleep_usec() const { + + return OS::get_singleton()->get_low_processor_usage_mode_sleep_usec(); +} + String _OS::get_executable_path() const { return OS::get_singleton()->get_executable_path(); @@ -1232,6 +1242,9 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("set_low_processor_usage_mode", "enable"), &_OS::set_low_processor_usage_mode); ClassDB::bind_method(D_METHOD("is_in_low_processor_usage_mode"), &_OS::is_in_low_processor_usage_mode); + ClassDB::bind_method(D_METHOD("set_low_processor_usage_mode_sleep_usec", "usec"), &_OS::set_low_processor_usage_mode_sleep_usec); + ClassDB::bind_method(D_METHOD("get_low_processor_usage_mode_sleep_usec"), &_OS::get_low_processor_usage_mode_sleep_usec); + ClassDB::bind_method(D_METHOD("get_processor_count"), &_OS::get_processor_count); ClassDB::bind_method(D_METHOD("get_executable_path"), &_OS::get_executable_path); @@ -1337,6 +1350,7 @@ void _OS::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "exit_code"), "set_exit_code", "get_exit_code"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "vsync_enabled"), "set_use_vsync", "is_vsync_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "low_processor_usage_mode"), "set_low_processor_usage_mode", "is_in_low_processor_usage_mode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "low_processor_usage_mode_sleep_usec"), "set_low_processor_usage_mode_sleep_usec", "get_low_processor_usage_mode_sleep_usec"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keep_screen_on"), "set_keep_screen_on", "is_keep_screen_on"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "min_window_size"), "set_min_window_size", "get_min_window_size"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "max_window_size"), "set_max_window_size", "get_max_window_size"); @@ -1358,6 +1372,7 @@ void _OS::_bind_methods() { ADD_PROPERTY_DEFAULT("exit_code", 0); ADD_PROPERTY_DEFAULT("vsync_enabled", true); ADD_PROPERTY_DEFAULT("low_processor_usage_mode", false); + ADD_PROPERTY_DEFAULT("low_processor_usage_mode_sleep_usec", 6900); ADD_PROPERTY_DEFAULT("keep_screen_on", true); ADD_PROPERTY_DEFAULT("min_window_size", Vector2()); ADD_PROPERTY_DEFAULT("max_window_size", Vector2()); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 1a4fd1d5cb..18182860c6 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -222,6 +222,9 @@ public: void set_low_processor_usage_mode(bool p_enabled); bool is_in_low_processor_usage_mode() const; + void set_low_processor_usage_mode_sleep_usec(int p_usec); + int get_low_processor_usage_mode_sleep_usec() const; + String get_executable_path() const; int execute(const String &p_path, const Vector<String> &p_arguments, bool p_blocking, Array p_output = Array(), bool p_read_stderr = false); diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index 5aeeb61647..6da0547352 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -878,6 +878,9 @@ <member name="low_processor_usage_mode" type="bool" setter="set_low_processor_usage_mode" getter="is_in_low_processor_usage_mode" default="false"> If [code]true[/code], the engine optimizes for low processor usage by only refreshing the screen if needed. Can improve battery consumption on mobile. </member> + <member name="low_processor_usage_mode_sleep_usec" type="int" setter="set_low_processor_usage_mode_sleep_usec" getter="get_low_processor_usage_mode_sleep_usec" default="6900"> + The amount of sleeping between frames when the low-processor usage mode is enabled (in microseconds). Higher values will result in lower CPU usage. + </member> <member name="max_window_size" type="Vector2" setter="set_max_window_size" getter="get_max_window_size" default="Vector2( 0, 0 )"> The maximum size of the window (without counting window manager decorations). Does not affect fullscreen mode. Set to [code](0, 0)[/code] to reset to the system default value. </member> |