summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeeyong Um <conr2d@gmail.com>2018-05-01 04:32:37 +0900
committerJeeyong Um <conr2d@gmail.com>2018-05-01 04:46:47 +0900
commit90192a2a4fe92cc94545d4e209dd50930b9febb1 (patch)
tree00b40298cecf9bf359cecb3652188ddf40ea1920
parent929bcec6b22eb6afc7e525de4d6b15b759de1fd0 (diff)
edje_cc: Handle image resources when importing edjdevs/conr2d/import_edj
-rw-r--r--src/bin/edje/edje_cc.h1
-rw-r--r--src/bin/edje/edje_cc_handlers.c46
-rw-r--r--src/bin/edje/edje_cc_out.c40
3 files changed, 80 insertions, 7 deletions
diff --git a/src/bin/edje/edje_cc.h b/src/bin/edje/edje_cc.h
index 90e640b39a..ee2e513588 100644
--- a/src/bin/edje/edje_cc.h
+++ b/src/bin/edje/edje_cc.h
@@ -340,6 +340,7 @@ extern Eina_List *vibration_dirs;
340extern Eina_List *data_dirs; 340extern Eina_List *data_dirs;
341extern char *file_in; 341extern char *file_in;
342extern char *file_out; 342extern char *file_out;
343extern char *file_import;
343extern char *watchfile; 344extern char *watchfile;
344extern char *depfile; 345extern char *depfile;
345extern char *license; 346extern char *license;
diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c
index a5d3e4a176..4e653fe8e5 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -2441,8 +2441,43 @@ st_import(void)
2441 edje_file_import = _edje_file_open(f, &error_ret, eina_file_mtime_get(f), 2441 edje_file_import = _edje_file_open(f, &error_ret, eina_file_mtime_get(f),
2442 EINA_TRUE); 2442 EINA_TRUE);
2443 2443
2444 file_import = eina_strbuf_string_steal(path);
2444 eina_strbuf_free(path); 2445 eina_strbuf_free(path);
2445 free(name); 2446 free(name);
2447
2448 if (edje_file_import->image_dir)
2449 {
2450 unsigned int i;
2451 Edje_Image_Directory *eid, *eid2;
2452 Edje_Image_Directory_Set_Entry *entry, *entry2;
2453 Eina_List *l;
2454
2455 eid2 = edje_file_import->image_dir;
2456 eid = edje_file->image_dir = mem_alloc(SZ(Edje_Image_Directory));
2457
2458 eid->entries_count = eid2->entries_count;
2459 eid->entries = mem_alloc(SZ(Edje_Image_Directory_Entry) * eid->entries_count);
2460
2461 for (i = 0; i < eid->entries_count; i++)
2462 {
2463 eid->entries[i].entry = STRDUP(eid2->entries[i].entry);
2464 eid->entries[i].source_type = eid2->entries[i].source_type;
2465 eid->entries[i].source_param = eid2->entries[i].source_param;
2466 eid->entries[i].id = eid2->entries[i].id;
2467 }
2468
2469 for (i = 0; i < eid->sets_count; i++)
2470 {
2471 eid->sets[i].name = STRDUP(eid2->sets[i].name);
2472 eid->sets[i].id = eid2->sets[i].id;
2473
2474 EINA_LIST_FOREACH(eid2->sets[i].entries, l, entry2)
2475 {
2476 entry = mem_alloc(SZ(Edje_Image_Directory_Set_Entry));
2477 memcpy(entry, entry2, sizeof(Edje_Image_Directory_Set_Entry));
2478 }
2479 }
2480 }
2446} 2481}
2447 2482
2448/** @edcsubsection{toplevel_externals, 2483/** @edcsubsection{toplevel_externals,
@@ -9230,7 +9265,11 @@ st_collections_group_parts_part_description_inherit(void)
9230 ied->image = iparent->image; 9265 ied->image = iparent->image;
9231 9266
9232 data_queue_image_remove(&ied->image.id, &ied->image.set); 9267 data_queue_image_remove(&ied->image.id, &ied->image.set);
9233 data_queue_copied_image_lookup(&iparent->image.id, &ied->image.id, &ied->image.set); 9268 if (!pcp->import)
9269 data_queue_copied_image_lookup(&iparent->image.id, &ied->image.id, &ied->image.set);
9270 else
9271 data_queue_image_lookup(STRDUP(edje_file->image_dir->entries[iparent->image.id].entry),
9272 &ied->image.id, &ied->image.set);
9234 9273
9235 ied->image.tweens = calloc(iparent->image.tweens_count, 9274 ied->image.tweens = calloc(iparent->image.tweens_count,
9236 sizeof (Edje_Part_Image_Id *)); 9275 sizeof (Edje_Part_Image_Id *));
@@ -9243,6 +9282,11 @@ st_collections_group_parts_part_description_inherit(void)
9243 iid_new = mem_alloc(SZ(Edje_Part_Image_Id)); 9282 iid_new = mem_alloc(SZ(Edje_Part_Image_Id));
9244 data_queue_image_remove(&ied->image.id, &ied->image.set); 9283 data_queue_image_remove(&ied->image.id, &ied->image.set);
9245 data_queue_copied_image_lookup(&(iid->id), &(iid_new->id), &(iid_new->set)); 9284 data_queue_copied_image_lookup(&(iid->id), &(iid_new->id), &(iid_new->set));
9285 if (!pcp->import)
9286 data_queue_copied_image_lookup(&(iid->id), &(iid_new->id), &(iid_new->set));
9287 else
9288 data_queue_image_lookup(STRDUP(edje_file->image_dir->entries[iid->id].entry),
9289 &iid_new->id, &iid_new->set);
9246 ied->image.tweens[i] = iid_new; 9290 ied->image.tweens[i] = iid_new;
9247 } 9291 }
9248 9292
diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c
index 0baf221216..a06f9a32bb 100644
--- a/src/bin/edje/edje_cc_out.c
+++ b/src/bin/edje/edje_cc_out.c
@@ -215,6 +215,7 @@ static void data_process_string(Edje_Part_Collection *pc, const char *prefix, ch
215 215
216extern Eina_List *po_files; 216extern Eina_List *po_files;
217 217
218char *file_import;
218Edje_File *edje_file = NULL; 219Edje_File *edje_file = NULL;
219Edje_File *edje_file_import = NULL; 220Edje_File *edje_file_import = NULL;
220Eina_List *edje_collections = NULL; 221Eina_List *edje_collections = NULL;
@@ -242,6 +243,7 @@ static Eet_File *cur_ef;
242static int image_num; 243static int image_num;
243static Ecore_Evas *buffer_ee; 244static Ecore_Evas *buffer_ee;
244static int cur_image_entry; 245static int cur_image_entry;
246static Eina_List *images_unused_list = NULL;
245 247
246static void data_write_images(void); 248static void data_write_images(void);
247 249
@@ -1363,6 +1365,7 @@ data_write_images(void)
1363{ 1365{
1364 Evas *evas; 1366 Evas *evas;
1365 const char *ext = NULL; 1367 const char *ext = NULL;
1368 Image_Unused_Ids *iui;
1366 1369
1367 if (!((edje_file) && (edje_file->image_dir))) return; 1370 if (!((edje_file) && (edje_file->image_dir))) return;
1368 1371
@@ -1447,9 +1450,35 @@ data_write_images(void)
1447 } 1450 }
1448 else 1451 else
1449 { 1452 {
1450 free(iw); 1453 int load_err2 = EVAS_LOAD_ERROR_NONE;
1451 error_and_abort_image_load_error(cur_ef, img->entry, load_err); 1454 char buf[PATH_MAX];
1452 exit(1); // ensure static analysis tools know we exit 1455 Eina_List *l;
1456
1457 EINA_LIST_FOREACH(images_unused_list, l, iui)
1458 {
1459 if (iui->new_id == img->id)
1460 break;
1461 }
1462
1463 snprintf(buf, sizeof(buf), "edje/images/%i", (iui) ? iui->old_id : img->id);
1464 evas_object_image_file_set(im, file_import, buf);
1465 load_err2 = evas_object_image_load_error_get(im);
1466 if (load_err2 == EVAS_LOAD_ERROR_NONE)
1467 {
1468 image_num += 1;
1469 iw->path = strdup(buf);
1470 pending_threads++;
1471 if (threads)
1472 evas_object_image_preload(im, 0);
1473 if (!threads)
1474 data_image_preload_done(iw, evas, im, NULL);
1475 }
1476 else
1477 {
1478 free(iw);
1479 error_and_abort_image_load_error(cur_ef, img->entry, load_err);
1480 exit(1); // ensure static analysis tools know we exit
1481 }
1453 } 1482 }
1454 } 1483 }
1455 1484
@@ -1471,6 +1500,8 @@ data_write_images(void)
1471 if (pending_threads + pending_image_threads > (int)max_open_files - 2) break; 1500 if (pending_threads + pending_image_threads > (int)max_open_files - 2) break;
1472 } 1501 }
1473 } 1502 }
1503 EINA_LIST_FREE(images_unused_list, iui)
1504 free(iui);
1474} 1505}
1475 1506
1476static void 1507static void
@@ -4021,7 +4052,6 @@ free_group:
4021 Edje_Image_Directory_Entry *de, *de_last, *img; 4052 Edje_Image_Directory_Entry *de, *de_last, *img;
4022 Edje_Image_Directory_Set *set, *set_last, *set_realloc; 4053 Edje_Image_Directory_Set *set, *set_last, *set_realloc;
4023 Edje_Image_Directory_Set_Entry *set_e; 4054 Edje_Image_Directory_Set_Entry *set_e;
4024 Eina_List *images_unused_list = NULL;
4025 unsigned int i; 4055 unsigned int i;
4026 4056
4027 for (i = 0; i < edje_file->image_dir->entries_count; ++i) 4057 for (i = 0; i < edje_file->image_dir->entries_count; ++i)
@@ -4084,8 +4114,6 @@ free_group:
4084 4114
4085 /* update image id in parts */ 4115 /* update image id in parts */
4086 if (images_unused_list) _data_image_id_update(images_unused_list); 4116 if (images_unused_list) _data_image_id_update(images_unused_list);
4087 EINA_LIST_FREE(images_unused_list, iui)
4088 free(iui);
4089 4117
4090 _data_image_sets_size_set(); 4118 _data_image_sets_size_set();
4091 } 4119 }