forked from enlightenment/efl
edje: reduce parts walk during load time of Edje file.
SVN revision: 66281
This commit is contained in:
parent
3e46832708
commit
186db4e496
|
@ -242,3 +242,4 @@
|
||||||
2011-12-16 Cedric Bail
|
2011-12-16 Cedric Bail
|
||||||
|
|
||||||
* Fix wrong call to free() in edje_load.
|
* Fix wrong call to free() in edje_load.
|
||||||
|
* Reduce parts walk to the strict minimum.
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
Edje 1.1.0
|
Edje 1.1.0
|
||||||
|
|
||||||
|
Changes since Edje 1.1.0:
|
||||||
|
|
||||||
|
Improvements:
|
||||||
|
* speedup load time of Edje file.
|
||||||
|
|
||||||
Changes since Edje 1.0.0:
|
Changes since Edje 1.0.0:
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
|
|
|
@ -262,6 +262,10 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
|
||||||
{
|
{
|
||||||
Edje *ed;
|
Edje *ed;
|
||||||
Evas *tev;
|
Evas *tev;
|
||||||
|
Edje_Real_Part *rp;
|
||||||
|
Eina_List *textblocks = NULL;
|
||||||
|
Eina_List *sources = NULL;
|
||||||
|
Eina_List *externals = NULL;
|
||||||
Eina_List *old_swallows;
|
Eina_List *old_swallows;
|
||||||
unsigned int n;
|
unsigned int n;
|
||||||
Eina_List *parts = NULL;
|
Eina_List *parts = NULL;
|
||||||
|
@ -323,7 +327,6 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int errors = 0;
|
|
||||||
|
|
||||||
/* colorclass stuff */
|
/* colorclass stuff */
|
||||||
for (i = 0; i < ed->collection->parts_count; ++i)
|
for (i = 0; i < ed->collection->parts_count; ++i)
|
||||||
|
@ -333,8 +336,6 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
|
||||||
|
|
||||||
ep = ed->collection->parts[i];
|
ep = ed->collection->parts[i];
|
||||||
|
|
||||||
if (errors)
|
|
||||||
break;
|
|
||||||
/* Register any color classes in this parts descriptions. */
|
/* Register any color classes in this parts descriptions. */
|
||||||
if ((ep->default_desc) && (ep->default_desc->color_class))
|
if ((ep->default_desc) && (ep->default_desc->color_class))
|
||||||
_edje_color_class_member_add(ed, ep->default_desc->color_class);
|
_edje_color_class_member_add(ed, ep->default_desc->color_class);
|
||||||
|
@ -353,12 +354,12 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
|
||||||
for (n = 0; n < ed->collection->parts_count; n++)
|
for (n = 0; n < ed->collection->parts_count; n++)
|
||||||
{
|
{
|
||||||
Edje_Part *ep;
|
Edje_Part *ep;
|
||||||
Edje_Real_Part *rp;
|
|
||||||
|
|
||||||
ep = ed->collection->parts[n];
|
ep = ed->collection->parts[n];
|
||||||
rp = eina_mempool_malloc(_edje_real_part_mp, sizeof(Edje_Real_Part));
|
rp = eina_mempool_malloc(_edje_real_part_mp, sizeof(Edje_Real_Part));
|
||||||
if (!rp)
|
if (!rp)
|
||||||
{
|
{
|
||||||
|
/* FIXME: destroy all allocated ressource, need to have a common exit point */
|
||||||
ed->load_error = EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
|
ed->load_error = EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
|
||||||
evas_event_thaw(tev);
|
evas_event_thaw(tev);
|
||||||
evas_event_thaw_eval(tev);
|
evas_event_thaw_eval(tev);
|
||||||
|
@ -407,9 +408,12 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
|
||||||
rp->object = evas_object_text_add(ed->base.evas);
|
rp->object = evas_object_text_add(ed->base.evas);
|
||||||
evas_object_text_font_source_set(rp->object, ed->path);
|
evas_object_text_font_source_set(rp->object, ed->path);
|
||||||
break;
|
break;
|
||||||
case EDJE_PART_TYPE_SWALLOW:
|
|
||||||
case EDJE_PART_TYPE_GROUP:
|
case EDJE_PART_TYPE_GROUP:
|
||||||
|
sources = eina_list_append(sources, rp);
|
||||||
|
case EDJE_PART_TYPE_SWALLOW:
|
||||||
case EDJE_PART_TYPE_EXTERNAL:
|
case EDJE_PART_TYPE_EXTERNAL:
|
||||||
|
if (ep->type == EDJE_PART_TYPE_EXTERNAL)
|
||||||
|
externals = eina_list_append(externals, rp);
|
||||||
rp->object = evas_object_rectangle_add(ed->base.evas);
|
rp->object = evas_object_rectangle_add(ed->base.evas);
|
||||||
evas_object_color_set(rp->object, 0, 0, 0, 0);
|
evas_object_color_set(rp->object, 0, 0, 0, 0);
|
||||||
evas_object_pass_events_set(rp->object, 1);
|
evas_object_pass_events_set(rp->object, 1);
|
||||||
|
@ -417,13 +421,16 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
|
||||||
_edje_callbacks_focus_add(rp->object, ed, rp);
|
_edje_callbacks_focus_add(rp->object, ed, rp);
|
||||||
break;
|
break;
|
||||||
case EDJE_PART_TYPE_TEXTBLOCK:
|
case EDJE_PART_TYPE_TEXTBLOCK:
|
||||||
|
textblocks = eina_list_append(textblocks, rp);
|
||||||
rp->object = evas_object_textblock_add(ed->base.evas);
|
rp->object = evas_object_textblock_add(ed->base.evas);
|
||||||
break;
|
break;
|
||||||
case EDJE_PART_TYPE_BOX:
|
case EDJE_PART_TYPE_BOX:
|
||||||
|
sources = eina_list_append(sources, rp);
|
||||||
rp->object = evas_object_box_add(ed->base.evas);
|
rp->object = evas_object_box_add(ed->base.evas);
|
||||||
rp->anim = _edje_box_layout_anim_new(rp->object);
|
rp->anim = _edje_box_layout_anim_new(rp->object);
|
||||||
break;
|
break;
|
||||||
case EDJE_PART_TYPE_TABLE:
|
case EDJE_PART_TYPE_TABLE:
|
||||||
|
sources = eina_list_append(sources, rp);
|
||||||
rp->object = evas_object_table_add(ed->base.evas);
|
rp->object = evas_object_table_add(ed->base.evas);
|
||||||
break;
|
break;
|
||||||
case EDJE_PART_TYPE_GRADIENT:
|
case EDJE_PART_TYPE_GRADIENT:
|
||||||
|
@ -463,7 +470,6 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
|
||||||
}
|
}
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
{
|
{
|
||||||
Edje_Real_Part *rp;
|
|
||||||
Eina_List *l;
|
Eina_List *l;
|
||||||
|
|
||||||
ed->table_parts = malloc(sizeof(Edje_Real_Part *) * n);
|
ed->table_parts = malloc(sizeof(Edje_Real_Part *) * n);
|
||||||
|
@ -587,8 +593,6 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
|
||||||
_edje_var_init(ed);
|
_edje_var_init(ed);
|
||||||
for (i = 0; i < ed->table_parts_size; i++)
|
for (i = 0; i < ed->table_parts_size; i++)
|
||||||
{
|
{
|
||||||
Edje_Real_Part *rp;
|
|
||||||
|
|
||||||
rp = ed->table_parts[i];
|
rp = ed->table_parts[i];
|
||||||
evas_object_show(rp->object);
|
evas_object_show(rp->object);
|
||||||
if (_edje_block_break(ed)) break;
|
if (_edje_block_break(ed)) break;
|
||||||
|
@ -606,11 +610,28 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
|
||||||
if ((evas_object_clipees_get(ed->base.clipper)) &&
|
if ((evas_object_clipees_get(ed->base.clipper)) &&
|
||||||
(evas_object_visible_get(obj)))
|
(evas_object_visible_get(obj)))
|
||||||
evas_object_show(ed->base.clipper);
|
evas_object_show(ed->base.clipper);
|
||||||
|
|
||||||
/* instantiate 'internal swallows' */
|
/* instantiate 'internal swallows' */
|
||||||
for (i = 0; i < ed->table_parts_size; i++)
|
EINA_LIST_FREE(externals, rp)
|
||||||
|
{
|
||||||
|
Edje_Part_Description_External *external;
|
||||||
|
Evas_Object *child_obj;
|
||||||
|
|
||||||
|
external = (Edje_Part_Description_External *) rp->part->default_desc;
|
||||||
|
child_obj = _edje_external_type_add(rp->part->source,
|
||||||
|
evas_object_evas_get(ed->obj), ed->obj,
|
||||||
|
external->external_params, rp->part->name);
|
||||||
|
if (child_obj)
|
||||||
|
{
|
||||||
|
_edje_real_part_swallow(rp, child_obj, EINA_TRUE);
|
||||||
|
rp->param1.external_params = _edje_external_params_parse(child_obj,
|
||||||
|
external->external_params);
|
||||||
|
_edje_external_recalc_apply(ed, rp, NULL, rp->chosen_description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EINA_LIST_FREE(sources, rp)
|
||||||
{
|
{
|
||||||
Edje_Real_Part *rp;
|
|
||||||
/* XXX: curr_item and pack_it don't require to be NULL since
|
/* XXX: curr_item and pack_it don't require to be NULL since
|
||||||
* XXX: they are just used when source != NULL and type == BOX,
|
* XXX: they are just used when source != NULL and type == BOX,
|
||||||
* XXX: and they're always set in this case, but GCC fails to
|
* XXX: and they're always set in this case, but GCC fails to
|
||||||
|
@ -620,8 +641,6 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
|
||||||
unsigned int item_count = 0;
|
unsigned int item_count = 0;
|
||||||
Edje_Pack_Element *pack_it = NULL;
|
Edje_Pack_Element *pack_it = NULL;
|
||||||
const char *source = NULL;
|
const char *source = NULL;
|
||||||
|
|
||||||
rp = ed->table_parts[i];
|
|
||||||
|
|
||||||
switch (rp->part->type)
|
switch (rp->part->type)
|
||||||
{
|
{
|
||||||
|
@ -643,25 +662,9 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EDJE_PART_TYPE_EXTERNAL:
|
|
||||||
{
|
|
||||||
Edje_Part_Description_External *external;
|
|
||||||
Evas_Object *child_obj;
|
|
||||||
|
|
||||||
external = (Edje_Part_Description_External *) rp->part->default_desc;
|
|
||||||
child_obj = _edje_external_type_add(rp->part->source,
|
|
||||||
evas_object_evas_get(ed->obj), ed->obj,
|
|
||||||
external->external_params, rp->part->name);
|
|
||||||
if (child_obj)
|
|
||||||
{
|
|
||||||
_edje_real_part_swallow(rp, child_obj, EINA_TRUE);
|
|
||||||
rp->param1.external_params = _edje_external_params_parse(child_obj,
|
|
||||||
external->external_params);
|
|
||||||
_edje_external_recalc_apply(ed, rp, NULL, rp->chosen_description);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
default:
|
default:
|
||||||
|
/* This list should only be filled by group, box or table, nothing else. */
|
||||||
|
abort();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,6 +685,9 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
|
||||||
{
|
{
|
||||||
if (data == group_path_entry)
|
if (data == group_path_entry)
|
||||||
{
|
{
|
||||||
|
textblocks = eina_list_free(textblocks);
|
||||||
|
externals = eina_list_free(externals);
|
||||||
|
sources = eina_list_free(sources);
|
||||||
_edje_thaw(ed);
|
_edje_thaw(ed);
|
||||||
_edje_unblock(ed);
|
_edje_unblock(ed);
|
||||||
_edje_unref(ed);
|
_edje_unref(ed);
|
||||||
|
@ -698,7 +704,7 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
child_obj = edje_object_add(ed->base.evas);
|
child_obj = edje_object_add(ed->base.evas);
|
||||||
group_path = eina_list_append(group_path, group_path_entry);
|
group_path = eina_list_append(group_path, group_path_entry);
|
||||||
if (rp->part->type == EDJE_PART_TYPE_GROUP)
|
if (rp->part->type == EDJE_PART_TYPE_GROUP)
|
||||||
|
@ -708,11 +714,14 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
|
||||||
|
|
||||||
if (!_edje_object_file_set_internal(child_obj, file, source, rp->part->name, group_path))
|
if (!_edje_object_file_set_internal(child_obj, file, source, rp->part->name, group_path))
|
||||||
{
|
{
|
||||||
|
textblocks = eina_list_free(textblocks);
|
||||||
|
externals = eina_list_free(externals);
|
||||||
|
sources = eina_list_free(sources);
|
||||||
_edje_thaw(ed);
|
_edje_thaw(ed);
|
||||||
_edje_unblock(ed);
|
_edje_unblock(ed);
|
||||||
_edje_unref(ed);
|
_edje_unref(ed);
|
||||||
_edje_file_del(ed);
|
_edje_file_del(ed);
|
||||||
|
|
||||||
if (group_path_started)
|
if (group_path_started)
|
||||||
{
|
{
|
||||||
while (group_path)
|
while (group_path)
|
||||||
|
@ -794,56 +803,51 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
Evas_Object *swallow;
|
Evas_Object *swallow;
|
||||||
|
|
||||||
name = eina_list_data_get(old_swallows);
|
name = eina_list_data_get(old_swallows);
|
||||||
old_swallows = eina_list_remove_list(old_swallows, old_swallows);
|
old_swallows = eina_list_remove_list(old_swallows, old_swallows);
|
||||||
|
|
||||||
swallow = eina_list_data_get(old_swallows);
|
swallow = eina_list_data_get(old_swallows);
|
||||||
old_swallows = eina_list_remove_list(old_swallows, old_swallows);
|
old_swallows = eina_list_remove_list(old_swallows, old_swallows);
|
||||||
|
|
||||||
edje_object_part_swallow(obj, name, swallow);
|
edje_object_part_swallow(obj, name, swallow);
|
||||||
eina_stringshare_del(name);
|
eina_stringshare_del(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_edje_recalc(ed);
|
_edje_recalc(ed);
|
||||||
_edje_thaw(ed);
|
_edje_thaw(ed);
|
||||||
_edje_unblock(ed);
|
_edje_unblock(ed);
|
||||||
_edje_unref(ed);
|
_edje_unref(ed);
|
||||||
ed->load_error = EDJE_LOAD_ERROR_NONE;
|
ed->load_error = EDJE_LOAD_ERROR_NONE;
|
||||||
_edje_emit(ed, "load", NULL);
|
_edje_emit(ed, "load", NULL);
|
||||||
/* instantiate 'internal swallows' */
|
|
||||||
for (i = 0; i < ed->table_parts_size; i++)
|
|
||||||
{
|
|
||||||
Edje_Real_Part *rp;
|
|
||||||
|
|
||||||
rp = ed->table_parts[i];
|
|
||||||
if ((rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) &&
|
|
||||||
(rp->part->default_desc))
|
|
||||||
{
|
|
||||||
Edje_Part_Description_Text *text;
|
|
||||||
Edje_Style *stl = NULL;
|
|
||||||
const char *style;
|
|
||||||
|
|
||||||
text = (Edje_Part_Description_Text *) rp->part->default_desc;
|
/* instantiate 'internal textblock style' */
|
||||||
style = edje_string_get(&text->text.style);
|
EINA_LIST_FREE(textblocks, rp)
|
||||||
if (style)
|
if (rp->part->default_desc)
|
||||||
{
|
{
|
||||||
Eina_List *l;
|
Edje_Part_Description_Text *text;
|
||||||
|
Edje_Style *stl = NULL;
|
||||||
|
const char *style;
|
||||||
|
|
||||||
EINA_LIST_FOREACH(ed->file->styles, l, stl)
|
text = (Edje_Part_Description_Text *) rp->part->default_desc;
|
||||||
{
|
style = edje_string_get(&text->text.style);
|
||||||
if ((stl->name) && (!strcmp(stl->name, style))) break;
|
if (style)
|
||||||
stl = NULL;
|
{
|
||||||
}
|
Eina_List *l;
|
||||||
}
|
|
||||||
if (stl)
|
EINA_LIST_FOREACH(ed->file->styles, l, stl)
|
||||||
{
|
{
|
||||||
if (evas_object_textblock_style_get(rp->object) != stl->style)
|
if ((stl->name) && (!strcmp(stl->name, style))) break;
|
||||||
evas_object_textblock_style_set(rp->object, stl->style);
|
stl = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (stl)
|
||||||
|
{
|
||||||
|
if (evas_object_textblock_style_get(rp->object) != stl->style)
|
||||||
|
evas_object_textblock_style_set(rp->object, stl->style);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_edje_entry_init(ed);
|
_edje_entry_init(ed);
|
||||||
evas_event_thaw(tev);
|
evas_event_thaw(tev);
|
||||||
|
|
Loading…
Reference in New Issue