-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) {
String adb=EditorSettings::get_singleton()->get("android/adb");
if (!FileAccess::exists(adb)) {
OS::get_singleton()->delay_usec(3000000);
continue; //adb not configured
}
if (FileAccess::exists(adb)) {
String devices;
List<String> args;
@ -1489,8 +1486,16 @@ void EditorExportPlatformAndroid::_device_poll_thread(void *ud) {
}
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")) {

View file

@ -532,10 +532,7 @@ 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;
@ -618,9 +615,16 @@ void EditorExportPlatformBB10::_device_poll_thread(void *ud) {
}
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;
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) {

View file

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

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);
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();

View file

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

View file

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

View file

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

View file

@ -247,6 +247,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
hint=p_hint;
hint_text=p_hint_text;
type_button->hide();
if (color_picker)
color_picker->hide();
texture_preview->hide();
inheritors_array.clear();
@ -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 );

View file

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