diff options
author | Jeeyong Um <conr2d@gmail.com> | 2018-05-01 04:32:37 +0900 |
---|---|---|
committer | Jeeyong Um <conr2d@gmail.com> | 2018-05-01 04:46:47 +0900 |
commit | 90192a2a4fe92cc94545d4e209dd50930b9febb1 (patch) | |
tree | 00b40298cecf9bf359cecb3652188ddf40ea1920 | |
parent | 929bcec6b22eb6afc7e525de4d6b15b759de1fd0 (diff) | |
download | efl-devs/conr2d/import_edj.tar.gz |
edje_cc: Handle image resources when importing edjdevs/conr2d/import_edj
-rw-r--r-- | src/bin/edje/edje_cc.h | 1 | ||||
-rw-r--r-- | src/bin/edje/edje_cc_handlers.c | 46 | ||||
-rw-r--r-- | src/bin/edje/edje_cc_out.c | 40 |
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; extern Eina_List *data_dirs; extern char *file_in; extern char *file_out; +extern char *file_import; extern char *watchfile; extern char *depfile; extern 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) edje_file_import = _edje_file_open(f, &error_ret, eina_file_mtime_get(f), EINA_TRUE); + file_import = eina_strbuf_string_steal(path); eina_strbuf_free(path); free(name); + + if (edje_file_import->image_dir) + { + unsigned int i; + Edje_Image_Directory *eid, *eid2; + Edje_Image_Directory_Set_Entry *entry, *entry2; + Eina_List *l; + + eid2 = edje_file_import->image_dir; + eid = edje_file->image_dir = mem_alloc(SZ(Edje_Image_Directory)); + + eid->entries_count = eid2->entries_count; + eid->entries = mem_alloc(SZ(Edje_Image_Directory_Entry) * eid->entries_count); + + for (i = 0; i < eid->entries_count; i++) + { + eid->entries[i].entry = STRDUP(eid2->entries[i].entry); + eid->entries[i].source_type = eid2->entries[i].source_type; + eid->entries[i].source_param = eid2->entries[i].source_param; + eid->entries[i].id = eid2->entries[i].id; + } + + for (i = 0; i < eid->sets_count; i++) + { + eid->sets[i].name = STRDUP(eid2->sets[i].name); + eid->sets[i].id = eid2->sets[i].id; + + EINA_LIST_FOREACH(eid2->sets[i].entries, l, entry2) + { + entry = mem_alloc(SZ(Edje_Image_Directory_Set_Entry)); + memcpy(entry, entry2, sizeof(Edje_Image_Directory_Set_Entry)); + } + } + } } /** @edcsubsection{toplevel_externals, @@ -9230,7 +9265,11 @@ st_collections_group_parts_part_description_inherit(void) ied->image = iparent->image; data_queue_image_remove(&ied->image.id, &ied->image.set); - data_queue_copied_image_lookup(&iparent->image.id, &ied->image.id, &ied->image.set); + if (!pcp->import) + data_queue_copied_image_lookup(&iparent->image.id, &ied->image.id, &ied->image.set); + else + data_queue_image_lookup(STRDUP(edje_file->image_dir->entries[iparent->image.id].entry), + &ied->image.id, &ied->image.set); ied->image.tweens = calloc(iparent->image.tweens_count, sizeof (Edje_Part_Image_Id *)); @@ -9243,6 +9282,11 @@ st_collections_group_parts_part_description_inherit(void) iid_new = mem_alloc(SZ(Edje_Part_Image_Id)); data_queue_image_remove(&ied->image.id, &ied->image.set); data_queue_copied_image_lookup(&(iid->id), &(iid_new->id), &(iid_new->set)); + if (!pcp->import) + data_queue_copied_image_lookup(&(iid->id), &(iid_new->id), &(iid_new->set)); + else + data_queue_image_lookup(STRDUP(edje_file->image_dir->entries[iid->id].entry), + &iid_new->id, &iid_new->set); ied->image.tweens[i] = iid_new; } 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 extern Eina_List *po_files; +char *file_import; Edje_File *edje_file = NULL; Edje_File *edje_file_import = NULL; Eina_List *edje_collections = NULL; @@ -242,6 +243,7 @@ static Eet_File *cur_ef; static int image_num; static Ecore_Evas *buffer_ee; static int cur_image_entry; +static Eina_List *images_unused_list = NULL; static void data_write_images(void); @@ -1363,6 +1365,7 @@ data_write_images(void) { Evas *evas; const char *ext = NULL; + Image_Unused_Ids *iui; if (!((edje_file) && (edje_file->image_dir))) return; @@ -1447,9 +1450,35 @@ data_write_images(void) } else { - free(iw); - error_and_abort_image_load_error(cur_ef, img->entry, load_err); - exit(1); // ensure static analysis tools know we exit + int load_err2 = EVAS_LOAD_ERROR_NONE; + char buf[PATH_MAX]; + Eina_List *l; + + EINA_LIST_FOREACH(images_unused_list, l, iui) + { + if (iui->new_id == img->id) + break; + } + + snprintf(buf, sizeof(buf), "edje/images/%i", (iui) ? iui->old_id : img->id); + evas_object_image_file_set(im, file_import, buf); + load_err2 = evas_object_image_load_error_get(im); + if (load_err2 == EVAS_LOAD_ERROR_NONE) + { + image_num += 1; + iw->path = strdup(buf); + pending_threads++; + if (threads) + evas_object_image_preload(im, 0); + if (!threads) + data_image_preload_done(iw, evas, im, NULL); + } + else + { + free(iw); + error_and_abort_image_load_error(cur_ef, img->entry, load_err); + exit(1); // ensure static analysis tools know we exit + } } } @@ -1471,6 +1500,8 @@ data_write_images(void) if (pending_threads + pending_image_threads > (int)max_open_files - 2) break; } } + EINA_LIST_FREE(images_unused_list, iui) + free(iui); } static void @@ -4021,7 +4052,6 @@ free_group: Edje_Image_Directory_Entry *de, *de_last, *img; Edje_Image_Directory_Set *set, *set_last, *set_realloc; Edje_Image_Directory_Set_Entry *set_e; - Eina_List *images_unused_list = NULL; unsigned int i; for (i = 0; i < edje_file->image_dir->entries_count; ++i) @@ -4084,8 +4114,6 @@ free_group: /* update image id in parts */ if (images_unused_list) _data_image_id_update(images_unused_list); - EINA_LIST_FREE(images_unused_list, iui) - free(iui); _data_image_sets_size_set(); } |