summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorVyacheslav Reutskiy <v.reutskiy@samsung.com>2013-11-04 15:28:59 +0900
committerCedric Bail <cedric.bail@samsung.com>2013-11-04 15:29:09 +0900
commitcff3ec04b4d234c8ef59f9d6235e85b725e0bcf3 (patch)
tree071b2aafa05ace0b793de1ea92647da1c10b6e61 /src/bin
parent2d54ae83bf84854291949b5802f361851fbf5977 (diff)
edje: delete unused images from eet(edj) file.
Update the data_process_lookups function. Earlier images are not deleted, but his name was removed from the list, and it was possible to access the image by id. Now all unused images are deleted. Reviewers: cedric, seoz Differential Revision: https://phab.enlightenment.org/D309 Signed-off-by: Cedric Bail <cedric.bail@samsung.com>
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/edje/edje_cc_out.c92
1 files changed, 89 insertions, 3 deletions
diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c
index 8c3e8628b6..1c09c3eb3a 100644
--- a/src/bin/edje/edje_cc_out.c
+++ b/src/bin/edje/edje_cc_out.c
@@ -175,6 +175,14 @@ struct _Group_Write
175 char *errstr; 175 char *errstr;
176}; 176};
177 177
178struct _Image_Unused_Ids
179{
180 int old_id;
181 int new_id;
182};
183
184typedef struct _Image_Unused_Ids Image_Unused_Ids;
185
178static int pending_threads = 0; 186static int pending_threads = 0;
179 187
180static void data_process_string(Edje_Part_Collection *pc, const char *prefix, char *s, void (*func)(Edje_Part_Collection *pc, char *name, char* ptr, int len)); 188static void data_process_string(Edje_Part_Collection *pc, const char *prefix, char *s, void (*func)(Edje_Part_Collection *pc, char *name, char* ptr, int len));
@@ -2209,6 +2217,58 @@ data_process_part_set(Part_Lookup *target, int value)
2209 } 2217 }
2210} 2218}
2211 2219
2220static void
2221_data_image_id_update(Eina_List *images_unused_list)
2222{
2223 Image_Unused_Ids *iui;
2224 Edje_Part_Collection *pc;
2225 Edje_Part *part;
2226 Edje_Part_Description_Image *part_desc_image;
2227 Edje_Part_Image_Id *tween_id;
2228 unsigned int i, j, desc_it;
2229 Eina_List *l, *l2, *l3;
2230
2231#define PART_DESC_IMAGE_ID_UPDATE \
2232 EINA_LIST_FOREACH(images_unused_list, l3, iui) \
2233 { \
2234 if (part_desc_image->image.id == iui->old_id) \
2235 { \
2236 part_desc_image->image.id = iui->new_id; \
2237 break; \
2238 } \
2239 } \
2240 for (desc_it = 0; desc_it < part_desc_image->image.tweens_count; desc_it++) \
2241 { \
2242 tween_id = part_desc_image->image.tweens[desc_it]; \
2243 EINA_LIST_FOREACH(images_unused_list, l3, iui) \
2244 { \
2245 if (tween_id->id == iui->old_id) \
2246 { \
2247 tween_id->id = iui->new_id; \
2248 break; \
2249 } \
2250 } \
2251 }
2252
2253 EINA_LIST_FOREACH_SAFE(edje_collections, l, l2, pc)
2254 {
2255 for(i = 0; i < pc->parts_count; i++)
2256 {
2257 part = pc->parts[i];
2258 if (part->type == EDJE_PART_TYPE_IMAGE)
2259 {
2260 part_desc_image = (Edje_Part_Description_Image *)part->default_desc;
2261 PART_DESC_IMAGE_ID_UPDATE
2262 for (j = 0; j < part->other.desc_count; j++)
2263 {
2264 part_desc_image = (Edje_Part_Description_Image *)part->other.desc[j];
2265 PART_DESC_IMAGE_ID_UPDATE
2266 }
2267 }
2268 }
2269 }
2270}
2271
2212void 2272void
2213data_process_lookups(void) 2273data_process_lookups(void)
2214{ 2274{
@@ -2224,6 +2284,7 @@ data_process_lookups(void)
2224 void *data; 2284 void *data;
2225 char *group_name; 2285 char *group_name;
2226 Eina_Bool is_lua = EINA_FALSE; 2286 Eina_Bool is_lua = EINA_FALSE;
2287 Image_Unused_Ids *iui;
2227 2288
2228 /* remove all unreferenced Edje_Part_Collection */ 2289 /* remove all unreferenced Edje_Part_Collection */
2229 EINA_LIST_FOREACH_SAFE(edje_collections, l, l2, pc) 2290 EINA_LIST_FOREACH_SAFE(edje_collections, l, l2, pc)
@@ -2534,8 +2595,10 @@ free_group:
2534 2595
2535 if (edje_file->image_dir && !is_lua) 2596 if (edje_file->image_dir && !is_lua)
2536 { 2597 {
2537 Edje_Image_Directory_Entry *de; 2598 Edje_Image_Directory_Entry *de, *de_last, *img;
2538 Edje_Image_Directory_Set *set; 2599 Edje_Image_Directory_Set *set;
2600 Edje_Image_Directory_Set_Entry *set_e;
2601 Eina_List *images_unused_list = NULL;
2539 unsigned int i; 2602 unsigned int i;
2540 2603
2541 for (i = 0; i < edje_file->image_dir->entries_count; ++i) 2604 for (i = 0; i < edje_file->image_dir->entries_count; ++i)
@@ -2548,7 +2611,22 @@ free_group:
2548 INF("Image '%s' in resource 'edje/image/%i' will not be included as it is unused.", 2611 INF("Image '%s' in resource 'edje/image/%i' will not be included as it is unused.",
2549 de->entry, de->id); 2612 de->entry, de->id);
2550 2613
2614 /* so as not to write the unused images, moved last image in the
2615 list to unused image position and check it */
2616 free((void *)de->entry);
2551 de->entry = NULL; 2617 de->entry = NULL;
2618 de_last = edje_file->image_dir->entries + edje_file->image_dir->entries_count - 1;
2619 iui = mem_alloc(SZ(Image_Unused_Ids));
2620 iui->old_id = de_last->id;
2621 images_unused_list = eina_list_append(images_unused_list, iui);
2622 iui->new_id = i;
2623 de_last->id = i;
2624 memcpy(de, de_last, sizeof (Edje_Image_Directory_Entry));
2625 --i; /* need to check a moved image on this index */
2626 edje_file->image_dir->entries_count--;
2627 img = realloc(edje_file->image_dir->entries,
2628 sizeof (Edje_Image_Directory_Entry) * edje_file->image_dir->entries_count);
2629 edje_file->image_dir->entries = img;
2552 } 2630 }
2553 2631
2554 for (i = 0; i < edje_file->image_dir->sets_count; ++i) 2632 for (i = 0; i < edje_file->image_dir->sets_count; ++i)
@@ -2560,9 +2638,17 @@ free_group:
2560 2638
2561 INF("Set '%s' will not be included as it is unused.", set->name); 2639 INF("Set '%s' will not be included as it is unused.", set->name);
2562 2640
2563 set->name = NULL; 2641 free((void *)set->name);
2564 set->entries = NULL; 2642 EINA_LIST_FREE(set->entries, set_e)
2643 {
2644 free((void *)set_e->name);
2645 free(set_e);
2646 }
2565 } 2647 }
2648 /* update image id in parts */
2649 if (images_unused_list) _data_image_id_update(images_unused_list);
2650 EINA_LIST_FREE(images_unused_list, iui)
2651 free(iui);
2566 } 2652 }
2567 2653
2568 eina_hash_free(images_in_use); 2654 eina_hash_free(images_in_use);