summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorperepelits.m <perepelits.m@samsung.com>2015-02-05 15:29:03 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-02-09 22:03:26 +0100
commit2e3b9ea589afdcba13d62e04fbc552b1e6c5f12e (patch)
tree675b3f77f0010be8ee2b753c2a3744b90b038514
parentef6456c54193be09536cfb368e57a6e1d53c6911 (diff)
edje: add of model lookups.
Summary: I have added some methods to edje_cc_out.c to organize model lookups. The same methods already exists for images. Also, I have removed source_type because now we don't need it in efl_file_set. @feature Reviewers: raster, Hermet, cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D1886 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/bin/edje/edje_cc.h2
-rwxr-xr-xsrc/bin/edje/edje_cc_out.c174
-rw-r--r--src/lib/edje/edje_private.h1
3 files changed, 176 insertions, 1 deletions
diff --git a/src/bin/edje/edje_cc.h b/src/bin/edje/edje_cc.h
index 7b794ed0ed..d5ee9aa6c3 100644
--- a/src/bin/edje/edje_cc.h
+++ b/src/bin/edje/edje_cc.h
@@ -184,8 +184,10 @@ void data_queue_copied_program_lookup(Edje_Part_Collection *pc, int *src, int
184void data_queue_anonymous_lookup(Edje_Part_Collection *pc, Edje_Program *ep, int *dest); 184void data_queue_anonymous_lookup(Edje_Part_Collection *pc, Edje_Program *ep, int *dest);
185void data_queue_copied_anonymous_lookup(Edje_Part_Collection *pc, int *src, int *dest); 185void data_queue_copied_anonymous_lookup(Edje_Part_Collection *pc, int *src, int *dest);
186void data_queue_image_lookup(char *name, int *dest, Eina_Bool *set); 186void data_queue_image_lookup(char *name, int *dest, Eina_Bool *set);
187void data_queue_model_lookup(char *name, int *dest, Eina_Bool *set);
187void data_queue_copied_image_lookup(int *src, int *dest, Eina_Bool *set); 188void data_queue_copied_image_lookup(int *src, int *dest, Eina_Bool *set);
188void data_queue_image_remove(int *dest, Eina_Bool *set); 189void data_queue_image_remove(int *dest, Eina_Bool *set);
190void data_queue_model_remove(int *dest, Eina_Bool *set);
189void data_queue_spectrum_lookup(char *name, int *dest); 191void data_queue_spectrum_lookup(char *name, int *dest);
190void data_queue_spectrum_slave_lookup(int *master, int *slave); 192void data_queue_spectrum_slave_lookup(int *master, int *slave);
191void data_process_lookups(void); 193void data_process_lookups(void);
diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c
index 4f582c779c..a284bebfff 100755
--- a/src/bin/edje/edje_cc_out.c
+++ b/src/bin/edje/edje_cc_out.c
@@ -213,6 +213,7 @@ static Eina_List *program_lookups = NULL;
213static Eina_List *group_lookups = NULL; 213static Eina_List *group_lookups = NULL;
214static Eina_List *face_group_lookups = NULL; 214static Eina_List *face_group_lookups = NULL;
215static Eina_List *image_lookups = NULL; 215static Eina_List *image_lookups = NULL;
216static Eina_List *model_lookups = NULL;
216 217
217static Eina_Hash *part_dest_lookup = NULL; 218static Eina_Hash *part_dest_lookup = NULL;
218static Eina_Hash *part_pc_dest_lookup = NULL; 219static Eina_Hash *part_pc_dest_lookup = NULL;
@@ -2571,6 +2572,36 @@ data_queue_image_remove(int *dest, Eina_Bool *set)
2571 } 2572 }
2572 2573
2573void 2574void
2575data_queue_model_lookup(char *name, int *dest, Eina_Bool *set)
2576{
2577 Image_Lookup *il;
2578
2579 il = mem_alloc(SZ(Image_Lookup));
2580 model_lookups = eina_list_append(model_lookups, il);
2581 il->name = mem_strdup(name);
2582 il->dest = dest;
2583 il->set = set;
2584}
2585
2586void
2587data_queue_model_remove(int *dest, Eina_Bool *set)
2588{
2589 Eina_List *l;
2590 Image_Lookup *il;
2591
2592 EINA_LIST_FOREACH(model_lookups, l, il)
2593 {
2594 if (il->dest == dest && il->set == set)
2595 {
2596 model_lookups = eina_list_remove_list(model_lookups, l);
2597 free(il->name);
2598 free(il);
2599 return;
2600 }
2601 }
2602}
2603
2604void
2574data_queue_copied_image_lookup(int *src, int *dest, Eina_Bool *set) 2605data_queue_copied_image_lookup(int *src, int *dest, Eina_Bool *set)
2575{ 2606{
2576 Eina_List *l; 2607 Eina_List *l;
@@ -2731,6 +2762,7 @@ _data_image_id_update(Eina_List *images_unused_list)
2731 Edje_Part_Collection *pc; 2762 Edje_Part_Collection *pc;
2732 Edje_Part *part; 2763 Edje_Part *part;
2733 Edje_Part_Description_Image *part_desc_image; 2764 Edje_Part_Description_Image *part_desc_image;
2765 Edje_Part_Description_Mesh_Node *part_desc_mesh_node;
2734 Edje_Part_Image_Id *tween_id; 2766 Edje_Part_Image_Id *tween_id;
2735 unsigned int i, j, desc_it; 2767 unsigned int i, j, desc_it;
2736 Eina_List *l, *l2, *l3; 2768 Eina_List *l, *l2, *l3;
@@ -2757,6 +2789,15 @@ _data_image_id_update(Eina_List *images_unused_list)
2757 } \ 2789 } \
2758 } 2790 }
2759 2791
2792#define PART_DESC_PROXY_ID_UPDATE \
2793 EINA_LIST_FOREACH(images_unused_list, l3, iui) \
2794 { \
2795 if (part_desc_mesh_node->mesh_node.texture.id == iui->old_id) \
2796 { \
2797 part_desc_mesh_node->mesh_node.texture.id = iui->new_id; \
2798 break; \
2799 } \
2800 }
2760 EINA_LIST_FOREACH_SAFE(edje_collections, l, l2, pc) 2801 EINA_LIST_FOREACH_SAFE(edje_collections, l, l2, pc)
2761 { 2802 {
2762 for(i = 0; i < pc->parts_count; i++) 2803 for(i = 0; i < pc->parts_count; i++)
@@ -2773,6 +2814,17 @@ _data_image_id_update(Eina_List *images_unused_list)
2773 PART_DESC_IMAGE_ID_UPDATE 2814 PART_DESC_IMAGE_ID_UPDATE
2774 } 2815 }
2775 } 2816 }
2817 else if (part->type == EDJE_PART_TYPE_MESH_NODE)
2818 {
2819 part_desc_mesh_node = (Edje_Part_Description_Mesh_Node *)part->default_desc;
2820 if (!part_desc_mesh_node) continue;
2821 PART_DESC_PROXY_ID_UPDATE
2822 for (j = 0; j < part->other.desc_count; j++)
2823 {
2824 part_desc_mesh_node = (Edje_Part_Description_Mesh_Node *)part->other.desc[j];
2825 PART_DESC_PROXY_ID_UPDATE
2826 }
2827 }
2776 } 2828 }
2777 } 2829 }
2778 for (i = 0; i < edje_file->image_dir->sets_count; i++) 2830 for (i = 0; i < edje_file->image_dir->sets_count; i++)
@@ -2796,6 +2848,46 @@ _data_image_id_update(Eina_List *images_unused_list)
2796 } 2848 }
2797} 2849}
2798 2850
2851static void
2852_data_model_id_update(Eina_List *models_unused_list)
2853{
2854 Image_Unused_Ids *iui;
2855 Edje_Part_Collection *pc;
2856 Edje_Part *part;
2857 Edje_Part_Description_Mesh_Node *part_desc_mesh_node;
2858 unsigned int i, j;
2859 Eina_List *l, *l2, *l3;
2860
2861#define PART_DESC_MODEL_ID_UPDATE \
2862 EINA_LIST_FOREACH(models_unused_list, l3, iui) \
2863 { \
2864 if (part_desc_mesh_node->mesh_node.mesh.id == iui->old_id) \
2865 { \
2866 part_desc_mesh_node->mesh_node.mesh.id = iui->new_id; \
2867 break; \
2868 } \
2869 } \
2870
2871 EINA_LIST_FOREACH_SAFE(edje_collections, l, l2, pc)
2872 {
2873 for(i = 0; i < pc->parts_count; i++)
2874 {
2875 part = pc->parts[i];
2876 if (part->type == EDJE_PART_TYPE_MESH_NODE)
2877 {
2878 part_desc_mesh_node = (Edje_Part_Description_Mesh_Node *)part->default_desc;
2879 if (!part_desc_mesh_node) continue;
2880 PART_DESC_MODEL_ID_UPDATE
2881 for (j = 0; j < part->other.desc_count; j++)
2882 {
2883 part_desc_mesh_node = (Edje_Part_Description_Mesh_Node *)part->other.desc[j];
2884 PART_DESC_MODEL_ID_UPDATE
2885 }
2886 }
2887 }
2888 }
2889}
2890
2799void 2891void
2800data_process_lookups(void) 2892data_process_lookups(void)
2801{ 2893{
@@ -2805,9 +2897,11 @@ data_process_lookups(void)
2805 Program_Lookup *program; 2897 Program_Lookup *program;
2806 Group_Lookup *group; 2898 Group_Lookup *group;
2807 Image_Lookup *image; 2899 Image_Lookup *image;
2900 Image_Lookup *model;
2808 Eina_List *l2; 2901 Eina_List *l2;
2809 Eina_List *l; 2902 Eina_List *l;
2810 Eina_Hash *images_in_use; 2903 Eina_Hash *images_in_use;
2904 Eina_Hash *models_in_use;
2811 char *group_name; 2905 char *group_name;
2812 Eina_Bool is_lua = EINA_FALSE; 2906 Eina_Bool is_lua = EINA_FALSE;
2813 Image_Unused_Ids *iui; 2907 Image_Unused_Ids *iui;
@@ -3178,6 +3272,86 @@ free_group:
3178 } 3272 }
3179 3273
3180 eina_hash_free(images_in_use); 3274 eina_hash_free(images_in_use);
3275
3276 models_in_use = eina_hash_string_superfast_new(NULL);
3277
3278 EINA_LIST_FREE(model_lookups, model)
3279 {
3280 Eina_Bool find = EINA_FALSE;
3281
3282 if (edje_file->model_dir)
3283 {
3284 Edje_Model_Directory_Entry *de;
3285 unsigned int i;
3286
3287 for (i = 0; i < edje_file->model_dir->entries_count; ++i)
3288 {
3289 de = edje_file->model_dir->entries + i;
3290
3291 if ((de->entry) && (!strcmp(de->entry, model->name)))
3292 {
3293 *(model->dest) = de->id;
3294 *(model->set) = EINA_FALSE;
3295 find = EINA_TRUE;
3296
3297 if (!eina_hash_find(models_in_use, model->name))
3298 eina_hash_direct_add(models_in_use, de->entry, de);
3299 break;
3300 }
3301 }
3302 }
3303
3304 if (!find)
3305 {
3306 ERR("Unable to find model name \"%s\".", model->name);
3307 exit(-1);
3308 }
3309
3310 free(model->name);
3311 free(model);
3312 }
3313
3314 if (edje_file->model_dir && !is_lua)
3315 {
3316 Edje_Model_Directory_Entry *de, *de_last, *mdl;
3317 Eina_List *models_unused_list = NULL;
3318 unsigned int i;
3319
3320 for (i = 0; i < edje_file->model_dir->entries_count; ++i)
3321 {
3322 de = edje_file->model_dir->entries + i;
3323
3324 if (de->entry && eina_hash_find(models_in_use, de->entry))
3325 continue ;
3326
3327 INF("Model '%s' in resource 'edje/model/%i' will not be included as it is unused.",
3328 de->entry, de->id);
3329
3330 /* so as not to write the unused models, moved last model in the
3331 list to unused model position and check it */
3332 free((void *)de->entry);
3333 de->entry = NULL;
3334 de_last = edje_file->model_dir->entries + edje_file->model_dir->entries_count - 1;
3335 iui = mem_alloc(SZ(Image_Unused_Ids));
3336 iui->old_id = de_last->id;
3337 models_unused_list = eina_list_append(models_unused_list, iui);
3338 iui->new_id = i;
3339 de_last->id = i;
3340 memcpy(de, de_last, sizeof (Edje_Model_Directory_Entry));
3341 --i; /* need to check a moved model on this index */
3342 edje_file->model_dir->entries_count--;
3343 mdl = realloc(edje_file->model_dir->entries,
3344 sizeof (Edje_Model_Directory_Entry) * edje_file->model_dir->entries_count);
3345 edje_file->model_dir->entries = mdl;
3346 }
3347
3348 /* update model id in parts */
3349 if (models_unused_list) _data_model_id_update(models_unused_list);
3350 EINA_LIST_FREE(models_unused_list, iui)
3351 free(iui);
3352 }
3353
3354 eina_hash_free(models_in_use);
3181} 3355}
3182 3356
3183static void 3357static void
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 19bc6944ea..6e310eb144 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -633,7 +633,6 @@ struct _Edje_Model_Directory
633struct _Edje_Model_Directory_Entry 633struct _Edje_Model_Directory_Entry
634{ 634{
635 const char *entry; /* the nominal name of the model - if any */ 635 const char *entry; /* the nominal name of the model - if any */
636 int source_type; /* alternate source mode. 0 = none */
637 int id; /* the id no. of the image */ 636 int id; /* the id no. of the image */
638}; 637};
639 638