summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoungBok Shin <id213sin@gmail.com>2020-02-17 18:59:09 +0900
committerHermet Park <hermetpark@gmail.com>2020-02-17 18:59:09 +0900
commit2fe158ce652860b2aa5a2e883e6b2beb0ee1c670 (patch)
treea1de907a23578f956f7f0c695ea53e3e77b5b3c1
parentba8c349eedd35608f94996aada44ab8d1c404d4a (diff)
edje: add json file support feature
Summary: It also starts to support following new edc properties. This is backported patch from Tizen 5.0 1. frame desc { "default" vector { frame: 0.5; // 0.0 ~ 1.0 } } 2. actions program { "vector_animation"; // VG_ANIM_PLAY, VG_ANIM_PLAY_BACK, VG_ANIM_LOOP, // VG_ANIM_STOP, VG_ANIM_PAUSE, VG_ANIM_RESUME action: VG_ANIM_PLAY; target: "your_vector_part"; } @feature Co-authored-by: Jaehyun Cho <jae_hyun.cho@samsung.com> - Fix to remove Efl.Canvas.Animation_Player on edje Test Plan: {F3840540} {F3840542} {F3840543} make and test attached file edje_cc -beta -id ./ json_edc.edc json.edj gcc -o test test_edc.c -g `pkg-config --cflags --libs evas elementary rlottie` ./test Reviewers: Hermet, Jaehyun_Cho, id213sin Reviewed By: Hermet Subscribers: segfaultxavi, raster, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D11228
-rw-r--r--src/bin/edje/edje_cc_handlers.c56
-rw-r--r--src/bin/edje/edje_cc_out.c51
-rw-r--r--src/lib/edje/Edje_Common.h8
-rw-r--r--src/lib/edje/edje_calc.c150
-rw-r--r--src/lib/edje/edje_data.c3
-rw-r--r--src/lib/edje/edje_load.c20
-rw-r--r--src/lib/edje/edje_private.h32
-rw-r--r--src/lib/edje/edje_program.c72
8 files changed, 371 insertions, 21 deletions
diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c
index 6b7ec172e7..59a0f377a8 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -516,6 +516,9 @@ static void st_collections_group_parts_part_description_params_bool(void);
516static void st_collections_group_parts_part_description_params_choice(void); 516static void st_collections_group_parts_part_description_params_choice(void);
517static void st_collections_group_parts_part_description_params_smart(void); 517static void st_collections_group_parts_part_description_params_smart(void);
518 518
519/* vector part parameter */
520static void st_collections_group_parts_part_description_vector_frame(void);
521
519static void ob_collections_group_programs_program(void); 522static void ob_collections_group_programs_program(void);
520static void st_collections_group_programs_program_name(void); 523static void st_collections_group_programs_program_name(void);
521static void st_collections_group_programs_program_signal(void); 524static void st_collections_group_programs_program_signal(void);
@@ -1047,6 +1050,7 @@ New_Statement_Handler statement_handlers[] =
1047 {"collections.group.parts.part.description.params.bool", st_collections_group_parts_part_description_params_bool}, 1050 {"collections.group.parts.part.description.params.bool", st_collections_group_parts_part_description_params_bool},
1048 {"collections.group.parts.part.description.params.choice", st_collections_group_parts_part_description_params_choice}, 1051 {"collections.group.parts.part.description.params.choice", st_collections_group_parts_part_description_params_choice},
1049 {"collections.group.parts.part.description.params.*", st_collections_group_parts_part_description_params_smart}, 1052 {"collections.group.parts.part.description.params.*", st_collections_group_parts_part_description_params_smart},
1053 {"collections.group.parts.part.description.vector.frame", st_collections_group_parts_part_description_vector_frame},
1050 IMAGE_STATEMENTS("collections.group.parts.part.description.") 1054 IMAGE_STATEMENTS("collections.group.parts.part.description.")
1051 { 1055 {
1052 "collections.group.parts.part.description.font", st_fonts_font 1056 "collections.group.parts.part.description.font", st_fonts_font
@@ -1590,6 +1594,7 @@ New_Object_Handler object_handlers[] =
1590 {"collections.group.parts.part.description.map.zoom", NULL}, 1594 {"collections.group.parts.part.description.map.zoom", NULL},
1591 {"collections.group.parts.part.description.perspective", NULL}, 1595 {"collections.group.parts.part.description.perspective", NULL},
1592 {"collections.group.parts.part.description.params", NULL}, 1596 {"collections.group.parts.part.description.params", NULL},
1597 {"collections.group.parts.part.description.vector", NULL},
1593 {"collections.group.parts.part.description.color_classes", NULL}, /* dup */ 1598 {"collections.group.parts.part.description.color_classes", NULL}, /* dup */
1594 {"collections.group.parts.part.description.color_classes.color_class", ob_color_class}, /* dup */ 1599 {"collections.group.parts.part.description.color_classes.color_class", ob_color_class}, /* dup */
1595 {"collections.group.parts.part.description.text_classes", NULL}, /* dup */ 1600 {"collections.group.parts.part.description.text_classes", NULL}, /* dup */
@@ -2545,6 +2550,7 @@ _handle_vector_image(void)
2545 { 2550 {
2546 ed->vg.set = EINA_TRUE; 2551 ed->vg.set = EINA_TRUE;
2547 ed->vg.id = edje_file->image_dir->vectors[i].id; 2552 ed->vg.id = edje_file->image_dir->vectors[i].id;
2553 ed->vg.type = edje_file->image_dir->vectors[i].type;
2548 break; 2554 break;
2549 } 2555 }
2550 } 2556 }
@@ -2587,6 +2593,7 @@ st_images_vector(void)
2587 Edje_Vector_Directory_Entry *vector; 2593 Edje_Vector_Directory_Entry *vector;
2588 const char *tmp; 2594 const char *tmp;
2589 unsigned int i; 2595 unsigned int i;
2596 size_t entry_len;
2590 2597
2591 check_min_arg_count(1); 2598 check_min_arg_count(1);
2592 2599
@@ -2618,6 +2625,16 @@ st_images_vector(void)
2618 2625
2619 vector->entry = tmp; 2626 vector->entry = tmp;
2620 vector->id = edje_file->image_dir->vectors_count - 1; 2627 vector->id = edje_file->image_dir->vectors_count - 1;
2628
2629 entry_len = strlen(vector->entry);
2630 if ((entry_len > 5) && !strncmp(vector->entry + entry_len - 5, ".json", 5))
2631 {
2632 vector->type = EDJE_VECTOR_FILE_TYPE_JSON;
2633 }
2634 else
2635 {
2636 vector->type = EDJE_VECTOR_FILE_TYPE_SVG;
2637 }
2621} 2638}
2622 2639
2623/** 2640/**
@@ -8960,6 +8977,8 @@ st_collections_group_parts_part_description_inherit(void)
8960 Edje_Part_Description_Vector *iparent = (Edje_Part_Description_Vector *)parent; 8977 Edje_Part_Description_Vector *iparent = (Edje_Part_Description_Vector *)parent;
8961 ied->vg.set = iparent->vg.set; 8978 ied->vg.set = iparent->vg.set;
8962 ied->vg.id = iparent->vg.id; 8979 ied->vg.id = iparent->vg.id;
8980 ied->vg.type = iparent->vg.type;
8981 ied->vg.frame = iparent->vg.frame;
8963 break; 8982 break;
8964 } 8983 }
8965 } 8984 }
@@ -15235,6 +15254,25 @@ st_collections_group_parts_part_description_params_choice(void)
15235 _st_collections_group_parts_part_description_params(EDJE_EXTERNAL_PARAM_TYPE_CHOICE); 15254 _st_collections_group_parts_part_description_params(EDJE_EXTERNAL_PARAM_TYPE_CHOICE);
15236} 15255}
15237 15256
15257static void
15258st_collections_group_parts_part_description_vector_frame(void)
15259{
15260 Edje_Part_Description_Vector *ed;
15261
15262 check_arg_count(1);
15263
15264 if (current_part->type != EDJE_PART_TYPE_VECTOR)
15265 {
15266 ERR("parse error %s:%i. vector attributes in non-VECTOR part.",
15267 file_in, line - 1);
15268 exit(-1);
15269 }
15270
15271 ed = (Edje_Part_Description_Vector *)current_desc;
15272
15273 ed->vg.frame = parse_float_range(0, 0.0, 1.0);
15274}
15275
15238/** @edcsubsection{collections_group_parts_description_links, 15276/** @edcsubsection{collections_group_parts_description_links,
15239 * Group.Parts.Part.Description.Links} */ 15277 * Group.Parts.Part.Description.Links} */
15240 15278
@@ -15747,6 +15785,12 @@ st_collections_group_programs_program_action(void)
15747 "PHYSICS_STOP", EDJE_ACTION_TYPE_PHYSICS_STOP, 15785 "PHYSICS_STOP", EDJE_ACTION_TYPE_PHYSICS_STOP,
15748 "PHYSICS_ROT_SET", EDJE_ACTION_TYPE_PHYSICS_ROT_SET, 15786 "PHYSICS_ROT_SET", EDJE_ACTION_TYPE_PHYSICS_ROT_SET,
15749 "PLAY_VIBRATION", EDJE_ACTION_TYPE_VIBRATION_SAMPLE, 15787 "PLAY_VIBRATION", EDJE_ACTION_TYPE_VIBRATION_SAMPLE,
15788 "VG_ANIM_STOP", EDJE_ACTION_TYPE_VG_ANIM_STOP,
15789 "VG_ANIM_PAUSE", EDJE_ACTION_TYPE_VG_ANIM_PAUSE,
15790 "VG_ANIM_RESUME", EDJE_ACTION_TYPE_VG_ANIM_RESUME,
15791 "VG_ANIM_PLAY", EDJE_ACTION_TYPE_VG_ANIM_PLAY,
15792 "VG_ANIM_PLAY_BACK", EDJE_ACTION_TYPE_VG_ANIM_REWIND,
15793 "VG_ANIM_LOOP", EDJE_ACTION_TYPE_VG_ANIM_LOOP,
15750 NULL); 15794 NULL);
15751 if (ep->action == EDJE_ACTION_TYPE_STATE_SET) 15795 if (ep->action == EDJE_ACTION_TYPE_STATE_SET)
15752 { 15796 {
@@ -15908,6 +15952,12 @@ st_collections_group_programs_program_action(void)
15908 case EDJE_ACTION_TYPE_ACTION_STOP: 15952 case EDJE_ACTION_TYPE_ACTION_STOP:
15909 case EDJE_ACTION_TYPE_PHYSICS_FORCES_CLEAR: 15953 case EDJE_ACTION_TYPE_PHYSICS_FORCES_CLEAR:
15910 case EDJE_ACTION_TYPE_PHYSICS_STOP: 15954 case EDJE_ACTION_TYPE_PHYSICS_STOP:
15955 case EDJE_ACTION_TYPE_VG_ANIM_STOP:
15956 case EDJE_ACTION_TYPE_VG_ANIM_PAUSE:
15957 case EDJE_ACTION_TYPE_VG_ANIM_RESUME:
15958 case EDJE_ACTION_TYPE_VG_ANIM_PLAY:
15959 case EDJE_ACTION_TYPE_VG_ANIM_REWIND:
15960 case EDJE_ACTION_TYPE_VG_ANIM_LOOP:
15911 check_arg_count(1); 15961 check_arg_count(1);
15912 break; 15962 break;
15913 15963
@@ -16187,6 +16237,12 @@ _program_target_add(char *name)
16187 case EDJE_ACTION_TYPE_PHYSICS_STOP: 16237 case EDJE_ACTION_TYPE_PHYSICS_STOP:
16188 case EDJE_ACTION_TYPE_PHYSICS_ROT_SET: 16238 case EDJE_ACTION_TYPE_PHYSICS_ROT_SET:
16189#endif 16239#endif
16240 case EDJE_ACTION_TYPE_VG_ANIM_STOP:
16241 case EDJE_ACTION_TYPE_VG_ANIM_PAUSE:
16242 case EDJE_ACTION_TYPE_VG_ANIM_RESUME:
16243 case EDJE_ACTION_TYPE_VG_ANIM_PLAY:
16244 case EDJE_ACTION_TYPE_VG_ANIM_REWIND:
16245 case EDJE_ACTION_TYPE_VG_ANIM_LOOP:
16190 data_queue_part_lookup(pc, name, &(et->id)); 16246 data_queue_part_lookup(pc, name, &(et->id));
16191 break; 16247 break;
16192 16248
diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c
index f932eac9e9..4c192efe6e 100644
--- a/src/bin/edje/edje_cc_out.c
+++ b/src/bin/edje/edje_cc_out.c
@@ -1428,19 +1428,48 @@ data_write_vectors(Eet_File *ef, int *vector_num)
1428 if (!f) continue; 1428 if (!f) continue;
1429 eina_file_close(f); 1429 eina_file_close(f);
1430 1430
1431 if (efl_file_set(vg, eina_strbuf_string_get(buf))) 1431 if (vector->type == EDJE_VECTOR_FILE_TYPE_JSON)
1432 error_and_abort(ef, "Failed to parse svg : %s", vector->entry); 1432 {
1433 if (efl_file_load(vg)) 1433 char *json_data = NULL;
1434 error_and_abort(ef, "Failed to parse svg : %s", vector->entry); 1434 int json_data_len = 0;
1435 1435
1436 eina_strbuf_reset(buf); 1436 f = eina_file_open(eina_strbuf_string_get(buf), EINA_FALSE);
1437 eina_strbuf_append_printf(buf, "edje/vectors/%i", vector->id); 1437 if (!f) continue;
1438 if (!efl_file_save(vg, eet_file_get(ef), eina_strbuf_string_get(buf), NULL))
1439 error_and_abort(ef, "Failed to write data in Eet for svg :%s", vector->entry);
1440 1438
1441 *vector_num += 1; 1439 json_data_len = (int) eina_file_size_get(f);
1442 found = EINA_TRUE; 1440 json_data = eina_file_map_all(f, EINA_FILE_POPULATE);
1443 break; 1441
1442 eina_strbuf_reset(buf);
1443 eina_strbuf_append_printf(buf, "edje/vectors/%i", vector->id);
1444 eet_write(ef, eina_strbuf_string_get(buf), json_data, json_data_len, EET_COMPRESSION_NONE);
1445
1446 eina_file_map_free(f, json_data);
1447 eina_file_close(f);
1448
1449 *vector_num += 1;
1450 found = EINA_TRUE;
1451 break;
1452 }
1453 else
1454 {
1455 f = eina_file_open(eina_strbuf_string_get(buf), EINA_FALSE);
1456 if (!f) continue;
1457 eina_file_close(f);
1458
1459 if (efl_file_set(vg, eina_strbuf_string_get(buf)))
1460 error_and_abort(ef, "Failed to parse svg : %s", vector->entry);
1461 if (efl_file_load(vg))
1462 error_and_abort(ef, "Failed to parse svg : %s", vector->entry);
1463
1464 eina_strbuf_reset(buf);
1465 eina_strbuf_append_printf(buf, "edje/vectors/%i", vector->id);
1466 if (!efl_file_save(vg, eet_file_get(ef), eina_strbuf_string_get(buf), NULL))
1467 error_and_abort(ef, "Failed to write data in Eet for svg :%s", vector->entry);
1468
1469 *vector_num += 1;
1470 found = EINA_TRUE;
1471 break;
1472 }
1444 } 1473 }
1445 if (!found) 1474 if (!found)
1446 error_and_abort(ef, "Unable to find the svg :%s", vector->entry); 1475 error_and_abort(ef, "Unable to find the svg :%s", vector->entry);
diff --git a/src/lib/edje/Edje_Common.h b/src/lib/edje/Edje_Common.h
index 22aa8e667a..be752343ab 100644
--- a/src/lib/edje/Edje_Common.h
+++ b/src/lib/edje/Edje_Common.h
@@ -1952,7 +1952,13 @@ typedef enum _Edje_Action_Type
1952 EDJE_ACTION_TYPE_PHYSICS_ROT_SET = 23, /**< @since 1.8 @brief Physics rotation set action value */ 1952 EDJE_ACTION_TYPE_PHYSICS_ROT_SET = 23, /**< @since 1.8 @brief Physics rotation set action value */
1953 EDJE_ACTION_TYPE_VIBRATION_SAMPLE = 24, /**< @since 1.10 @brief vibration sample action value */ 1953 EDJE_ACTION_TYPE_VIBRATION_SAMPLE = 24, /**< @since 1.10 @brief vibration sample action value */
1954 EDJE_ACTION_TYPE_MO = 25, /**< @since 1.15 @brief Mo action value */ 1954 EDJE_ACTION_TYPE_MO = 25, /**< @since 1.15 @brief Mo action value */
1955 EDJE_ACTION_TYPE_LAST = 26 /**< Last action value */ 1955 EDJE_ACTION_TYPE_VG_ANIM_STOP,
1956 EDJE_ACTION_TYPE_VG_ANIM_PAUSE,
1957 EDJE_ACTION_TYPE_VG_ANIM_RESUME,
1958 EDJE_ACTION_TYPE_VG_ANIM_PLAY,
1959 EDJE_ACTION_TYPE_VG_ANIM_REWIND,
1960 EDJE_ACTION_TYPE_VG_ANIM_LOOP,
1961 EDJE_ACTION_TYPE_LAST = 32 /**< Last action value */
1956} Edje_Action_Type; 1962} Edje_Action_Type;
1957 1963
1958/** 1964/**
diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c
index 4c11f6ab4e..eba505b721 100644
--- a/src/lib/edje/edje_calc.c
+++ b/src/lib/edje/edje_calc.c
@@ -3280,34 +3280,133 @@ _edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edj
3280} 3280}
3281 3281
3282static void 3282static void
3283_edje_svg_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3 EINA_UNUSED, Edje_Part_Description_Vector *chosen_desc, FLOAT_T pos) 3283_edje_vector_animation_running_cb(void *data, const Efl_Event *event)
3284{ 3284{
3285 int new_svg = -1; //invalid svg 3285 double pos = *((double*)event->info);
3286 Edje_Real_Part *ep = (Edje_Real_Part *)data;
3287 int frame, frame_count;
3288
3289 frame_count = efl_gfx_frame_controller_frame_count_get(ep->object) - 1;
3290 if (frame_count < 0) frame_count = 0;
3291
3292 if (ep->typedata.vector->backward)
3293 frame = ep->typedata.vector->start_frame - (int) (frame_count * pos);
3294 else
3295 frame = ep->typedata.vector->start_frame + (int) (frame_count * pos);
3296
3297 efl_gfx_frame_controller_frame_set(ep->object, frame);
3298
3299 if ((ep->typedata.vector->backward && (frame <= 0)) ||
3300 (!ep->typedata.vector->backward && (frame >= frame_count)))
3301 {
3302 if (ep->typedata.vector->loop)
3303 {
3304 if (ep->typedata.vector->backward)
3305 ep->typedata.vector->start_frame = frame_count;
3306 else
3307 ep->typedata.vector->start_frame = 0;
3308
3309 efl_canvas_object_animation_start(ep->object,
3310 ep->typedata.vector->anim,
3311 1.0, 0.0);
3312 }
3313 else
3314 {
3315 efl_canvas_object_animation_stop(ep->object);
3316 }
3317 }
3318}
3319
3320static void
3321_edje_vector_load_json(Edje *ed, Edje_Real_Part *ep, const char *key)
3322{
3323 Edje_Part_Description_Vector *desc = (Edje_Part_Description_Vector *)ep->chosen_description;
3324 Eina_File *file;
3325 char *json_data;
3326 double frame_duration;
3327 int json_data_len = 0;
3328 int frame_count;
3329
3330 if (ep->typedata.vector->anim == NULL)
3331 {
3332 Eo *anim = efl_add(EFL_CANVAS_ANIMATION_CLASS, ed->base.evas);
3333 ep->typedata.vector->anim = anim;
3334 efl_event_callback_add(ep->object,
3335 EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED,
3336 _edje_vector_animation_running_cb, ep);
3337 }
3338
3339 if (ep->typedata.vector->current_id != desc->vg.id)
3340 {
3341 json_data = (char *)eet_read(ed->file->ef, key, &json_data_len);
3342 json_data[json_data_len] = '\0';
3343 file = eina_file_virtualize(NULL, json_data, json_data_len + 1, EINA_FALSE);
3344 efl_file_simple_mmap_load(ep->object, file, NULL);
3345
3346 if (ep->typedata.vector->json_virtual_file)
3347 eina_file_close(ep->typedata.vector->json_virtual_file);
3348 ep->typedata.vector->json_virtual_file = file;
3349
3350 if (ep->typedata.vector->json_data)
3351 free(ep->typedata.vector->json_data);
3352 ep->typedata.vector->json_data = json_data;
3353
3354 ep->typedata.vector->current_id = desc->vg.id;
3355 }
3356
3357 frame_duration = efl_gfx_frame_controller_frame_duration_get(ep->object, 0, 0);
3358 efl_animation_duration_set(ep->typedata.vector->anim, frame_duration);
3359
3360 if (!ep->typedata.vector->is_playing)
3361 {
3362 frame_count = efl_gfx_frame_controller_frame_count_get(ep->object);
3363 efl_gfx_frame_controller_frame_set(ep->object, (int)(frame_count * desc->vg.frame));
3364 }
3365}
3366
3367static void
3368_edje_vector_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3 EINA_UNUSED, Edje_Part_Description_Vector *chosen_desc, FLOAT_T pos)
3369{
3370 int new_id = -1; //invalid svg
3286 int w, h; 3371 int w, h;
3287 char src_key[32], dest_key[32]; 3372 char src_key[32], dest_key[32];
3288 Efl_VG *src_root, *dest_root, *root; 3373 Efl_VG *src_root, *dest_root, *root;
3374 Edje_Vector_File_Type type = chosen_desc->vg.type;
3375 Edje_Vector_File_Type new_type = EDJE_VECTOR_FILE_TYPE_SVG;
3289 3376
3290 evas_object_geometry_get(ep->object, NULL, NULL, &w, &h); 3377 evas_object_geometry_get(ep->object, NULL, NULL, &w, &h);
3291 if( (w == 0) || (h == 0)) return; 3378 if( (w == 0) || (h == 0)) return;
3292 3379
3293 snprintf(src_key, sizeof(src_key), "edje/vectors/%i", chosen_desc->vg.id); 3380 snprintf(src_key, sizeof(src_key), "edje/vectors/%i", chosen_desc->vg.id);
3294 3381
3382 if (type == EDJE_VECTOR_FILE_TYPE_JSON)
3383 {
3384 _edje_vector_load_json(ed, ep, src_key);
3385
3386 return;
3387 }
3388
3295 if (ep->param2) 3389 if (ep->param2)
3296 { 3390 {
3297 Edje_Part_Description_Vector *next_state = (Edje_Part_Description_Vector *)ep->param2->description; 3391 Edje_Part_Description_Vector *next_state = (Edje_Part_Description_Vector *)ep->param2->description;
3298 if (chosen_desc->vg.id != next_state->vg.id) 3392 if (chosen_desc->vg.id != next_state->vg.id)
3299 new_svg = next_state->vg.id; 3393 {
3394 new_id = next_state->vg.id;
3395 new_type = next_state->vg.type;
3396 }
3300 else 3397 else
3301 pos = 0; 3398 {
3399 pos = 0;
3400 }
3302 } 3401 }
3303 3402
3304 if (new_svg < 0) 3403 if ((new_id < 0) || (new_type == EDJE_VECTOR_FILE_TYPE_JSON))
3305 { 3404 {
3306 efl_file_simple_load(ep->object, ed->file->path, src_key); 3405 efl_file_simple_load(ep->object, ed->file->path, src_key);
3307 } 3406 }
3308 else 3407 else
3309 { 3408 {
3310 snprintf(dest_key, sizeof(dest_key), "edje/vectors/%i", new_svg); 3409 snprintf(dest_key, sizeof(dest_key), "edje/vectors/%i", new_id);
3311 3410
3312 efl_file_simple_load(ep->object, ed->file->path, src_key); 3411 efl_file_simple_load(ep->object, ed->file->path, src_key);
3313 src_root = efl_canvas_vg_object_root_node_get(ep->object); 3412 src_root = efl_canvas_vg_object_root_node_get(ep->object);
@@ -3329,6 +3428,43 @@ _edje_svg_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3 EINA_U
3329 } 3428 }
3330} 3429}
3331 3430
3431void
3432_edje_part_vector_anim_stop(Edje *ed EINA_UNUSED, Edje_Real_Part *rp)
3433{
3434 Edje_Part_Description_Vector *desc = (Edje_Part_Description_Vector *)rp->chosen_description;
3435 double frame_count = efl_gfx_frame_controller_frame_count_get(rp->object);
3436
3437 efl_canvas_object_animation_stop(rp->object);
3438 efl_gfx_frame_controller_frame_set(rp->object, (int)(frame_count * desc->vg.frame));
3439 rp->typedata.vector->is_playing = EINA_FALSE;
3440}
3441
3442void
3443_edje_part_vector_anim_pause(Edje *ed EINA_UNUSED, Edje_Real_Part *rp)
3444{
3445 efl_canvas_object_animation_pause_set(rp->object, EINA_TRUE);
3446}
3447
3448void
3449_edje_part_vector_anim_resume(Edje *ed EINA_UNUSED, Edje_Real_Part *rp)
3450{
3451 if (rp->typedata.vector->is_playing)
3452 {
3453 rp->typedata.vector->start_frame = efl_gfx_frame_controller_frame_get(rp->object);
3454 efl_canvas_object_animation_pause_set(rp->object, EINA_FALSE);
3455 }
3456}
3457
3458void
3459_edje_part_vector_anim_play(Edje *ed EINA_UNUSED, Edje_Real_Part *rp, Eina_Bool backward, Eina_Bool loop)
3460{
3461 rp->typedata.vector->backward = backward;
3462 rp->typedata.vector->loop = loop;
3463 rp->typedata.vector->start_frame = efl_gfx_frame_controller_frame_get(rp->object);
3464 rp->typedata.vector->is_playing = EINA_TRUE;
3465 efl_canvas_object_animation_start(rp->object, rp->typedata.vector->anim, 1.0, 0.0);
3466}
3467
3332static Edje_Real_Part * 3468static Edje_Real_Part *
3333_edje_real_part_state_get(Edje *ed, Edje_Real_Part *ep, int flags, int id, int *state) 3469_edje_real_part_state_get(Edje *ed, Edje_Real_Part *ep, int flags, int id, int *state)
3334{ 3470{
@@ -5089,7 +5225,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
5089 break; 5225 break;
5090 5226
5091 case EDJE_PART_TYPE_VECTOR: 5227 case EDJE_PART_TYPE_VECTOR:
5092 _edje_svg_recalc_apply(ed, ep, pf, (Edje_Part_Description_Vector *)chosen_desc, pos); 5228 _edje_vector_recalc_apply(ed, ep, pf, (Edje_Part_Description_Vector *)chosen_desc, pos);
5093 break; 5229 break;
5094 5230
5095 case EDJE_PART_TYPE_TEXTBLOCK: 5231 case EDJE_PART_TYPE_TEXTBLOCK:
diff --git a/src/lib/edje/edje_data.c b/src/lib/edje/edje_data.c
index daa4a01ac7..41f73ab410 100644
--- a/src/lib/edje/edje_data.c
+++ b/src/lib/edje/edje_data.c
@@ -424,6 +424,7 @@ _edje_edd_init(void)
424 eet_data_descriptor_file_new(&eddc); 424 eet_data_descriptor_file_new(&eddc);
425 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_vector_directory_entry, Edje_Vector_Directory_Entry, "entry", entry, EET_T_STRING); 425 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_vector_directory_entry, Edje_Vector_Directory_Entry, "entry", entry, EET_T_STRING);
426 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_vector_directory_entry, Edje_Vector_Directory_Entry, "id", id, EET_T_INT); 426 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_vector_directory_entry, Edje_Vector_Directory_Entry, "id", id, EET_T_INT);
427 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_vector_directory_entry, Edje_Vector_Directory_Entry, "type", type, EET_T_INT);
427 428
428 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory); 429 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory);
429 _edje_edd_edje_image_directory = 430 _edje_edd_edje_image_directory =
@@ -971,6 +972,8 @@ _edje_edd_init(void)
971 EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(_edje_edd_edje_part_description_vector, Edje_Part_Description_Vector, common); 972 EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(_edje_edd_edje_part_description_vector, Edje_Part_Description_Vector, common);
972 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_vector, Edje_Part_Description_Vector, "vg.id", vg.id, EET_T_INT); 973 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_vector, Edje_Part_Description_Vector, "vg.id", vg.id, EET_T_INT);
973 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_vector, Edje_Part_Description_Vector, "vg.set", vg.set, EET_T_UCHAR); 974 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_vector, Edje_Part_Description_Vector, "vg.set", vg.set, EET_T_UCHAR);
975 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_vector, Edje_Part_Description_Vector, "vg.type", vg.type, EET_T_INT);
976 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_vector, Edje_Part_Description_Vector, "vg.frame", vg.frame, EET_T_DOUBLE);
974 977
975 978
976 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Common); 979 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Common);
diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c
index ec51e2a37a..a3c2e3ca15 100644
--- a/src/lib/edje/edje_load.c
+++ b/src/lib/edje/edje_load.c
@@ -951,6 +951,13 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
951 if (!rp->typedata.container) memerr = EINA_TRUE; 951 if (!rp->typedata.container) memerr = EINA_TRUE;
952 break; 952 break;
953 953
954 case EDJE_PART_TYPE_VECTOR:
955 rp->type = EDJE_RP_TYPE_VECTOR;
956 rp->typedata.vector = calloc(1, sizeof(Edje_Real_Part_Vector));
957 if (!rp->typedata.vector) memerr = EINA_TRUE;
958 rp->typedata.vector->current_id = -1;
959 break;
960
954 default: 961 default:
955 break; 962 break;
956 } 963 }
@@ -2022,6 +2029,19 @@ _edje_file_del(Edje *ed)
2022 free(rp->typedata.swallow); 2029 free(rp->typedata.swallow);
2023 rp->typedata.swallow = NULL; 2030 rp->typedata.swallow = NULL;
2024 } 2031 }
2032 else if ((rp->type == EDJE_RP_TYPE_VECTOR) &&
2033 (rp->typedata.vector))
2034 {
2035 if (rp->typedata.vector->anim)
2036 efl_del(rp->typedata.vector->anim);
2037 if (rp->typedata.vector->json_virtual_file)
2038 eina_file_close(rp->typedata.vector->json_virtual_file);
2039 if (rp->typedata.vector->json_data)
2040 free(rp->typedata.vector->json_data);
2041
2042 free(rp->typedata.vector);
2043 rp->typedata.vector = NULL;
2044 }
2025 2045
2026 /* Cleanup optional part. */ 2046 /* Cleanup optional part. */
2027 free(rp->drag); 2047 free(rp->drag);
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 9abbb50962..c3f3ebbda6 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -393,6 +393,7 @@ typedef struct _Edje_Real_Part_Container Edje_Real_Part_Container;
393typedef struct _Edje_Real_Part_State Edje_Real_Part_State; 393typedef struct _Edje_Real_Part_State Edje_Real_Part_State;
394typedef struct _Edje_Real_Part_Drag Edje_Real_Part_Drag; 394typedef struct _Edje_Real_Part_Drag Edje_Real_Part_Drag;
395typedef struct _Edje_Real_Part_Set Edje_Real_Part_Set; 395typedef struct _Edje_Real_Part_Set Edje_Real_Part_Set;
396typedef struct _Edje_Real_Part_Vector Edje_Real_Part_Vector;
396typedef struct _Edje_Real_Part Edje_Real_Part; 397typedef struct _Edje_Real_Part Edje_Real_Part;
397typedef struct _Edje_Running_Program Edje_Running_Program; 398typedef struct _Edje_Running_Program Edje_Running_Program;
398typedef struct _Edje_Signal_Callback Edje_Signal_Callback; 399typedef struct _Edje_Signal_Callback Edje_Signal_Callback;
@@ -686,10 +687,17 @@ struct _Edje_Image_Directory
686 unsigned int vectors_count; 687 unsigned int vectors_count;
687}; 688};
688 689
690typedef enum _Edje_Vector_File_Type
691{
692 EDJE_VECTOR_FILE_TYPE_SVG = 0,
693 EDJE_VECTOR_FILE_TYPE_JSON
694} Edje_Vector_File_Type;
695
689struct _Edje_Vector_Directory_Entry 696struct _Edje_Vector_Directory_Entry
690{ 697{
691 const char *entry; /* the nominal name of the vector image - if any */ 698 const char *entry; /* the nominal name of the vector image - if any */
692 int id; /* the id no. of the image */ 699 int id; /* the id no. of the image */
700 Edje_Vector_File_Type type;
693}; 701};
694 702
695struct _Edje_Image_Directory_Entry 703struct _Edje_Image_Directory_Entry
@@ -1600,8 +1608,10 @@ struct _Edje_Part_Description_Spec_Camera
1600 1608
1601struct _Edje_Part_Description_Spec_Svg 1609struct _Edje_Part_Description_Spec_Svg
1602{ 1610{
1603 int id; /* the svg id to use */ 1611 int id; /* the svg id to use */
1604 Eina_Bool set; /* if vg condition it's content */ 1612 Eina_Bool set; /* if vg condition it's content */
1613 Edje_Vector_File_Type type;
1614 double frame;
1605}; 1615};
1606 1616
1607struct _Edje_Part_Description_Image 1617struct _Edje_Part_Description_Image
@@ -1988,6 +1998,7 @@ struct _Edje_Real_Part_Drag
1988#define EDJE_RP_TYPE_TEXT 1 1998#define EDJE_RP_TYPE_TEXT 1
1989#define EDJE_RP_TYPE_CONTAINER 2 1999#define EDJE_RP_TYPE_CONTAINER 2
1990#define EDJE_RP_TYPE_SWALLOW 3 2000#define EDJE_RP_TYPE_SWALLOW 3
2001#define EDJE_RP_TYPE_VECTOR 4
1991 2002
1992struct _Edje_Real_Part_Text 2003struct _Edje_Real_Part_Text
1993{ 2004{
@@ -2032,6 +2043,18 @@ struct _Edje_Real_Part_Swallow
2032 } swallow_params; // 28 // FIXME: only if type SWALLOW 2043 } swallow_params; // 28 // FIXME: only if type SWALLOW
2033}; 2044};
2034 2045
2046struct _Edje_Real_Part_Vector
2047{
2048 Eo *anim;
2049 Eina_File *json_virtual_file;
2050 char *json_data;
2051 int start_frame;
2052 int current_id;
2053 Eina_Bool backward : 1;
2054 Eina_Bool loop : 1;
2055 Eina_Bool is_playing : 1;
2056};
2057
2035struct _Edje_Real_Part 2058struct _Edje_Real_Part
2036{ 2059{
2037 Edje_Real_Part_State param1; // 32 2060 Edje_Real_Part_State param1; // 32
@@ -2054,6 +2077,7 @@ struct _Edje_Real_Part
2054 Edje_Real_Part_Text *text; 2077 Edje_Real_Part_Text *text;
2055 Edje_Real_Part_Container *container; 2078 Edje_Real_Part_Container *container;
2056 Edje_Real_Part_Swallow *swallow; 2079 Edje_Real_Part_Swallow *swallow;
2080 Edje_Real_Part_Vector *vector;
2057 } typedata; // 4 2081 } typedata; // 4
2058 FLOAT_T description_pos; // 8 2082 FLOAT_T description_pos; // 8
2059 Edje_Rectangle req; // 16 2083 Edje_Rectangle req; // 16
@@ -3326,6 +3350,10 @@ char * _edje_text_cursor_content_get(Edje_Real_Part *rp, Efl_Text_Cursor_Handle
3326void _edje_object_part_text_insert(Edje *ed, Edje_Real_Part *rp, const char *text); 3350void _edje_object_part_text_insert(Edje *ed, Edje_Real_Part *rp, const char *text);
3327 3351
3328void _edje_internal_proxy_shutdown(void); 3352void _edje_internal_proxy_shutdown(void);
3353void _edje_part_vector_anim_stop(Edje *ed, Edje_Real_Part *rp);
3354void _edje_part_vector_anim_pause(Edje *ed, Edje_Real_Part *rp);
3355void _edje_part_vector_anim_resume(Edje *ed, Edje_Real_Part *rp);
3356void _edje_part_vector_anim_play(Edje *ed, Edje_Real_Part *rp, Eina_Bool backward, Eina_Bool loop);
3329 3357
3330#ifdef HAVE_EPHYSICS 3358#ifdef HAVE_EPHYSICS
3331Eina_Bool _edje_ephysics_load(void); 3359Eina_Bool _edje_ephysics_load(void);
diff --git a/src/lib/edje/edje_program.c b/src/lib/edje/edje_program.c
index b1edd1fa2b..fbef7639ed 100644
--- a/src/lib/edje/edje_program.c
+++ b/src/lib/edje/edje_program.c
@@ -1221,6 +1221,78 @@ low_mem_current:
1221 break; 1221 break;
1222 1222
1223#endif 1223#endif
1224
1225 case EDJE_ACTION_TYPE_VG_ANIM_STOP:
1226 if (_edje_block_break(ed))
1227 goto break_prog;
1228 EINA_LIST_FOREACH(pr->targets, l, pt)
1229 {
1230 if (pt->id >= 0)
1231 {
1232 rp = ed->table_parts[pt->id % ed->table_parts_size];
1233 if (rp)
1234 _edje_part_vector_anim_stop(ed, rp);
1235 }
1236 }
1237 break;
1238
1239 case EDJE_ACTION_TYPE_VG_ANIM_PAUSE:
1240 if (_edje_block_break(ed))
1241 goto break_prog;
1242 EINA_LIST_FOREACH(pr->targets, l, pt)
1243 {
1244 if (pt->id >= 0)
1245 {
1246 rp = ed->table_parts[pt->id % ed->table_parts_size];
1247 if (rp)
1248 _edje_part_vector_anim_pause(ed, rp);
1249 }
1250 }
1251 break;
1252
1253 case EDJE_ACTION_TYPE_VG_ANIM_RESUME:
1254 if (_edje_block_break(ed))
1255 goto break_prog;
1256 EINA_LIST_FOREACH(pr->targets, l, pt)
1257 {
1258 if (pt->id >= 0)
1259 {
1260 rp = ed->table_parts[pt->id % ed->table_parts_size];
1261 if (rp)
1262 _edje_part_vector_anim_resume(ed, rp);
1263 }
1264 }
1265 break;
1266
1267 case EDJE_ACTION_TYPE_VG_ANIM_LOOP:
1268 case EDJE_ACTION_TYPE_VG_ANIM_REWIND:
1269 case EDJE_ACTION_TYPE_VG_ANIM_PLAY:
1270 if (_edje_block_break(ed))
1271 goto break_prog;
1272 EINA_LIST_FOREACH(pr->targets, l, pt)
1273 {
1274 if (pt->id >= 0)
1275 {
1276 rp = ed->table_parts[pt->id % ed->table_parts_size];
1277 if (rp)
1278 {
1279 Eina_Bool vector_anim_backward = EINA_FALSE;
1280 Eina_Bool vector_anim_loop = EINA_FALSE;
1281
1282 if (pr->action == EDJE_ACTION_TYPE_VG_ANIM_REWIND)
1283 vector_anim_backward = EINA_TRUE;
1284
1285 if (pr->action == EDJE_ACTION_TYPE_VG_ANIM_LOOP)
1286 vector_anim_loop = EINA_TRUE;
1287
1288 _edje_part_vector_anim_play(ed, rp,
1289 vector_anim_backward,
1290 vector_anim_loop);
1291 }
1292 }
1293 }
1294 break;
1295
1224 default: 1296 default:
1225 // _edje_emit(ed, "program,start", pr->name); 1297 // _edje_emit(ed, "program,start", pr->name);
1226 // _edje_emit(ed, "program,stop", pr->name); 1298 // _edje_emit(ed, "program,stop", pr->name);