summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2017-08-25 17:54:29 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-09-18 20:47:37 +0900
commit712243fb57a45e74caebb96ae0b52072dedafae5 (patch)
tree89befbe49c32b465ba35f15dbc4b19fa61a70ae8
parentf347db4bf38df21f95e32d9d463bf24506d5a947 (diff)
downloadefl-712243fb57a45e74caebb96ae0b52072dedafae5.tar.gz
efl_animation: Add parallel group animation and instance
Efl.Animation.Group.Parallel is a class for animations started in parallel. Efl.Animation.Instance.Group.Parallel is a class which provides methods for an instance of Efl.Animation.Group.Parallel. The instances added into the parallel group animation instance start in parallel.
-rw-r--r--src/Makefile_Evas.am8
-rw-r--r--src/lib/evas/Evas_Common.h14
-rw-r--r--src/lib/evas/Evas_Eo.h2
-rw-r--r--src/lib/evas/canvas/efl_animation_group_parallel.c103
-rw-r--r--src/lib/evas/canvas/efl_animation_group_parallel.eo15
-rw-r--r--src/lib/evas/canvas/efl_animation_group_parallel_private.h25
-rw-r--r--src/lib/evas/canvas/efl_animation_instance_group_parallel.c112
-rw-r--r--src/lib/evas/canvas/efl_animation_instance_group_parallel.eo12
-rw-r--r--src/lib/evas/canvas/efl_animation_instance_group_parallel_private.h25
9 files changed, 315 insertions, 1 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 8d3bb63488..2b03649973 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -50,12 +50,14 @@ evas_eolian_pub_files = \
lib/evas/canvas/efl_animation_scale.eo \
lib/evas/canvas/efl_animation_translate.eo \
lib/evas/canvas/efl_animation_group.eo \
+ lib/evas/canvas/efl_animation_group_parallel.eo \
lib/evas/canvas/efl_animation_instance.eo \
lib/evas/canvas/efl_animation_instance_alpha.eo \
lib/evas/canvas/efl_animation_instance_rotate.eo \
lib/evas/canvas/efl_animation_instance_scale.eo \
lib/evas/canvas/efl_animation_instance_translate.eo \
lib/evas/canvas/efl_animation_instance_group.eo \
+ lib/evas/canvas/efl_animation_instance_group_parallel.eo \
$(NULL)
evas_eolian_legacy_files = \
@@ -140,12 +142,14 @@ lib/evas/canvas/efl_animation_rotate_private.h \
lib/evas/canvas/efl_animation_scale_private.h \
lib/evas/canvas/efl_animation_translate_private.h \
lib/evas/canvas/efl_animation_group_private.h \
+lib/evas/canvas/efl_animation_group_parallel_private.h \
lib/evas/canvas/efl_animation_instance_private.h \
lib/evas/canvas/efl_animation_instance_alpha_private.h \
lib/evas/canvas/efl_animation_instance_rotate_private.h \
lib/evas/canvas/efl_animation_instance_scale_private.h \
lib/evas/canvas/efl_animation_instance_translate_private.h \
-lib/evas/canvas/efl_animation_instance_group_private.h
+lib/evas/canvas/efl_animation_instance_group_private.h \
+lib/evas/canvas/efl_animation_instance_group_parallel_private.h
# Linebreak
@@ -237,12 +241,14 @@ lib/evas/canvas/efl_animation_rotate.c \
lib/evas/canvas/efl_animation_scale.c \
lib/evas/canvas/efl_animation_translate.c \
lib/evas/canvas/efl_animation_group.c \
+lib/evas/canvas/efl_animation_group_parallel.c \
lib/evas/canvas/efl_animation_instance.c \
lib/evas/canvas/efl_animation_instance_alpha.c \
lib/evas/canvas/efl_animation_instance_rotate.c \
lib/evas/canvas/efl_animation_instance_scale.c \
lib/evas/canvas/efl_animation_instance_translate.c \
lib/evas/canvas/efl_animation_instance_group.c \
+lib/evas/canvas/efl_animation_instance_group_parallel.c \
$(NULL)
EXTRA_DIST2 += \
diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h
index a36fa87c51..5f5a763945 100644
--- a/src/lib/evas/Evas_Common.h
+++ b/src/lib/evas/Evas_Common.h
@@ -3365,6 +3365,13 @@ typedef Eo Efl_Animation_Group;
#endif
+#ifndef _EFL_ANIMATION_GROUP_PARALLEL_EO_CLASS_TYPE
+#define _EFL_ANIMATION_GROUP_PARALLEL_EO_CLASS_TYPE
+
+typedef Eo Efl_Animation_Group_Parallel;
+
+#endif
+
#ifndef _EFL_ANIMATION_INSTANCE_EO_CLASS_TYPE
#define _EFL_ANIMATION_INSTANCE_EO_CLASS_TYPE
@@ -3407,6 +3414,13 @@ typedef Eo Efl_Animation_Instance_Group;
#endif
+#ifndef _EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_EO_CLASS_TYPE
+#define _EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_EO_CLASS_TYPE
+
+typedef Eo Efl_Animation_Instance_Group_Parallel;
+
+#endif
+
struct _Efl_Animation_Instance_Animate_Event_Info
{
double progress;
diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h
index fb216c7c2e..0ae95e2942 100644
--- a/src/lib/evas/Evas_Eo.h
+++ b/src/lib/evas/Evas_Eo.h
@@ -61,12 +61,14 @@
#include "canvas/efl_animation_scale.eo.h"
#include "canvas/efl_animation_translate.eo.h"
#include "canvas/efl_animation_group.eo.h"
+#include "canvas/efl_animation_group_parallel.eo.h"
#include "canvas/efl_animation_instance.eo.h"
#include "canvas/efl_animation_instance_alpha.eo.h"
#include "canvas/efl_animation_instance_rotate.eo.h"
#include "canvas/efl_animation_instance_scale.eo.h"
#include "canvas/efl_animation_instance_translate.eo.h"
#include "canvas/efl_animation_instance_group.eo.h"
+#include "canvas/efl_animation_instance_group_parallel.eo.h"
#endif /* EFL_EO_API_SUPPORT */
diff --git a/src/lib/evas/canvas/efl_animation_group_parallel.c b/src/lib/evas/canvas/efl_animation_group_parallel.c
new file mode 100644
index 0000000000..fbcbe869f6
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_group_parallel.c
@@ -0,0 +1,103 @@
+#include "efl_animation_group_parallel_private.h"
+
+EOLIAN static void
+_efl_animation_group_parallel_efl_animation_group_animation_add(Eo *eo_obj,
+ Efl_Animation_Group_Parallel_Data *pd EINA_UNUSED,
+ Efl_Animation *animation)
+{
+ EFL_ANIMATION_GROUP_PARALLEL_CHECK_OR_RETURN(eo_obj);
+
+ if (!animation) return;
+
+ efl_animation_group_animation_add(efl_super(eo_obj, MY_CLASS),
+ animation);
+
+ /* Total duration is calculated in efl_animation_total_duration_get() based
+ * on the current group animation list.
+ * Therefore, the calculated total duration should be set to update total
+ * duration. */
+ double total_duration =
+ efl_animation_total_duration_get(eo_obj);
+ efl_animation_total_duration_set(eo_obj, total_duration);
+}
+
+EOLIAN static void
+_efl_animation_group_parallel_efl_animation_group_animation_del(Eo *eo_obj,
+ Efl_Animation_Group_Parallel_Data *pd EINA_UNUSED,
+ Efl_Animation *animation)
+{
+ EFL_ANIMATION_GROUP_PARALLEL_CHECK_OR_RETURN(eo_obj);
+
+ if (!animation) return;
+
+ efl_animation_group_animation_del(efl_super(eo_obj, MY_CLASS),
+ animation);
+
+ /* Total duration is calculated in efl_animation_total_duration_get() based
+ * on the current group animation list.
+ * Therefore, the calculated total duration should be set to update total
+ * duration. */
+ double total_duration =
+ efl_animation_total_duration_get(eo_obj);
+ efl_animation_total_duration_set(eo_obj, total_duration);
+}
+
+EOLIAN static double
+_efl_animation_group_parallel_efl_animation_total_duration_get(Eo *eo_obj,
+ Efl_Animation_Group_Parallel_Data *pd EINA_UNUSED)
+{
+ EFL_ANIMATION_GROUP_PARALLEL_CHECK_OR_RETURN(eo_obj, 0.0);
+
+ Eina_List *animations =
+ efl_animation_group_animations_get(eo_obj);
+ if (!animations) return 0.0;
+
+ double total_duration = 0.0;
+ Eina_List *l;
+ Efl_Animation *anim;
+ EINA_LIST_FOREACH(animations, l, anim)
+ {
+ double child_total_duration = efl_animation_total_duration_get(anim);
+ if (child_total_duration > total_duration)
+ total_duration = child_total_duration;
+ }
+ return total_duration;
+}
+
+EOLIAN static Efl_Animation_Instance *
+_efl_animation_group_parallel_efl_animation_instance_create(Eo *eo_obj,
+ Efl_Animation_Group_Parallel_Data *pd EINA_UNUSED)
+{
+ EFL_ANIMATION_GROUP_PARALLEL_CHECK_OR_RETURN(eo_obj, NULL);
+
+ Efl_Animation_Instance_Group_Parallel *group_inst
+ = efl_add(EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_CLASS, NULL);
+
+ Eina_List *animations = efl_animation_group_animations_get(eo_obj);
+ Eina_List *l;
+ Efl_Animation *child_anim;
+ Efl_Animation_Instance *child_inst;
+
+ EINA_LIST_FOREACH(animations, l, child_anim)
+ {
+ child_inst = efl_animation_instance_create(child_anim);
+ efl_animation_instance_group_instance_add(group_inst, child_inst);
+ }
+
+ Efl_Canvas_Object *target = efl_animation_target_get(eo_obj);
+ if (target)
+ efl_animation_instance_target_set(group_inst, target);
+
+ Eina_Bool state_keep = efl_animation_final_state_keep_get(eo_obj);
+ efl_animation_instance_final_state_keep_set(group_inst, state_keep);
+
+ double duration = efl_animation_duration_get(eo_obj);
+ efl_animation_instance_duration_set(group_inst, duration);
+
+ double total_duration = efl_animation_total_duration_get(eo_obj);
+ efl_animation_instance_total_duration_set(group_inst, total_duration);
+
+ return group_inst;
+}
+
+#include "efl_animation_group_parallel.eo.c"
diff --git a/src/lib/evas/canvas/efl_animation_group_parallel.eo b/src/lib/evas/canvas/efl_animation_group_parallel.eo
new file mode 100644
index 0000000000..58eaaab7ba
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_group_parallel.eo
@@ -0,0 +1,15 @@
+import efl_animation_types;
+
+class Efl.Animation.Group.Parallel (Efl.Animation.Group)
+{
+ [[Efl group parallel animation class]]
+ data: Efl_Animation_Group_Parallel_Data;
+ methods {
+ }
+ implements {
+ Efl.Animation.instance_create;
+ Efl.Animation.Group.animation_add;
+ Efl.Animation.Group.animation_del;
+ Efl.Animation.total_duration { get; }
+ }
+}
diff --git a/src/lib/evas/canvas/efl_animation_group_parallel_private.h b/src/lib/evas/canvas/efl_animation_group_parallel_private.h
new file mode 100644
index 0000000000..b425a1606e
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_group_parallel_private.h
@@ -0,0 +1,25 @@
+#define EFL_ANIMATION_PROTECTED
+
+#include "evas_common_private.h"
+
+#define MY_CLASS EFL_ANIMATION_GROUP_PARALLEL_CLASS
+#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)
+
+#define EFL_ANIMATION_GROUP_PARALLEL_CHECK_OR_RETURN(anim, ...) \
+ do { \
+ if (!anim) { \
+ CRI("Efl_Animation " # anim " is NULL!"); \
+ return __VA_ARGS__; \
+ } \
+ if (efl_animation_is_deleted(anim)) { \
+ ERR("Efl_Animation " # anim " has already been deleted!"); \
+ return __VA_ARGS__; \
+ } \
+ } while (0)
+
+#define EFL_ANIMATION_GROUP_PARALLEL_DATA_GET(o, pd) \
+ Efl_Animation_Group_Parallel_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_GROUP_PARALLEL_CLASS)
+
+typedef struct _Efl_Animation_Group_Parallel_Data
+{
+} Efl_Animation_Group_Parallel_Data;
diff --git a/src/lib/evas/canvas/efl_animation_instance_group_parallel.c b/src/lib/evas/canvas/efl_animation_instance_group_parallel.c
new file mode 100644
index 0000000000..ec4ae258d4
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_instance_group_parallel.c
@@ -0,0 +1,112 @@
+#include "efl_animation_instance_group_parallel_private.h"
+
+EOLIAN static void
+_efl_animation_instance_group_parallel_efl_animation_instance_group_instance_add(Eo *eo_obj,
+ Efl_Animation_Instance_Group_Parallel_Data *pd EINA_UNUSED,
+ Efl_Animation_Instance *instance)
+{
+ EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_CHECK_OR_RETURN(eo_obj);
+
+ if (!instance) return;
+
+ efl_animation_instance_group_instance_add(efl_super(eo_obj, MY_CLASS),
+ instance);
+
+ /* Total duration is calculated in
+ * efl_animation_instance_total_duration_get() based on the current group
+ * animation instance list.
+ * Therefore, the calculated total duration should be set to update total
+ * duration. */
+ double total_duration =
+ efl_animation_instance_total_duration_get(eo_obj);
+ efl_animation_instance_total_duration_set(eo_obj, total_duration);
+}
+
+EOLIAN static void
+_efl_animation_instance_group_parallel_efl_animation_instance_group_instance_del(Eo *eo_obj,
+ Efl_Animation_Instance_Group_Parallel_Data *pd EINA_UNUSED,
+ Efl_Animation_Instance *instance)
+{
+ EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_CHECK_OR_RETURN(eo_obj);
+
+ if (!instance) return;
+
+ efl_animation_instance_group_instance_del(efl_super(eo_obj, MY_CLASS),
+ instance);
+
+ /* Total duration is calculated in
+ * efl_animation_instance_total_duration_get() based on the current group
+ * animation instance list.
+ * Therefore, the calculated total duration should be set to update total
+ * duration. */
+ double total_duration =
+ efl_animation_instance_total_duration_get(eo_obj);
+ efl_animation_instance_total_duration_set(eo_obj, total_duration);
+}
+
+EOLIAN static double
+_efl_animation_instance_group_parallel_efl_animation_instance_total_duration_get(Eo *eo_obj,
+ Efl_Animation_Instance_Group_Parallel_Data *pd EINA_UNUSED)
+{
+ EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_CHECK_OR_RETURN(eo_obj, 0.0);
+
+ Eina_List *instances =
+ efl_animation_instance_group_instances_get(eo_obj);
+ if (!instances) return 0.0;
+
+ double total_duration = 0.0;
+ Eina_List *l;
+ Efl_Animation *inst;
+ EINA_LIST_FOREACH(instances, l, inst)
+ {
+ double child_total_duration =
+ efl_animation_instance_total_duration_get(inst);
+ if (child_total_duration > total_duration)
+ total_duration = child_total_duration;
+ }
+ return total_duration;
+}
+
+EOLIAN static void
+_efl_animation_instance_group_parallel_efl_animation_instance_progress_set(Eo *eo_obj,
+ Efl_Animation_Instance_Group_Parallel_Data *pd EINA_UNUSED,
+ double progress)
+{
+ if ((progress < 0.0) || (progress > 1.0)) return;
+
+ Eina_List *instances = efl_animation_instance_group_instances_get(eo_obj);
+ if (!instances) return;
+
+ double group_total_duration =
+ efl_animation_instance_total_duration_get(eo_obj);
+
+ double elapsed_time = progress * group_total_duration;
+
+ Eina_List *l;
+ Efl_Animation_Instance *inst;
+ EINA_LIST_FOREACH(instances, l, inst)
+ {
+ double total_duration = efl_animation_instance_total_duration_get(inst);
+ double inst_progress;
+
+ if (total_duration == 0.0)
+ inst_progress = 1.0;
+ else
+ {
+ inst_progress = elapsed_time / total_duration;
+ if (inst_progress > 1.0)
+ inst_progress = 1.0;
+ }
+
+ efl_animation_instance_progress_set(inst, inst_progress);
+ }
+}
+
+/* Internal EO APIs */
+
+#define EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_EXTRA_OPS \
+ EFL_OBJECT_OP_FUNC(efl_animation_instance_group_instance_add, _efl_animation_instance_group_parallel_efl_animation_instance_group_instance_add), \
+ EFL_OBJECT_OP_FUNC(efl_animation_instance_group_instance_del, _efl_animation_instance_group_parallel_efl_animation_instance_group_instance_del), \
+ EFL_OBJECT_OP_FUNC(efl_animation_instance_total_duration_get, _efl_animation_instance_group_parallel_efl_animation_instance_total_duration_get)
+
+#include "efl_animation_instance_group_parallel.eo.c"
diff --git a/src/lib/evas/canvas/efl_animation_instance_group_parallel.eo b/src/lib/evas/canvas/efl_animation_instance_group_parallel.eo
new file mode 100644
index 0000000000..95ef9ac86c
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_instance_group_parallel.eo
@@ -0,0 +1,12 @@
+import efl_animation_types;
+
+class Efl.Animation.Instance.Group.Parallel (Efl.Animation.Instance.Group)
+{
+ [[Efl group parallel animation instance class]]
+ data: Efl_Animation_Instance_Group_Parallel_Data;
+ methods {
+ }
+ implements {
+ Efl.Animation.Instance.progress_set;
+ }
+}
diff --git a/src/lib/evas/canvas/efl_animation_instance_group_parallel_private.h b/src/lib/evas/canvas/efl_animation_instance_group_parallel_private.h
new file mode 100644
index 0000000000..d948e64f0f
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_instance_group_parallel_private.h
@@ -0,0 +1,25 @@
+#define EFL_ANIMATION_INSTANCE_PROTECTED
+
+#include "evas_common_private.h"
+
+#define MY_CLASS EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_CLASS
+#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)
+
+#define EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_CHECK_OR_RETURN(inst, ...) \
+ do { \
+ if (!inst) { \
+ CRI("Efl_Animation_Instance " # inst " is NULL!"); \
+ return __VA_ARGS__; \
+ } \
+ if (efl_animation_instance_is_deleted(inst)) { \
+ ERR("Efl_Animation_Instance " # inst " has already been deleted!"); \
+ return __VA_ARGS__; \
+ } \
+ } while (0)
+
+#define EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_DATA_GET(o, pd) \
+ Efl_Animation_Instance_Group_Parallel_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_CLASS)
+
+typedef struct _Efl_Animation_Instance_Group_Parallel_Data
+{
+} Efl_Animation_Instance_Group_Parallel_Data;