From aef56b169e2588ee450e13b5f163c19bd65a330f Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Thu, 14 Nov 2019 12:54:31 +0100 Subject: [PATCH] remove efl_canvas_animation_player this now all migrated to Efl.Canvas.Object.Animation Reviewed-by: Cedric BAIL Differential Revision: https://phab.enlightenment.org/D10667 --- src/lib/evas/Efl_Canvas.h | 1 - src/lib/evas/Evas_Eo.h | 1 - src/lib/evas/canvas/efl_canvas_animation.eo | 5 +- .../evas/canvas/efl_canvas_animation_player.c | 444 ------------------ .../canvas/efl_canvas_animation_player.eo | 62 --- .../efl_canvas_animation_player_private.h | 53 --- src/lib/evas/canvas/meson.build | 2 - 7 files changed, 2 insertions(+), 566 deletions(-) delete mode 100644 src/lib/evas/canvas/efl_canvas_animation_player.c delete mode 100644 src/lib/evas/canvas/efl_canvas_animation_player.eo delete mode 100644 src/lib/evas/canvas/efl_canvas_animation_player_private.h diff --git a/src/lib/evas/Efl_Canvas.h b/src/lib/evas/Efl_Canvas.h index 82659a38e7..cf0db0c2f4 100644 --- a/src/lib/evas/Efl_Canvas.h +++ b/src/lib/evas/Efl_Canvas.h @@ -69,7 +69,6 @@ extern "C" { #include #include #include -#include #include #include #include diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h index 13ecde563a..5f8d0b45bc 100644 --- a/src/lib/evas/Evas_Eo.h +++ b/src/lib/evas/Evas_Eo.h @@ -232,7 +232,6 @@ struct _Efl_Canvas_Object_Animation_Event #include "canvas/efl_canvas_animation_group.eo.h" #include "canvas/efl_canvas_animation_group_parallel.eo.h" #include "canvas/efl_canvas_animation_group_sequential.eo.h" -#include "canvas/efl_canvas_animation_player.eo.h" #include "canvas/efl_canvas_event_grabber.eo.h" /** diff --git a/src/lib/evas/canvas/efl_canvas_animation.eo b/src/lib/evas/canvas/efl_canvas_animation.eo index f8c371c0c9..3640cd2234 100644 --- a/src/lib/evas/canvas/efl_canvas_animation.eo +++ b/src/lib/evas/canvas/efl_canvas_animation.eo @@ -1,5 +1,4 @@ import efl_canvas_animation_types; -parse efl_canvas_animation_player; class @beta Efl.Canvas.Animation extends Efl.Object implements Efl.Playable { @@ -16,7 +15,7 @@ class @beta Efl.Canvas.Animation extends Efl.Object implements Efl.Playable removed. This means that if the animation does not end in the object's initial state there will be a noticeable sudden jump. To avoid this, animations must finish in the same state as they begin, or the object's state must be - matched to the animation's ending state once the animation finishes (using the @[Efl.Canvas.Animation_Player.ended] + matched to the animation's ending state once the animation finishes (using the @[Efl.Canvas.Object_Animation.animation,changed] event). ]] c_prefix: efl_animation; @@ -99,7 +98,7 @@ class @beta Efl.Canvas.Animation extends Efl.Object implements Efl.Playable } animation_apply { [[Overwrite this method to implement your own animation subclasses. - + This is used for example by @Efl.Canvas.Animation_Translate or @Efl.Canvas.Animation_Scale. Subclasses should call their parent's @.animation_apply to get the adjusted $progress value diff --git a/src/lib/evas/canvas/efl_canvas_animation_player.c b/src/lib/evas/canvas/efl_canvas_animation_player.c deleted file mode 100644 index e8b57cb5b9..0000000000 --- a/src/lib/evas/canvas/efl_canvas_animation_player.c +++ /dev/null @@ -1,444 +0,0 @@ -#include "efl_canvas_animation_player_private.h" - -static void -_target_del_cb(void *data, const Efl_Event *event EINA_UNUSED) -{ - Efl_Canvas_Animation_Player_Data *pd = data; - pd->target = NULL; -} - -EOLIAN static void -_efl_canvas_animation_player_target_set(Eo *eo_obj EINA_UNUSED, - Efl_Canvas_Animation_Player_Data *pd, - Efl_Canvas_Object *target) -{ - if (pd->target == target) - return; - - if (pd->target) - efl_event_callback_del(pd->target, EFL_EVENT_DEL, _target_del_cb, pd); - - efl_event_callback_add(target, EFL_EVENT_DEL, _target_del_cb, pd); - - pd->target = target; -} - -EOLIAN static Efl_Canvas_Object * -_efl_canvas_animation_player_target_get(const Eo *eo_obj EINA_UNUSED, Efl_Canvas_Animation_Player_Data *pd) -{ - return pd->target; -} - -EOLIAN static void -_efl_canvas_animation_player_auto_del_set(Eo *eo_obj EINA_UNUSED, - Efl_Canvas_Animation_Player_Data *pd, - Eina_Bool auto_del) -{ - pd->auto_del = auto_del; -} - -EOLIAN static Eina_Bool -_efl_canvas_animation_player_auto_del_get(const Eo *eo_obj EINA_UNUSED, - Efl_Canvas_Animation_Player_Data *pd) -{ - return pd->auto_del; -} - -EOLIAN static void -_efl_canvas_animation_player_animation_set(Eo *eo_obj, - Efl_Canvas_Animation_Player_Data *pd, - Efl_Canvas_Animation *anim) -{ - if (anim == pd->animation) - return; - - if (!efl_isa(anim, EFL_CANVAS_ANIMATION_CLASS)) - { - ERR("Passed argument [%p]:[%s] is not an Efl.Animation", - anim, efl_class_name_get(efl_class_get(anim))); - return; - } - - if (pd->animation) - { - efl_player_playing_set(eo_obj, EINA_FALSE); - efl_unref(pd->animation); - } - pd->animation = anim; - efl_ref(pd->animation); -} - -EOLIAN static Efl_Canvas_Animation * -_efl_canvas_animation_player_animation_get(const Eo *eo_obj EINA_UNUSED, - Efl_Canvas_Animation_Player_Data *pd) -{ - return pd->animation; -} - -static Eina_Bool -_animator_cb(void *data) -{ - Eo *eo_obj = data; - EFL_ANIMATION_PLAYER_DATA_GET(eo_obj, pd); - EFL_ANIMATION_PLAYER_ANIMATION_GET(eo_obj, anim); - double duration, elapsed_time, vector; - - if (efl_playable_seekable_get(eo_obj)) - { - pd->time.current = ecore_loop_time_get(); - - duration = efl_animation_duration_get(anim); - elapsed_time = pd->time.current - pd->time.prev; - vector = elapsed_time / duration; - - /* When animation player starts, _animator_cb() is called immediately so - * both elapsed time and progress are 0.0. - * Since it is the beginning of the animation if progress is 0.0, the - * following codes for animation should be executed. */ - if ((vector <= DBL_EPSILON) && (pd->progress != 0.0)) - return ECORE_CALLBACK_RENEW; // There is no update. - - //TODO: check negative play_speed. - if (!pd->is_direction_forward) - vector *= -1; - pd->progress += vector; - - if (pd->progress > 1.0) - pd->progress = 1.0; - else if (pd->progress < 0.0) - pd->progress = 0.0; - } - else - { - pd->progress = (double)(pd->is_direction_forward); - } - - /* The previously applied map effect should be reset before applying the - * current map effect. Otherwise, the incrementally added map effects - * increase numerical error. */ - efl_gfx_mapping_reset(efl_animation_player_target_get(eo_obj)); - efl_animation_apply(anim, pd->progress, efl_animation_player_target_get(eo_obj)); - - Efl_Canvas_Animation_Player_Event_Running event_running; - event_running.progress = pd->progress; - efl_event_callback_call(eo_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, - &event_running); - pd->time.prev = pd->time.current; - - //Not end. Keep going. - if (fabs((!!(pd->is_direction_forward)) - pd->progress) > DBL_EPSILON) - return ECORE_CALLBACK_RENEW; - - //Repeat animation - if ((efl_animation_repeat_count_get(anim) == EFL_ANIMATION_REPEAT_INFINITE) || - (pd->remaining_repeat_count > 0)) - { - if (pd->remaining_repeat_count > 0) - pd->remaining_repeat_count--; - - if (efl_animation_repeat_mode_get(anim) == EFL_CANVAS_ANIMATION_REPEAT_MODE_REVERSE) - { - pd->is_direction_forward = !pd->is_direction_forward; - } - else - { - pd->progress = 0.0; - } - - return ECORE_CALLBACK_RENEW; - } - efl_player_playing_set(eo_obj, EINA_FALSE); - - pd->animator = NULL; - return ECORE_CALLBACK_CANCEL; -} - -static void -_start(Eo *eo_obj, Efl_Canvas_Animation_Player_Data *pd) -{ - EFL_ANIMATION_PLAYER_ANIMATION_GET(eo_obj, anim); - - pd->is_direction_forward = EINA_TRUE; - - pd->remaining_repeat_count = efl_animation_repeat_count_get(anim); - - ecore_animator_del(pd->animator); - pd->animator = NULL; - pd->time.prev = ecore_loop_time_get(); - - //pre started event is supported within class only (protected event) - efl_event_callback_call(eo_obj, EFL_ANIMATION_PLAYER_EVENT_PRE_STARTED, - NULL); - efl_event_callback_call(eo_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, NULL); - - pd->animator = ecore_evas_animator_add(pd->target, _animator_cb, eo_obj); - - _animator_cb(eo_obj); -} - -static Eina_Bool -_start_delay_timer_cb(void *data) -{ - Eo *eo_obj = data; - EFL_ANIMATION_PLAYER_DATA_GET(eo_obj, pd); - - pd->start_delay_timer = NULL; - - _start(eo_obj, pd); - - return ECORE_CALLBACK_CANCEL; -} - -static Eina_Bool -_is_final_state(Efl_Canvas_Animation *anim, double progress) -{ - if (!anim) return EINA_FALSE; - if ((progress != 0.0) && (progress != 1.0)) return EINA_FALSE; - - if (efl_animation_repeat_mode_get(anim) == EFL_CANVAS_ANIMATION_REPEAT_MODE_REVERSE) - { - if (efl_animation_repeat_count_get(anim) & 1) - { - if (progress == 0.0) - return EINA_TRUE; - } - else - { - if (progress == 1.0) - return EINA_TRUE; - } - } - else - { - if (progress == 1.0) - return EINA_TRUE; - } - - return EINA_FALSE; -} - -static void -_player_stop(Eo *eo_obj, Efl_Canvas_Animation_Player_Data *pd, Efl_Canvas_Animation *anim) -{ - //Reset the state of the target to the initial state - efl_gfx_mapping_reset(efl_animation_player_target_get(eo_obj)); - - if (efl_animation_final_state_keep_get(anim)) - { - if (_is_final_state(anim, pd->progress)) - { - /* Keep the final state only if efl_player_playing_set(EINA_FALSE) is called at - * the end of _animator_cb. */ - efl_animation_apply(anim, pd->progress, - efl_animation_player_target_get(eo_obj)); - } - else - { - pd->progress = 0.0; - } - } - else - { - pd->progress = 0.0; - } - efl_event_callback_call(eo_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, NULL); - if (pd->auto_del) efl_del(eo_obj); -} - -EOLIAN static Eina_Bool -_efl_canvas_animation_player_efl_player_playing_set(Eo *eo_obj, Efl_Canvas_Animation_Player_Data *pd, Eina_Bool playing) -{ - double start_delay; - EFL_ANIMATION_PLAYER_ANIMATION_GET(eo_obj, anim); - - if (!efl_playable_get(eo_obj)) return EINA_FALSE; - if ((!playing) && (!pd->is_play)) return EINA_TRUE; - if ((playing) && (pd->is_play)) return EINA_TRUE; - pd->is_play = !!playing; - if (!playing) - { - if (!pd->is_play) return EINA_TRUE; - pd->is_paused = EINA_FALSE; - _player_stop(eo_obj, pd, anim); - return EINA_TRUE; - } - //TODO: check this case is correct - if (pd->start_delay_timer) return EINA_TRUE; - - pd->progress = 0.0; - start_delay = efl_animation_start_delay_get(anim); - if (start_delay > 0.0) - { - pd->start_delay_timer = ecore_timer_add(start_delay, - _start_delay_timer_cb, eo_obj); - } - else - _start(eo_obj, pd); - return EINA_TRUE; -} - -EOLIAN static Eina_Bool -_efl_canvas_animation_player_efl_player_playing_get(const Eo *eo_obj EINA_UNUSED, Efl_Canvas_Animation_Player_Data *pd) -{ - return pd->is_play; -} - -EOLIAN static Eina_Bool -_efl_canvas_animation_player_efl_player_paused_set(Eo *eo_obj, - Efl_Canvas_Animation_Player_Data *pd, - Eina_Bool paused) -{ - paused = !!paused; - /* can't pause if not playing */ - if (!pd->is_play) return EINA_FALSE; - if (pd->is_paused == paused) return EINA_TRUE; - pd->is_paused = paused; - if (!paused) - { - //TODO: check this case is correct. - if (pd->start_delay_timer) return EINA_FALSE; - - pd->time.prev = ecore_loop_time_get(); - pd->animator = ecore_evas_animator_add(pd->target, _animator_cb, eo_obj); - - _animator_cb(eo_obj); - } - else - { - ecore_timer_del(pd->start_delay_timer); - pd->start_delay_timer = NULL; - ecore_animator_del(pd->animator); - pd->animator = NULL; - } - return EINA_TRUE; -} - -EOLIAN static Eina_Bool -_efl_canvas_animation_player_efl_player_paused_get(const Eo *eo_obj EINA_UNUSED, - Efl_Canvas_Animation_Player_Data *pd) -{ - return pd->is_paused; -} - -EOLIAN static Eina_Bool -_efl_canvas_animation_player_efl_playable_playable_get(const Eo *eo_obj, - Efl_Canvas_Animation_Player_Data *pd EINA_UNUSED) -{ - Efl_Canvas_Animation *anim = efl_animation_player_animation_get(eo_obj); - - return efl_playable_get(anim); -} - -EOLIAN static double -_efl_canvas_animation_player_efl_player_playback_position_get(const Eo *eo_obj, - Efl_Canvas_Animation_Player_Data *pd EINA_UNUSED) -{ - //TODO: this is not correct - Efl_Canvas_Animation *anim = efl_animation_player_animation_get(eo_obj); - double length = efl_animation_duration_get(anim); - - return length * efl_player_playback_progress_get(eo_obj); -} - -EOLIAN static void -_efl_canvas_animation_player_efl_player_playback_position_set(Eo *eo_obj, - Efl_Canvas_Animation_Player_Data *pd EINA_UNUSED, - double sec) -{ - //TODO: this is not correct - if (!efl_playable_seekable_get(eo_obj)) - return; - - EFL_ANIMATION_PLAYER_ANIMATION_GET(eo_obj, anim); - double length = efl_animation_duration_get(anim); - pd->progress = sec / length; - - /* The previously applied map effect should be reset before applying the - * current map effect. Otherwise, the incrementally added map effects - * increase numerical error. */ - efl_gfx_mapping_reset(efl_animation_player_target_get(eo_obj)); - efl_animation_apply(anim, pd->progress, efl_animation_player_target_get(eo_obj)); -} - -EOLIAN static double -_efl_canvas_animation_player_efl_player_playback_progress_get(const Eo *eo_obj EINA_UNUSED, - Efl_Canvas_Animation_Player_Data *pd) -{ - return pd->progress; -} - -EOLIAN static void -_efl_canvas_animation_player_efl_player_playback_speed_set(Eo *eo_obj EINA_UNUSED, - Efl_Canvas_Animation_Player_Data *pd, - double play_speed) -{ - //TODO: check reverse play case. - if (play_speed < 0) - return; - pd->play_speed = play_speed; -} - -EOLIAN static double -_efl_canvas_animation_player_efl_player_playback_speed_get(const Eo *eo_obj EINA_UNUSED, - Efl_Canvas_Animation_Player_Data *pd) -{ - return pd->play_speed; -} - -EOLIAN static double -_efl_canvas_animation_player_efl_playable_length_get(const Eo *eo_obj, - Efl_Canvas_Animation_Player_Data *pd EINA_UNUSED) -{ - EFL_ANIMATION_PLAYER_ANIMATION_GET(eo_obj, anim); - return efl_playable_length_get(anim); -} - -EOLIAN static Eina_Bool -_efl_canvas_animation_player_efl_playable_seekable_get(const Eo *eo_obj EINA_UNUSED, - Efl_Canvas_Animation_Player_Data *pd EINA_UNUSED) -{ - EFL_ANIMATION_PLAYER_ANIMATION_GET(eo_obj, anim); - return efl_playable_seekable_get(anim); -} - -EOLIAN static Efl_Object * -_efl_canvas_animation_player_efl_object_constructor(Eo *eo_obj, - Efl_Canvas_Animation_Player_Data *pd) -{ - eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS)); - - pd->time.begin = 0.0; - pd->time.current = 0.0; - - pd->animation = NULL; - - pd->progress = 0.0; - - //pd->auto_del = EINA_TRUE; - - return eo_obj; -} - -EOLIAN static void -_efl_canvas_animation_player_efl_object_destructor(Eo *eo_obj, - Efl_Canvas_Animation_Player_Data *pd) -{ - if (pd->animator) - { - ecore_animator_del(pd->animator); - pd->animator = NULL; - - //Reset the state of the target to the initial state - efl_player_playing_set(eo_obj, EINA_FALSE); - - efl_event_callback_call(eo_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, NULL); - } - efl_unref(pd->animation); - - efl_destructor(efl_super(eo_obj, MY_CLASS)); -} - -EWAPI const Efl_Event_Description _EFL_ANIMATION_PLAYER_EVENT_PRE_STARTED = - EFL_EVENT_DESCRIPTION("pre_started"); - -#include "efl_canvas_animation_player.eo.c" diff --git a/src/lib/evas/canvas/efl_canvas_animation_player.eo b/src/lib/evas/canvas/efl_canvas_animation_player.eo deleted file mode 100644 index 9a391cb874..0000000000 --- a/src/lib/evas/canvas/efl_canvas_animation_player.eo +++ /dev/null @@ -1,62 +0,0 @@ -class @beta Efl.Canvas.Animation_Player extends Efl.Object implements Efl.Player, Efl.Playable -{ - [[Player object for playing canvas animations. - - This player object can be used to play animations on a @.target canvas object. - The type of animation depends on the @.animation object. - ]] - c_prefix: efl_animation_player; - methods { - @property animation { - [[The animation to play. - - This animation object will be used to change the visual state of the @.target object. - ]] - values { - animation: Efl.Canvas.Animation; [[An already-configured animation object.]] - } - } - @property auto_del { - [[Auto delete property]] - set { - } - get { - } - values { - auto_del: bool; [[$true to delete animation object automatically when animation is finished or animation is - cancelled, $false otherwise.]] - } - } - @property target { - [[The canvas object to apply the effects of the @.animation object on. - - The @.animation object can change several properties of the $target. - You should ensure that nothing else is trying to change them too. - ]] - values { - target: Efl.Canvas.Object; [[Canvas object to animate.]] - } - } - } - implements { - Efl.Object.constructor; - Efl.Object.destructor; - Efl.Player.playing { get; set; } - Efl.Player.paused { get; set; } - Efl.Playable.playable { get; } - Efl.Player.playback_position { get; set; } - Efl.Player.playback_progress { get;} - Efl.Player.playback_speed { get; set; } - //Efl.Player.volume { get; set; } - //Efl.Player.mute { get; set; } - Efl.Playable.length { get; } - Efl.Playable.seekable { get; } - } - events { - /* FIXME: This event is similar to Efl.Canvas.Object.anim_started but with different type, might be confusing. */ - started: void; [[Animation is started.]] - running: Efl.Canvas.Object_Animation_Event; [[Animation is running.]] - /* FIXME: This event is similar to Efl.Canvas.Object.anim_ended but with different type, might be confusing. */ - ended: void; [[Animation is ended.]] - } -} diff --git a/src/lib/evas/canvas/efl_canvas_animation_player_private.h b/src/lib/evas/canvas/efl_canvas_animation_player_private.h deleted file mode 100644 index aff74db408..0000000000 --- a/src/lib/evas/canvas/efl_canvas_animation_player_private.h +++ /dev/null @@ -1,53 +0,0 @@ -#define EFL_ANIMATION_PLAYER_PROTECTED - -#include "evas_common_private.h" -#include - -#define MY_CLASS EFL_CANVAS_ANIMATION_PLAYER_CLASS -#define MY_CLASS_NAME efl_class_name_get(MY_CLASS) - -#if 0 -typedef struct _Target_State -{ - Evas_Coord x, y, w, h; - int r, g, b, a; - - Evas_Map *map; - Eina_Bool enable_map : 1; -} Target_State; -#endif - -typedef struct _Efl_Canvas_Animation_Player_Data -{ - Ecore_Animator *animator; - Ecore_Timer *start_delay_timer; - - struct { - double prev; - double begin; - double current; - double pause_begin; - } time; - - Efl_Canvas_Animation *animation; - Efl_Canvas_Object *target; - - double progress; - double play_speed; - - int remaining_repeat_count; - - Efl_Interpolator *interpolator; - - Eina_Bool auto_del : 1; - Eina_Bool is_play : 1; - Eina_Bool is_paused : 1; - Eina_Bool keep_final_state : 1; - Eina_Bool is_direction_forward : 1; -} Efl_Canvas_Animation_Player_Data; - -#define EFL_ANIMATION_PLAYER_DATA_GET(o, pd) \ - Efl_Canvas_Animation_Player_Data *pd = efl_data_scope_get(o, EFL_CANVAS_ANIMATION_PLAYER_CLASS) - -#define EFL_ANIMATION_PLAYER_ANIMATION_GET(o, anim) \ - Efl_Canvas_Animation *anim = efl_animation_player_animation_get(o) diff --git a/src/lib/evas/canvas/meson.build b/src/lib/evas/canvas/meson.build index c13d3335a7..67134caed9 100644 --- a/src/lib/evas/canvas/meson.build +++ b/src/lib/evas/canvas/meson.build @@ -39,7 +39,6 @@ pub_eo_files = [ 'efl_canvas_animation_group.eo', 'efl_canvas_animation_group_parallel.eo', 'efl_canvas_animation_group_sequential.eo', - 'efl_canvas_animation_player.eo', 'efl_canvas_text_factory.eo', 'efl_canvas_rectangle.eo', 'efl_canvas_object.eo', @@ -185,7 +184,6 @@ evas_src += files([ 'efl_canvas_animation_group.c', 'efl_canvas_animation_group_parallel.c', 'efl_canvas_animation_group_sequential.c', - 'efl_canvas_animation_player.c', 'efl_gfx_vg_value_provider.c', 'efl_canvas_vg_object.c', 'efl_canvas_vg_node.c',