forked from enlightenment/efl
edje: Rename Json to Lottie in edj supporting
Summary: The json file used by edje is for lottie output. json can be used in many ways. So the purpose is clear. Test Plan: N/A Reviewers: Hermet, kimcinoo, herb Reviewed By: Hermet Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D11478
This commit is contained in:
parent
794792aacb
commit
107e425ef6
|
@ -2629,7 +2629,7 @@ st_images_vector(void)
|
|||
entry_len = strlen(vector->entry);
|
||||
if ((entry_len > 5) && !strncmp(vector->entry + entry_len - 5, ".json", 5))
|
||||
{
|
||||
vector->type = EDJE_VECTOR_FILE_TYPE_JSON;
|
||||
vector->type = EDJE_VECTOR_FILE_TYPE_LOTTIE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1428,22 +1428,22 @@ data_write_vectors(Eet_File *ef, int *vector_num)
|
|||
if (!f) continue;
|
||||
eina_file_close(f);
|
||||
|
||||
if (vector->type == EDJE_VECTOR_FILE_TYPE_JSON)
|
||||
if (vector->type == EDJE_VECTOR_FILE_TYPE_LOTTIE)
|
||||
{
|
||||
char *json_data = NULL;
|
||||
int json_data_len = 0;
|
||||
char *lottie_data = NULL;
|
||||
int lottie_data_len = 0;
|
||||
|
||||
f = eina_file_open(eina_strbuf_string_get(buf), EINA_FALSE);
|
||||
if (!f) continue;
|
||||
|
||||
json_data_len = (int) eina_file_size_get(f);
|
||||
json_data = eina_file_map_all(f, EINA_FILE_POPULATE);
|
||||
lottie_data_len = (int) eina_file_size_get(f);
|
||||
lottie_data = eina_file_map_all(f, EINA_FILE_POPULATE);
|
||||
|
||||
eina_strbuf_reset(buf);
|
||||
eina_strbuf_append_printf(buf, "edje/vectors/%i", vector->id);
|
||||
eet_write(ef, eina_strbuf_string_get(buf), json_data, json_data_len, EET_COMPRESSION_NONE);
|
||||
eet_write(ef, eina_strbuf_string_get(buf), lottie_data, lottie_data_len, EET_COMPRESSION_NONE);
|
||||
|
||||
eina_file_map_free(f, json_data);
|
||||
eina_file_map_free(f, lottie_data);
|
||||
eina_file_close(f);
|
||||
|
||||
*vector_num += 1;
|
||||
|
|
|
@ -3319,13 +3319,13 @@ _edje_vector_animation_running_cb(void *data, const Efl_Event *event)
|
|||
}
|
||||
|
||||
static void
|
||||
_edje_vector_load_json(Edje *ed, Edje_Real_Part *ep, const char *key)
|
||||
_edje_vector_load_lottie(Edje *ed, Edje_Real_Part *ep, const char *key)
|
||||
{
|
||||
Edje_Part_Description_Vector *desc = (Edje_Part_Description_Vector *)ep->chosen_description;
|
||||
Eina_File *file;
|
||||
char *json_data;
|
||||
char *lottie_data;
|
||||
double frame_duration;
|
||||
int json_data_len = 0;
|
||||
int lottie_data_len = 0;
|
||||
int frame_count;
|
||||
|
||||
if (ep->typedata.vector->anim == NULL)
|
||||
|
@ -3339,18 +3339,18 @@ _edje_vector_load_json(Edje *ed, Edje_Real_Part *ep, const char *key)
|
|||
|
||||
if (ep->typedata.vector->current_id != desc->vg.id)
|
||||
{
|
||||
json_data = (char *)eet_read(ed->file->ef, key, &json_data_len);
|
||||
json_data[json_data_len] = '\0';
|
||||
file = eina_file_virtualize(NULL, json_data, json_data_len + 1, EINA_FALSE);
|
||||
lottie_data = (char *)eet_read(ed->file->ef, key, &lottie_data_len);
|
||||
lottie_data[lottie_data_len] = '\0';
|
||||
file = eina_file_virtualize(NULL, lottie_data, lottie_data_len + 1, EINA_FALSE);
|
||||
efl_file_simple_mmap_load(ep->object, file, NULL);
|
||||
|
||||
if (ep->typedata.vector->json_virtual_file)
|
||||
eina_file_close(ep->typedata.vector->json_virtual_file);
|
||||
ep->typedata.vector->json_virtual_file = file;
|
||||
if (ep->typedata.vector->lottie_virtual_file)
|
||||
eina_file_close(ep->typedata.vector->lottie_virtual_file);
|
||||
ep->typedata.vector->lottie_virtual_file = file;
|
||||
|
||||
if (ep->typedata.vector->json_data)
|
||||
free(ep->typedata.vector->json_data);
|
||||
ep->typedata.vector->json_data = json_data;
|
||||
if (ep->typedata.vector->lottie_data)
|
||||
free(ep->typedata.vector->lottie_data);
|
||||
ep->typedata.vector->lottie_data = lottie_data;
|
||||
|
||||
ep->typedata.vector->current_id = desc->vg.id;
|
||||
}
|
||||
|
@ -3381,12 +3381,12 @@ _edje_vector_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3 EIN
|
|||
|
||||
snprintf(src_key, sizeof(src_key), "edje/vectors/%i", chosen_desc->vg.id);
|
||||
|
||||
if (type == EDJE_VECTOR_FILE_TYPE_JSON)
|
||||
if (type == EDJE_VECTOR_FILE_TYPE_LOTTIE)
|
||||
{
|
||||
#ifdef BUILD_VG_LOADER_JSON
|
||||
_edje_vector_load_json(ed, ep, src_key);
|
||||
_edje_vector_load_lottie(ed, ep, src_key);
|
||||
#else
|
||||
ERR("Evas Vg Json (Lottie) Loader is not supported, Only Static Vector Image(SVG) is available!");
|
||||
ERR("Evas Vg Lottie (Lottie) Loader is not supported, Only Static Vector Image(SVG) is available!");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
@ -3405,11 +3405,11 @@ _edje_vector_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3 EIN
|
|||
}
|
||||
}
|
||||
|
||||
if ((new_id < 0) || (new_type == EDJE_VECTOR_FILE_TYPE_JSON))
|
||||
if ((new_id < 0) || (new_type == EDJE_VECTOR_FILE_TYPE_LOTTIE))
|
||||
{
|
||||
#ifndef BUILD_VG_LOADER_JSON
|
||||
if (new_type == EDJE_VECTOR_FILE_TYPE_JSON)
|
||||
ERR("Evas Vg Json (Lottie) Loader is not supported, Only Static Vector Image(SVG) is available!");
|
||||
if (new_type == EDJE_VECTOR_FILE_TYPE_LOTTIE)
|
||||
ERR("Evas Vg Lottie (Lottie) Loader is not supported, Only Static Vector Image(SVG) is available!");
|
||||
else
|
||||
#endif
|
||||
efl_file_simple_load(ep->object, ed->file->path, src_key);
|
||||
|
|
|
@ -2036,10 +2036,10 @@ _edje_file_del(Edje *ed)
|
|||
{
|
||||
if (rp->typedata.vector->anim)
|
||||
efl_del(rp->typedata.vector->anim);
|
||||
if (rp->typedata.vector->json_virtual_file)
|
||||
eina_file_close(rp->typedata.vector->json_virtual_file);
|
||||
if (rp->typedata.vector->json_data)
|
||||
free(rp->typedata.vector->json_data);
|
||||
if (rp->typedata.vector->lottie_virtual_file)
|
||||
eina_file_close(rp->typedata.vector->lottie_virtual_file);
|
||||
if (rp->typedata.vector->lottie_data)
|
||||
free(rp->typedata.vector->lottie_data);
|
||||
|
||||
free(rp->typedata.vector);
|
||||
rp->typedata.vector = NULL;
|
||||
|
|
|
@ -690,7 +690,7 @@ struct _Edje_Image_Directory
|
|||
typedef enum _Edje_Vector_File_Type
|
||||
{
|
||||
EDJE_VECTOR_FILE_TYPE_SVG = 0,
|
||||
EDJE_VECTOR_FILE_TYPE_JSON
|
||||
EDJE_VECTOR_FILE_TYPE_LOTTIE
|
||||
} Edje_Vector_File_Type;
|
||||
|
||||
struct _Edje_Vector_Directory_Entry
|
||||
|
@ -2050,8 +2050,8 @@ struct _Edje_Real_Part_Swallow
|
|||
struct _Edje_Real_Part_Vector
|
||||
{
|
||||
Eo *anim;
|
||||
Eina_File *json_virtual_file;
|
||||
char *json_data;
|
||||
Eina_File *lottie_virtual_file;
|
||||
char *lottie_data;
|
||||
int start_frame;
|
||||
int current_id;
|
||||
Eina_Bool backward : 1;
|
||||
|
|
Loading…
Reference in New Issue