Page MenuHomePhabricator

Elm_Animation_View : Add elm_animation_view_frame_set/get apis
ClosedPublic

Authored by jsuya on Jan 15 2019, 12:14 AM.

Details

Reviewers
Hermet
Summary
elm_animation_view_frame_set is index of frame of animation view.
Range of frame value is 0 to elm_animation_view_fame_count - 1.
This value calculated with keyframe value.

elm_animation_view_frame_get return index of current frame.
Test Plan
setenv("ECTOR_BACKEND", "default", 1);
setenv("ELM_ACCEL", "gl", 1);

elm_init(argc, argv);

Eo *win = elm_win_util_standard_add(NULL, "test");
evas_object_smart_callback_add(win, "delete,request", win_del, 0);
elm_win_autodel_set(win, 1);

//Animation View
Evas_Object *anim_view = elm_animation_view_add(win);
elm_animation_view_auto_repeat_set(anim_view, 1);
elm_animation_view_file_set(anim_view, "a.json", NULL);
evas_object_show(anim_view);

evas_object_size_hint_align_set(anim_view, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(anim_view, 1, 1);

elm_win_resize_object_add(win, anim_view);

evas_object_resize(win, WIDTH, HEIGHT);
evas_object_show(win);

printf("Get frame count : %d\n", elm_animation_view_frame_count_get(anim_view));
printf("Set frame : 35\n");
elm_animation_view_frame_set(anim_view  , 35);
printf("Get frame : %d\n", elm_animation_view_frame_get(anim_view));
printf("Get keyframe : %f\n", elm_animation_view_keyframe_get(anim_view));

printf("Set frame : 0\n");
elm_animation_view_frame_set(anim_view  , 0);
printf("Get frame : %d\n", elm_animation_view_frame_get(anim_view));
printf("Get keyframe : %f\n", elm_animation_view_keyframe_get(anim_view));

printf("Set keyframe : 0.5\n");
elm_animation_view_keyframe_set(anim_view  , 0.5);
printf("Get keyframe : %f\n", elm_animation_view_keyframe_get(anim_view));
printf("Get frame : %d\n", elm_animation_view_frame_get(anim_view));

elm_run();
elm_shutdown();

Diff Detail

Repository
rEFL core/efl
Branch
devs/hermet/lottie
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 8817
Build 7757: arc lint + arc unit
jsuya created this revision.Jan 15 2019, 12:14 AM
jsuya requested review of this revision.Jan 15 2019, 12:14 AM
jsuya updated this revision to Diff 18414.Jan 15 2019, 12:15 AM

Fix mistake

Hermet requested changes to this revision.Jan 15 2019, 12:24 AM

Added comments.

src/lib/elementary/elm_animation_view.c
173

frame range must be 0 ~ total_frame.

516

this wrapping is enough to go.
_elm_animation_view_keyframe_set(frame / evas_object_vg_animated_frame_count_get(pd->vg));

530

return (int) ((double) evas_object_vg_animated_frame_count_get(pd->vg) * pd->progress);

src/lib/elementary/elm_widget_animation_view.h
18 ↗(On Diff #18414)

we can use keyframe, don't need additional one.
when user call frame_set()/get(), we can convert the frame value to keyframe immediately.

This revision now requires changes to proceed.Jan 15 2019, 12:24 AM
YOhoho added a subscriber: YOhoho.Jan 15 2019, 12:27 AM

optimization point :)

src/lib/elementary/elm_widget_animation_view.h
18 ↗(On Diff #18414)

you can rearrange double, int struct member for efficient memory alignment.

jsuya updated this revision to Diff 18416.Jan 15 2019, 1:32 AM

update code

jsuya updated this revision to Diff 18417.Jan 15 2019, 1:34 AM

fix typo

Hermet requested changes to this revision.Jan 15 2019, 1:44 AM

Please see comments.

src/lib/elementary/elm_animation_view.c
518

we don't need this line, keyframe_set() will do exceptional handling.

526

no, minus 1,

src/lib/elementary/elm_animation_view.eo
83

please see evas_object_vg_frame_set() doc and update this as well.

87

user can pass 0 ~ frame_count.

This revision now requires changes to proceed.Jan 15 2019, 1:44 AM
jsuya added inline comments.Jan 15 2019, 2:09 AM
src/lib/elementary/elm_animation_view.c
518

Ok. i worry about negative integer, but it is not necessary. i'm wrong.

526

animated_frame_count is total number of frame.
evas_object_vg_animated_frame_count_get is from evas_cache_vg_anim_frame_count_get(Vg_Cache_Entry).
In evas_vg_cache.c, frame_num is started 0 and ended frame_cnt - 1.

please check again.

jsuya updated this revision to Diff 18420.Jan 15 2019, 3:14 AM

update code

jsuya updated this revision to Diff 18421.Jan 15 2019, 3:35 AM

update comment

jsuya updated this revision to Diff 18422.Jan 15 2019, 3:36 AM
jsuya edited the summary of this revision. (Show Details)

update commit's comment

Hermet accepted this revision.Jan 15 2019, 5:28 PM
This revision is now accepted and ready to land.Jan 15 2019, 5:28 PM
Hermet closed this revision.Jan 15 2019, 5:28 PM

@jsuya @Hermet it seems this is new api being added but there is no usage at all in the tree...is there a reason why the provided example code can't be submitted in some kind of test?