diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-06-07 22:08:12 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-06-07 22:10:09 -0300 |
commit | d61b91cbe0c05466182b15a6dd1899e92fcac749 (patch) | |
tree | 3021e43e4e99650062275407616d613b105e13d8 | |
parent | 193272aa8a809168b836dde3535cf96ce1f52264 (diff) |
-Heavily improved editor startup and exit performance
-rw-r--r-- | platform/android/export/export.cpp | 181 | ||||
-rw-r--r-- | platform/bb10/export/export.cpp | 122 | ||||
-rw-r--r-- | scene/main/node.cpp | 51 | ||||
-rw-r--r-- | scene/main/node.h | 3 | ||||
-rw-r--r-- | scene/main/scene_main_loop.cpp | 17 | ||||
-rw-r--r-- | scene/main/scene_main_loop.h | 9 | ||||
-rw-r--r-- | tools/editor/editor_node.cpp | 3 | ||||
-rw-r--r-- | tools/editor/editor_node.h | 3 | ||||
-rw-r--r-- | tools/editor/property_editor.cpp | 23 | ||||
-rw-r--r-- | tools/editor/scene_tree_editor.cpp | 5 |
10 files changed, 226 insertions, 191 deletions
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index bd63cadc57..060819b90e 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1377,120 +1377,125 @@ void EditorExportPlatformAndroid::_device_poll_thread(void *ud) { while(!ea->quit_request) { String adb=EditorSettings::get_singleton()->get("android/adb"); - if (!FileAccess::exists(adb)) { - OS::get_singleton()->delay_usec(3000000); - continue; //adb not configured - } - - String devices; - List<String> args; - args.push_back("devices"); - int ec; - Error err = OS::get_singleton()->execute(adb,args,true,NULL,&devices,&ec); - Vector<String> ds = devices.split("\n"); - Vector<String> ldevices; - for(int i=1;i<ds.size();i++) { - - String d = ds[i]; - int dpos = d.find("device"); - if (dpos==-1) - continue; - d=d.substr(0,dpos).strip_edges(); -// print_line("found devuce: "+d); - ldevices.push_back(d); - } + if (FileAccess::exists(adb)) { + + String devices; + List<String> args; + args.push_back("devices"); + int ec; + Error err = OS::get_singleton()->execute(adb,args,true,NULL,&devices,&ec); + Vector<String> ds = devices.split("\n"); + Vector<String> ldevices; + for(int i=1;i<ds.size();i++) { + + String d = ds[i]; + int dpos = d.find("device"); + if (dpos==-1) + continue; + d=d.substr(0,dpos).strip_edges(); + // print_line("found devuce: "+d); + ldevices.push_back(d); + } - ea->device_lock->lock(); + ea->device_lock->lock(); - bool different=false; + bool different=false; - if (devices.size()!=ldevices.size()) { + if (devices.size()!=ldevices.size()) { - different=true; - } else { + different=true; + } else { - for(int i=0;i<ea->devices.size();i++) { + for(int i=0;i<ea->devices.size();i++) { - if (ea->devices[i].id!=ldevices[i]) { - different=true; - break; + if (ea->devices[i].id!=ldevices[i]) { + different=true; + break; + } } } - } - if (different) { + if (different) { - Vector<Device> ndevices; + Vector<Device> ndevices; - for(int i=0;i<ldevices.size();i++) { + for(int i=0;i<ldevices.size();i++) { - Device d; - d.id=ldevices[i]; - for(int j=0;j<ea->devices.size();j++) { - if (ea->devices[j].id==ldevices[i]) { - d.description=ea->devices[j].description; - d.name=ea->devices[j].name; + Device d; + d.id=ldevices[i]; + for(int j=0;j<ea->devices.size();j++) { + if (ea->devices[j].id==ldevices[i]) { + d.description=ea->devices[j].description; + d.name=ea->devices[j].name; + } } - } - if (d.description=="") { - //in the oven, request! - args.clear(); - args.push_back("-s"); - args.push_back(d.id); - args.push_back("shell"); - args.push_back("cat"); - args.push_back("/system/build.prop"); - int ec; - String dp; - - Error err = OS::get_singleton()->execute(adb,args,true,NULL,&dp,&ec); - print_line("RV: "+itos(ec)); - Vector<String> props = dp.split("\n"); - String vendor; - String device; - d.description+"Device ID: "+d.id+"\n"; - for(int j=0;j<props.size();j++) { - - String p = props[j]; - if (p.begins_with("ro.product.model=")) { - device=p.get_slice("=",1).strip_edges(); - } else if (p.begins_with("ro.product.brand=")) { - vendor=p.get_slice("=",1).strip_edges().capitalize(); - } else if (p.begins_with("ro.build.display.id=")) { - d.description+="Build: "+p.get_slice("=",1).strip_edges()+"\n"; - } else if (p.begins_with("ro.build.version.release=")) { - d.description+="Release: "+p.get_slice("=",1).strip_edges()+"\n"; - } else if (p.begins_with("ro.product.cpu.abi=")) { - d.description+="CPU: "+p.get_slice("=",1).strip_edges()+"\n"; - } else if (p.begins_with("ro.product.manufacturer=")) { - d.description+="Manufacturer: "+p.get_slice("=",1).strip_edges()+"\n"; - } else if (p.begins_with("ro.board.platform=")) { - d.description+="Chipset: "+p.get_slice("=",1).strip_edges()+"\n"; - } else if (p.begins_with("ro.opengles.version=")) { - uint32_t opengl = p.get_slice("=",1).to_int(); - d.description+="OpenGL: "+itos(opengl>>16)+"."+itos((opengl>>8)&0xFF)+"."+itos((opengl)&0xFF)+"\n"; + if (d.description=="") { + //in the oven, request! + args.clear(); + args.push_back("-s"); + args.push_back(d.id); + args.push_back("shell"); + args.push_back("cat"); + args.push_back("/system/build.prop"); + int ec; + String dp; + + Error err = OS::get_singleton()->execute(adb,args,true,NULL,&dp,&ec); + print_line("RV: "+itos(ec)); + Vector<String> props = dp.split("\n"); + String vendor; + String device; + d.description+"Device ID: "+d.id+"\n"; + for(int j=0;j<props.size();j++) { + + String p = props[j]; + if (p.begins_with("ro.product.model=")) { + device=p.get_slice("=",1).strip_edges(); + } else if (p.begins_with("ro.product.brand=")) { + vendor=p.get_slice("=",1).strip_edges().capitalize(); + } else if (p.begins_with("ro.build.display.id=")) { + d.description+="Build: "+p.get_slice("=",1).strip_edges()+"\n"; + } else if (p.begins_with("ro.build.version.release=")) { + d.description+="Release: "+p.get_slice("=",1).strip_edges()+"\n"; + } else if (p.begins_with("ro.product.cpu.abi=")) { + d.description+="CPU: "+p.get_slice("=",1).strip_edges()+"\n"; + } else if (p.begins_with("ro.product.manufacturer=")) { + d.description+="Manufacturer: "+p.get_slice("=",1).strip_edges()+"\n"; + } else if (p.begins_with("ro.board.platform=")) { + d.description+="Chipset: "+p.get_slice("=",1).strip_edges()+"\n"; + } else if (p.begins_with("ro.opengles.version=")) { + uint32_t opengl = p.get_slice("=",1).to_int(); + d.description+="OpenGL: "+itos(opengl>>16)+"."+itos((opengl>>8)&0xFF)+"."+itos((opengl)&0xFF)+"\n"; + } } + + d.name=vendor+" "+device; + // print_line("name: "+d.name); + // print_line("description: "+d.description); + } - d.name=vendor+" "+device; -// print_line("name: "+d.name); -// print_line("description: "+d.description); + ndevices.push_back(d); } - ndevices.push_back(d); - + ea->devices=ndevices; + ea->devices_changed=true; } - ea->devices=ndevices; - ea->devices_changed=true; + 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")) { diff --git a/platform/bb10/export/export.cpp b/platform/bb10/export/export.cpp index da3a958a56..daee5aab9b 100644 --- a/platform/bb10/export/export.cpp +++ b/platform/bb10/export/export.cpp @@ -532,95 +532,99 @@ void EditorExportPlatformBB10::_device_poll_thread(void *ud) { if (windows) bb_deploy+=".bat"; - if (!FileAccess::exists(bb_deploy)) { - OS::get_singleton()->delay_usec(3000000); - continue; //adb not configured - } + if (FileAccess::exists(bb_deploy)) { - Vector<Device> devices; + Vector<Device> devices; - for (int i=0;i<MAX_DEVICES;i++) { + for (int i=0;i<MAX_DEVICES;i++) { - String host = EditorSettings::get_singleton()->get("blackberry/device_"+itos(i+1)+"/host"); - if (host==String()) - continue; - String pass = EditorSettings::get_singleton()->get("blackberry/device_"+itos(i+1)+"/password"); - if (pass==String()) - continue; + String host = EditorSettings::get_singleton()->get("blackberry/device_"+itos(i+1)+"/host"); + if (host==String()) + continue; + String pass = EditorSettings::get_singleton()->get("blackberry/device_"+itos(i+1)+"/password"); + if (pass==String()) + continue; - List<String> args; - args.push_back("-listDeviceInfo"); - args.push_back(host); - args.push_back("-password"); - args.push_back(pass); + List<String> args; + args.push_back("-listDeviceInfo"); + args.push_back(host); + args.push_back("-password"); + args.push_back(pass); - int ec; - String dp; + int ec; + String dp; - Error err = OS::get_singleton()->execute(bb_deploy,args,true,NULL,&dp,&ec); + Error err = OS::get_singleton()->execute(bb_deploy,args,true,NULL,&dp,&ec); - if (err==OK && ec==0) { + if (err==OK && ec==0) { - Device dev; - dev.index=i; - String descr; - Vector<String> ls=dp.split("\n"); + Device dev; + dev.index=i; + String descr; + Vector<String> ls=dp.split("\n"); - for(int i=0;i<ls.size();i++) { + for(int i=0;i<ls.size();i++) { + + String l = ls[i].strip_edges(); + if (l.begins_with("modelfullname::")) { + dev.name=l.get_slice("::",1); + descr+="Model: "+dev.name+"\n"; + } + if (l.begins_with("modelnumber::")) { + String s = l.get_slice("::",1); + dev.name+=" ("+s+")"; + descr+="Model Number: "+s+"\n"; + } + if (l.begins_with("scmbundle::")) + descr+="OS Version: "+l.get_slice("::",1)+"\n"; + if (l.begins_with("[n]debug_token_expiration::")) + descr+="Debug Token Expires:: "+l.get_slice("::",1)+"\n"; - String l = ls[i].strip_edges(); - if (l.begins_with("modelfullname::")) { - dev.name=l.get_slice("::",1); - descr+="Model: "+dev.name+"\n"; - } - if (l.begins_with("modelnumber::")) { - String s = l.get_slice("::",1); - dev.name+=" ("+s+")"; - descr+="Model Number: "+s+"\n"; } - if (l.begins_with("scmbundle::")) - descr+="OS Version: "+l.get_slice("::",1)+"\n"; - if (l.begins_with("[n]debug_token_expiration::")) - descr+="Debug Token Expires:: "+l.get_slice("::",1)+"\n"; + dev.description=descr; + devices.push_back(dev); } - dev.description=descr; - devices.push_back(dev); } - } - - bool changed=false; + bool changed=false; - ea->device_lock->lock(); + ea->device_lock->lock(); - if (ea->devices.size()!=devices.size()) { - changed=true; - } else { + if (ea->devices.size()!=devices.size()) { + changed=true; + } else { - for(int i=0;i<ea->devices.size();i++) { + for(int i=0;i<ea->devices.size();i++) { - if (ea->devices[i].index!=devices[i].index) { - changed=true; - break; + if (ea->devices[i].index!=devices[i].index) { + changed=true; + break; + } } } - } - if (changed) { + if (changed) { - ea->devices=devices; - ea->devices_changed=true; - } + ea->devices=devices; + ea->devices_changed=true; + } - 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; + } } } diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 29925b62f5..f8af83e23b 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -168,11 +168,8 @@ void Node::_propagate_enter_tree() { data.inside_tree=true; - const StringName *K=NULL; - - while ((K=data.grouped.next(K))) { - - data.tree->add_to_group(*K,this); + for (Map< StringName, GroupData>::Element *E=data.grouped.front();E;E=E->next()) { + E->get().group=data.tree->add_to_group(E->key(),this); } @@ -257,13 +254,13 @@ void Node::_propagate_exit_tree() { data.tree->node_removed(this); // exit groups - const StringName *K=NULL; - while ((K=data.grouped.next(K))) { - - data.tree->remove_from_group(*K,this); + for (Map< StringName, GroupData>::Element *E=data.grouped.front();E;E=E->next()) { + data.tree->remove_from_group(E->key(),this); + E->get().group=NULL; } + data.viewport = NULL; 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 ); } + for (const Map< StringName, GroupData>::Element *E=p_child->data.grouped.front();E;E=E->next()) { + E->get().group->changed=true; + } data.blocked--; @@ -1193,8 +1193,12 @@ void Node::add_to_group(const StringName& p_identifier,bool p_persistent) { GroupData gd; - if (data.tree) - data.tree->add_to_group(p_identifier,this); + SceneTree::Group *gptr=NULL; + if (data.tree) { + gd.group=data.tree->add_to_group(p_identifier,this); + } else { + gd.group=NULL; + } 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) ); - 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) - 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 { - 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; - gi.name=*K; - gi.persistent=data.grouped[*K].persistent; + gi.name=E->key(); + gi.persistent=E->get().persistent; p_groups->push_back(gi); } @@ -1246,16 +1249,16 @@ void Node::get_groups(List<GroupInfo> *p_groups) const { bool Node::has_persistent_groups() const { - const StringName *K=NULL; - while ((K=data.grouped.next(K))) { - - if (data.grouped[*K].persistent) + for (const Map< StringName, GroupData>::Element *E=data.grouped.front();E;E=E->next()) { + if (E->get().persistent) return true; } + return false; + } void Node::_print_tree(const Node *p_node) { diff --git a/scene/main/node.h b/scene/main/node.h index cf62e7cdea..d099f6e773 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -64,6 +64,7 @@ private: struct GroupData { bool persistent; + SceneTree::Group *group; GroupData() { persistent=false; } }; @@ -91,7 +92,7 @@ private: Viewport *viewport; - HashMap< StringName, GroupData,StringNameHasher> grouped; + Map< StringName, GroupData> grouped; List<Node*>::Element *OW; // owned element List<Node*> owned; diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp index d7f22c3228..a7ef7ca7c1 100644 --- a/scene/main/scene_main_loop.cpp +++ b/scene/main/scene_main_loop.cpp @@ -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); 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) { ERR_EXPLAIN("Already in group: "+p_group); - ERR_FAIL(); + ERR_FAIL_V(&E->get()); } 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) { @@ -125,7 +127,7 @@ void SceneTree::_flush_ugc() { void SceneTree::_update_group_order(Group& g) { - if (g.last_tree_version==tree_version) + if (!g.changed) return; if (g.nodes.empty()) return; @@ -135,7 +137,8 @@ void SceneTree::_update_group_order(Group& g) { SortArray<Node*,Node::Comparator> node_sort; 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()) return; - _update_group_order(g); - 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; } + _update_group_order(g); + Vector<Node*> nodes_copy = g.nodes; Node **nodes = &nodes_copy[0]; int node_count=nodes_copy.size(); diff --git a/scene/main/scene_main_loop.h b/scene/main/scene_main_loop.h index 5fc9e0c1ae..15604a3460 100644 --- a/scene/main/scene_main_loop.h +++ b/scene/main/scene_main_loop.h @@ -76,8 +76,9 @@ private: struct Group { Vector<Node*> nodes; - uint64_t last_tree_version; - Group() { last_tree_version=0; }; + //uint64_t last_tree_version; + bool changed; + Group() { changed=false; }; }; Viewport *root; @@ -135,7 +136,7 @@ private: void _flush_ugc(); void _flush_transform_notifications(); - void _update_group_order(Group& g); + _FORCE_INLINE_ void _update_group_order(Group& g); void _update_listener(); Array _get_nodes_in_group(const StringName& p_group); @@ -162,7 +163,7 @@ friend class 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 _notify_group_pause(const StringName& p_group,int p_notification); diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 01a6e3514c..cc5a44a650 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -2414,6 +2414,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { _menu_option_confirm(RUN_STOP,true); + exiting=true; get_tree()->quit(); } break; @@ -2747,6 +2748,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } _menu_option_confirm(RUN_STOP,true); + exiting=true; get_tree()->quit(); String exec = OS::get_singleton()->get_executable_path(); @@ -5244,6 +5246,7 @@ EditorNode::EditorNode() { singleton=this; + exiting=false; last_checked_version=0; changing_scene=false; _initializing_addons=false; diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index 7d9b11ed83..65a5687dce 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -227,6 +227,7 @@ private: Tabs *scene_tabs; int tab_closing; + bool exiting; int old_split_ofs; VSplitContainer *top_split; @@ -712,6 +713,8 @@ public: void update_keying(); + bool is_exiting() const { return exiting; } + ToolButton *get_pause_button() { return pause_button; } diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 3258bc6d74..2f0ba2da99 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -247,7 +247,8 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty hint=p_hint; hint_text=p_hint_text; type_button->hide(); - color_picker->hide(); + if (color_picker) + color_picker->hide(); texture_preview->hide(); inheritors_array.clear(); text_edit->hide(); @@ -596,6 +597,16 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty } break; 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->set_edit_alpha(hint!=PROPERTY_HINT_COLOR_NO_ALPHA); @@ -1757,13 +1768,9 @@ CustomPropertyEditor::CustomPropertyEditor() { action_buttons[i]->connect("pressed", this,"_action_pressed",binds); } - 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=NULL; + + set_as_toplevel(true); file = memnew ( EditorFileDialog ); diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp index bc12ff23e5..f8ce121690 100644 --- a/tools/editor/scene_tree_editor.cpp +++ b/tools/editor/scene_tree_editor.cpp @@ -461,6 +461,9 @@ void SceneTreeEditor::_node_script_changed(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")) p_node->disconnect("script_changed",this,"_node_script_changed"); @@ -534,6 +537,8 @@ void SceneTreeEditor::_test_update_tree() { void SceneTreeEditor::_tree_changed() { + if (EditorNode::get_singleton()->is_exiting()) + return; //speed up exit if (pending_test_update) return; if (tree_dirty) |