diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2019-05-30 16:47:40 +0200 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-30 16:47:40 +0200 | 
| commit | 6895ad303b51aaf84a568c982e3622049a50ed37 (patch) | |
| tree | 6310e1a149119ddab6ee10571f46110a245a2a60 | |
| parent | fcb60fa2cd496df1b054840727e13210d3d24b59 (diff) | |
| parent | ac14efcdfb22575fc49a75201492955e723d04c3 (diff) | |
Merge pull request #29297 from Calinou/decrease-editor-fps-unfocused
Decrease the editor FPS cap when the window is unfocused
| -rw-r--r-- | editor/editor_node.cpp | 10 | ||||
| -rw-r--r-- | editor/editor_settings.cpp | 4 | 
2 files changed, 14 insertions, 0 deletions
| diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 90604a36f1..1dd68309ae 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -288,6 +288,7 @@ void EditorNode::_notification(int p_what) {  		Engine::get_singleton()->set_editor_hint(true); +		OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/low_processor_mode_sleep_usec")));  		get_tree()->get_root()->set_usage(Viewport::USAGE_2D_NO_SAMPLING); //reduce memory usage  		get_tree()->get_root()->set_disable_3d(true);  		get_tree()->get_root()->set_as_audio_listener(false); @@ -323,9 +324,18 @@ void EditorNode::_notification(int p_what) {  	if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) { +		// Restore the original FPS cap after focusing back on the editor +		OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/low_processor_mode_sleep_usec"))); +  		EditorFileSystem::get_singleton()->scan_changes();  	} +	if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_OUT) { + +		// Set a low FPS cap to decrease CPU/GPU usage while the editor is unfocused +		OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/unfocused_low_processor_mode_sleep_usec"))); +	} +  	if (p_what == MainLoop::NOTIFICATION_WM_QUIT_REQUEST) {  		_menu_option_confirm(FILE_QUIT, false); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index c0dc231ea9..2c0b3a350f 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -340,6 +340,10 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {  	hints["interface/editor/dim_amount"] = PropertyInfo(Variant::REAL, "interface/editor/dim_amount", PROPERTY_HINT_RANGE, "0,1,0.01", PROPERTY_USAGE_DEFAULT);  	_initial_set("interface/editor/dim_transition_time", 0.08f);  	hints["interface/editor/dim_transition_time"] = PropertyInfo(Variant::REAL, "interface/editor/dim_transition_time", PROPERTY_HINT_RANGE, "0,1,0.001", PROPERTY_USAGE_DEFAULT); +	_initial_set("interface/editor/low_processor_mode_sleep_usec", 6900); // ~144 FPS +	hints["interface/editor/low_processor_mode_sleep_usec"] = PropertyInfo(Variant::REAL, "interface/editor/low_processor_mode_sleep_usec", PROPERTY_HINT_RANGE, "1,100000,1", PROPERTY_USAGE_DEFAULT); +	_initial_set("interface/editor/unfocused_low_processor_mode_sleep_usec", 50000); // 20 FPS +	hints["interface/editor/unfocused_low_processor_mode_sleep_usec"] = PropertyInfo(Variant::REAL, "interface/editor/unfocused_low_processor_mode_sleep_usec", PROPERTY_HINT_RANGE, "1,100000,1", PROPERTY_USAGE_DEFAULT);  	_initial_set("interface/editor/separate_distraction_mode", false);  	_initial_set("interface/editor/save_each_scene_on_quit", true); // Regression  	_initial_set("interface/editor/quit_confirmation", true); |