-Heavily improved editor startup and exit performance

This commit is contained in:
Juan Linietsky 2016-06-07 22:08:12 -03:00
parent 193272aa8a
commit d61b91cbe0
10 changed files with 229 additions and 194 deletions

View File

@ -1377,10 +1377,7 @@ void EditorExportPlatformAndroid::_device_poll_thread(void *ud) {
while(!ea->quit_request) { while(!ea->quit_request) {
String adb=EditorSettings::get_singleton()->get("android/adb"); String adb=EditorSettings::get_singleton()->get("android/adb");
if (!FileAccess::exists(adb)) { if (FileAccess::exists(adb)) {
OS::get_singleton()->delay_usec(3000000);
continue; //adb not configured
}
String devices; String devices;
List<String> args; List<String> args;
@ -1489,8 +1486,16 @@ void EditorExportPlatformAndroid::_device_poll_thread(void *ud) {
} }
ea->device_lock->unlock(); ea->device_lock->unlock();
}
uint64_t wait = 3000000;
uint64_t time = OS::get_singleton()->get_ticks_usec();
while(OS::get_singleton()->get_ticks_usec() - time < wait ) {
OS::get_singleton()->delay_usec(1000);
if (ea->quit_request)
break;
}
OS::get_singleton()->delay_usec(3000000);
} }
if (EditorSettings::get_singleton()->get("android/shutdown_adb_on_exit")) { if (EditorSettings::get_singleton()->get("android/shutdown_adb_on_exit")) {

View File

@ -532,10 +532,7 @@ void EditorExportPlatformBB10::_device_poll_thread(void *ud) {
if (windows) if (windows)
bb_deploy+=".bat"; bb_deploy+=".bat";
if (!FileAccess::exists(bb_deploy)) { if (FileAccess::exists(bb_deploy)) {
OS::get_singleton()->delay_usec(3000000);
continue; //adb not configured
}
Vector<Device> devices; Vector<Device> devices;
@ -618,9 +615,16 @@ void EditorExportPlatformBB10::_device_poll_thread(void *ud) {
} }
ea->device_lock->unlock(); ea->device_lock->unlock();
}
OS::get_singleton()->delay_usec(3000000);
uint64_t wait = 3000000;
uint64_t time = OS::get_singleton()->get_ticks_usec();
while(OS::get_singleton()->get_ticks_usec() - time < wait ) {
OS::get_singleton()->delay_usec(1000);
if (ea->quit_request)
break;
}
} }
} }

View File

@ -168,11 +168,8 @@ void Node::_propagate_enter_tree() {
data.inside_tree=true; data.inside_tree=true;
const StringName *K=NULL; for (Map< StringName, GroupData>::Element *E=data.grouped.front();E;E=E->next()) {
E->get().group=data.tree->add_to_group(E->key(),this);
while ((K=data.grouped.next(K))) {
data.tree->add_to_group(*K,this);
} }
@ -257,13 +254,13 @@ void Node::_propagate_exit_tree() {
data.tree->node_removed(this); data.tree->node_removed(this);
// exit groups // exit groups
const StringName *K=NULL;
while ((K=data.grouped.next(K))) { for (Map< StringName, GroupData>::Element *E=data.grouped.front();E;E=E->next()) {
data.tree->remove_from_group(E->key(),this);
data.tree->remove_from_group(*K,this); E->get().group=NULL;
} }
data.viewport = NULL; data.viewport = NULL;
if (data.tree) if (data.tree)
@ -307,6 +304,9 @@ void Node::move_child(Node *p_child,int p_pos) {
data.children[i]->notification( NOTIFICATION_MOVED_IN_PARENT ); data.children[i]->notification( NOTIFICATION_MOVED_IN_PARENT );
} }
for (const Map< StringName, GroupData>::Element *E=p_child->data.grouped.front();E;E=E->next()) {
E->get().group->changed=true;
}
data.blocked--; data.blocked--;
@ -1193,8 +1193,12 @@ void Node::add_to_group(const StringName& p_identifier,bool p_persistent) {
GroupData gd; GroupData gd;
if (data.tree) SceneTree::Group *gptr=NULL;
data.tree->add_to_group(p_identifier,this); if (data.tree) {
gd.group=data.tree->add_to_group(p_identifier,this);
} else {
gd.group=NULL;
}
gd.persistent=p_persistent; gd.persistent=p_persistent;
@ -1207,14 +1211,15 @@ void Node::remove_from_group(const StringName& p_identifier) {
ERR_FAIL_COND(!data.grouped.has(p_identifier) ); ERR_FAIL_COND(!data.grouped.has(p_identifier) );
GroupData *g=data.grouped.getptr(p_identifier);
ERR_FAIL_COND(!g); Map< StringName, GroupData>::Element *E=data.grouped.find(p_identifier);
ERR_FAIL_COND(!E);
if (data.tree) if (data.tree)
data.tree->remove_from_group(p_identifier,this); data.tree->remove_from_group(E->key(),this);
data.grouped.erase(p_identifier); data.grouped.erase(E);
} }
@ -1232,13 +1237,11 @@ Array Node::_get_groups() const {
void Node::get_groups(List<GroupInfo> *p_groups) const { void Node::get_groups(List<GroupInfo> *p_groups) const {
const StringName *K=NULL;
while ((K=data.grouped.next(K))) {
for (const Map< StringName, GroupData>::Element *E=data.grouped.front();E;E=E->next()) {
GroupInfo gi; GroupInfo gi;
gi.name=*K; gi.name=E->key();
gi.persistent=data.grouped[*K].persistent; gi.persistent=E->get().persistent;
p_groups->push_back(gi); p_groups->push_back(gi);
} }
@ -1246,16 +1249,16 @@ void Node::get_groups(List<GroupInfo> *p_groups) const {
bool Node::has_persistent_groups() const { bool Node::has_persistent_groups() const {
const StringName *K=NULL;
while ((K=data.grouped.next(K))) { for (const Map< StringName, GroupData>::Element *E=data.grouped.front();E;E=E->next()) {
if (E->get().persistent)
if (data.grouped[*K].persistent)
return true; return true;
} }
return false; return false;
} }
void Node::_print_tree(const Node *p_node) { void Node::_print_tree(const Node *p_node) {

View File

@ -64,6 +64,7 @@ private:
struct GroupData { struct GroupData {
bool persistent; bool persistent;
SceneTree::Group *group;
GroupData() { persistent=false; } GroupData() { persistent=false; }
}; };
@ -91,7 +92,7 @@ private:
Viewport *viewport; Viewport *viewport;
HashMap< StringName, GroupData,StringNameHasher> grouped; Map< StringName, GroupData> grouped;
List<Node*>::Element *OW; // owned element List<Node*>::Element *OW; // owned element
List<Node*> owned; List<Node*> owned;

View File

@ -64,7 +64,7 @@ void SceneTree::node_removed(Node *p_node) {
} }
void SceneTree::add_to_group(const StringName& p_group, Node *p_node) { SceneTree::Group *SceneTree::add_to_group(const StringName& p_group, Node *p_node) {
Map<StringName,Group>::Element *E=group_map.find(p_group); Map<StringName,Group>::Element *E=group_map.find(p_group);
if (!E) { if (!E) {
@ -73,10 +73,12 @@ void SceneTree::add_to_group(const StringName& p_group, Node *p_node) {
if (E->get().nodes.find(p_node)!=-1) { if (E->get().nodes.find(p_node)!=-1) {
ERR_EXPLAIN("Already in group: "+p_group); ERR_EXPLAIN("Already in group: "+p_group);
ERR_FAIL(); ERR_FAIL_V(&E->get());
} }
E->get().nodes.push_back(p_node); E->get().nodes.push_back(p_node);
E->get().last_tree_version=0; //E->get().last_tree_version=0;
E->get().changed=true;
return &E->get();
} }
void SceneTree::remove_from_group(const StringName& p_group, Node *p_node) { void SceneTree::remove_from_group(const StringName& p_group, Node *p_node) {
@ -125,7 +127,7 @@ void SceneTree::_flush_ugc() {
void SceneTree::_update_group_order(Group& g) { void SceneTree::_update_group_order(Group& g) {
if (g.last_tree_version==tree_version) if (!g.changed)
return; return;
if (g.nodes.empty()) if (g.nodes.empty())
return; return;
@ -135,7 +137,8 @@ void SceneTree::_update_group_order(Group& g) {
SortArray<Node*,Node::Comparator> node_sort; SortArray<Node*,Node::Comparator> node_sort;
node_sort.sort(nodes,node_count); node_sort.sort(nodes,node_count);
g.last_tree_version=tree_version; g.changed=false;
} }
@ -148,8 +151,6 @@ void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const
if (g.nodes.empty()) if (g.nodes.empty())
return; return;
_update_group_order(g);
if (p_call_flags&GROUP_CALL_UNIQUE && !(p_call_flags&GROUP_CALL_REALTIME)) { if (p_call_flags&GROUP_CALL_UNIQUE && !(p_call_flags&GROUP_CALL_REALTIME)) {
@ -175,6 +176,8 @@ void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const
return; return;
} }
_update_group_order(g);
Vector<Node*> nodes_copy = g.nodes; Vector<Node*> nodes_copy = g.nodes;
Node **nodes = &nodes_copy[0]; Node **nodes = &nodes_copy[0];
int node_count=nodes_copy.size(); int node_count=nodes_copy.size();

View File

@ -76,8 +76,9 @@ private:
struct Group { struct Group {
Vector<Node*> nodes; Vector<Node*> nodes;
uint64_t last_tree_version; //uint64_t last_tree_version;
Group() { last_tree_version=0; }; bool changed;
Group() { changed=false; };
}; };
Viewport *root; Viewport *root;
@ -135,7 +136,7 @@ private:
void _flush_ugc(); void _flush_ugc();
void _flush_transform_notifications(); void _flush_transform_notifications();
void _update_group_order(Group& g); _FORCE_INLINE_ void _update_group_order(Group& g);
void _update_listener(); void _update_listener();
Array _get_nodes_in_group(const StringName& p_group); Array _get_nodes_in_group(const StringName& p_group);
@ -162,7 +163,7 @@ friend class Node;
void node_removed(Node *p_node); void node_removed(Node *p_node);
void add_to_group(const StringName& p_group, Node *p_node); Group* add_to_group(const StringName& p_group, Node *p_node);
void remove_from_group(const StringName& p_group, Node *p_node); void remove_from_group(const StringName& p_group, Node *p_node);
void _notify_group_pause(const StringName& p_group,int p_notification); void _notify_group_pause(const StringName& p_group,int p_notification);

View File

@ -2414,6 +2414,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
_menu_option_confirm(RUN_STOP,true); _menu_option_confirm(RUN_STOP,true);
exiting=true;
get_tree()->quit(); get_tree()->quit();
} break; } break;
@ -2747,6 +2748,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} }
_menu_option_confirm(RUN_STOP,true); _menu_option_confirm(RUN_STOP,true);
exiting=true;
get_tree()->quit(); get_tree()->quit();
String exec = OS::get_singleton()->get_executable_path(); String exec = OS::get_singleton()->get_executable_path();
@ -5244,6 +5246,7 @@ EditorNode::EditorNode() {
singleton=this; singleton=this;
exiting=false;
last_checked_version=0; last_checked_version=0;
changing_scene=false; changing_scene=false;
_initializing_addons=false; _initializing_addons=false;

View File

@ -227,6 +227,7 @@ private:
Tabs *scene_tabs; Tabs *scene_tabs;
int tab_closing; int tab_closing;
bool exiting;
int old_split_ofs; int old_split_ofs;
VSplitContainer *top_split; VSplitContainer *top_split;
@ -712,6 +713,8 @@ public:
void update_keying(); void update_keying();
bool is_exiting() const { return exiting; }
ToolButton *get_pause_button() { return pause_button; } ToolButton *get_pause_button() { return pause_button; }

View File

@ -247,6 +247,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
hint=p_hint; hint=p_hint;
hint_text=p_hint_text; hint_text=p_hint_text;
type_button->hide(); type_button->hide();
if (color_picker)
color_picker->hide(); color_picker->hide();
texture_preview->hide(); texture_preview->hide();
inheritors_array.clear(); inheritors_array.clear();
@ -596,6 +597,16 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
} break; } break;
case Variant::COLOR: { case Variant::COLOR: {
if (!color_picker) {
//late init for performance
color_picker = memnew( ColorPicker );
add_child(color_picker);
color_picker->hide();
color_picker->set_area_as_parent_rect();
for(int i=0;i<4;i++)
color_picker->set_margin((Margin)i,5);
color_picker->connect("color_changed",this,"_color_changed");
}
color_picker->show(); color_picker->show();
color_picker->set_edit_alpha(hint!=PROPERTY_HINT_COLOR_NO_ALPHA); color_picker->set_edit_alpha(hint!=PROPERTY_HINT_COLOR_NO_ALPHA);
@ -1757,13 +1768,9 @@ CustomPropertyEditor::CustomPropertyEditor() {
action_buttons[i]->connect("pressed", this,"_action_pressed",binds); action_buttons[i]->connect("pressed", this,"_action_pressed",binds);
} }
color_picker = memnew( ColorPicker ); color_picker=NULL;
add_child(color_picker);
color_picker->hide();
color_picker->set_area_as_parent_rect();
for(int i=0;i<4;i++)
color_picker->set_margin((Margin)i,5);
color_picker->connect("color_changed",this,"_color_changed");
set_as_toplevel(true); set_as_toplevel(true);
file = memnew ( EditorFileDialog ); file = memnew ( EditorFileDialog );

View File

@ -461,6 +461,9 @@ void SceneTreeEditor::_node_script_changed(Node *p_node) {
void SceneTreeEditor::_node_removed(Node *p_node) { void SceneTreeEditor::_node_removed(Node *p_node) {
if (EditorNode::get_singleton()->is_exiting())
return; //speed up exit
if (p_node->is_connected("script_changed",this,"_node_script_changed")) if (p_node->is_connected("script_changed",this,"_node_script_changed"))
p_node->disconnect("script_changed",this,"_node_script_changed"); p_node->disconnect("script_changed",this,"_node_script_changed");
@ -534,6 +537,8 @@ void SceneTreeEditor::_test_update_tree() {
void SceneTreeEditor::_tree_changed() { void SceneTreeEditor::_tree_changed() {
if (EditorNode::get_singleton()->is_exiting())
return; //speed up exit
if (pending_test_update) if (pending_test_update)
return; return;
if (tree_dirty) if (tree_dirty)