aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-08-01 19:04:42 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-08-01 19:11:39 +0900
commit1d0b500fa8ce93ac6cd9211abd35ea8972be74b2 (patch)
tree42aef01c896b1084f91a42b051b82741112d5b9b
parentecore_audio - save 232k of real RAM by dlopening depednecies (diff)
downloadefl-1d0b500fa8ce93ac6cd9211abd35ea8972be74b2.tar.gz
edje - reduce memory footrpint by dlopening ephysics on demand
this saves about another 80Kb or so in dirty pages by only loading ephysics when needed. This removed ephysics and bullet library dirty pages from the process space. this is another patch to address https://phab.enlightenment.org/T4227. @fix
-rw-r--r--configure.ac19
-rw-r--r--src/Makefile_Edje.am3
-rw-r--r--src/lib/edje/edje_calc.c112
-rw-r--r--src/lib/edje/edje_embryo.c48
-rw-r--r--src/lib/edje/edje_load.c37
-rw-r--r--src/lib/edje/edje_main.c137
-rw-r--r--src/lib/edje/edje_private.h79
-rw-r--r--src/lib/edje/edje_program.c103
-rw-r--r--src/lib/edje/edje_smart.c18
9 files changed, 419 insertions, 137 deletions
diff --git a/configure.ac b/configure.ac
index aba9f8cf13..493fd31094 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4901,19 +4901,24 @@ EFL_INTERNAL_DEPEND_PKG([EDJE], [emile])
EFL_INTERNAL_DEPEND_PKG([EDJE], [efreet])
EFL_INTERNAL_DEPEND_PKG([EDJE], [eio])
-EFL_OPTIONAL_INTERNAL_DEPEND_PKG([EDJE], [${want_physics}], [ephysics])
+if test "x${want_physics}" = "xyes" ; then
+ AC_DEFINE([HAVE_EPHYSICS], [1], [EPhysics Support])
+ EDJE_CFLAGS="-I\$(top_srcdir)/src/lib/ephysics ${EDJE_CFLAGS}"
+fi
+dnl EFL_OPTIONAL_INTERNAL_DEPEND_PKG([EDJE], [${want_physics}], [ephysics])
+
+if test "x${want_lua_old}" = "xyes"; then
+ EFL_CHECK_LUA_OLD([EDJE_LUA])
+else
+ PKG_CHECK_MODULES([EDJE_LUA], [luajit >= 2.0.0])
+fi
+
EFL_OPTIONAL_INTERNAL_DEPEND_PKG([EDJE], [${want_multisense}], [ecore-audio])
EFL_ADD_FEATURE([EDJE], [physics])
EFL_ADD_FEATURE([EDJE], [multisense])
EFL_ADD_FEATURE([EDJE], [lua-old])
-if test "${want_lua_old}" = "yes"; then
- EFL_CHECK_LUA_OLD([EDJE])
-else
- EFL_DEPEND_PKG([EDJE], [LUAJIT], [luajit >= 2.0.0])
-fi
-
EFL_ADD_LIBS([EDJE], [-lm])
EFL_EVAL_PKGS([EDJE])
diff --git a/src/Makefile_Edje.am b/src/Makefile_Edje.am
index f6dd2f7cfb..989df6d0d7 100644
--- a/src/Makefile_Edje.am
+++ b/src/Makefile_Edje.am
@@ -51,6 +51,7 @@ EDJE_COMMON_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
-DPACKAGE_DATA_DIR=\"$(datadir)/edje\" \
-DPACKAGE_BUILD_DIR=\"$(abs_top_builddir)\" \
-DPACKAGE_SRC_DIR=\"$(abs_top_srcdir)\" \
+@EDJE_LUA_CFLAGS@ \
@EDJE_CFLAGS@
installed_edjemainheadersdir = $(includedir)/edje-@VMAJ@
@@ -97,7 +98,7 @@ lib/edje/edje_containers.c
lib_edje_libedje_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl $(EDJE_COMMON_CPPFLAGS)
-lib_edje_libedje_la_LIBADD = @EDJE_LIBS@
+lib_edje_libedje_la_LIBADD = @EDJE_LIBS@ @EDJE_LUA_LIBS@
lib_edje_libedje_la_DEPENDENCIES = @EDJE_INTERNAL_LIBS@
lib_edje_libedje_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c
index e5f022d539..66b1cee4c0 100644
--- a/src/lib/edje/edje_calc.c
+++ b/src/lib/edje/edje_calc.c
@@ -3357,7 +3357,8 @@ static Eina_Bool
_edje_physics_world_geometry_check(EPhysics_World *world)
{
Evas_Coord w, h, d;
- ephysics_world_render_geometry_get(world, NULL, NULL, NULL, &w, &h, &d);
+ if (!EPH_LOAD()) return EINA_FALSE;
+ EPH_CALL(ephysics_world_render_geometry_get)(world, NULL, NULL, NULL, &w, &h, &d);
return w && h && d;
}
@@ -3365,14 +3366,17 @@ static void
_edje_physics_body_props_update(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *pf,
Eina_Bool pos_update)
{
- ephysics_body_linear_movement_enable_set(ep->body,
- pf->physics->mov_freedom.lin.x,
- pf->physics->mov_freedom.lin.y,
- pf->physics->mov_freedom.lin.z);
- ephysics_body_angular_movement_enable_set(ep->body,
- pf->physics->mov_freedom.ang.x,
- pf->physics->mov_freedom.ang.y,
- pf->physics->mov_freedom.ang.z);
+ if (!EPH_LOAD()) return;
+ EPH_CALL(ephysics_body_linear_movement_enable_set)
+ (ep->body,
+ pf->physics->mov_freedom.lin.x,
+ pf->physics->mov_freedom.lin.y,
+ pf->physics->mov_freedom.lin.z);
+ EPH_CALL(ephysics_body_angular_movement_enable_set)
+ (ep->body,
+ pf->physics->mov_freedom.ang.x,
+ pf->physics->mov_freedom.ang.y,
+ pf->physics->mov_freedom.ang.z);
/* Boundaries geometry and mass shouldn't be changed */
if (ep->part->physics_body < EDJE_PART_PHYSICS_BODY_BOUNDARY_TOP)
@@ -3381,62 +3385,65 @@ _edje_physics_body_props_update(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *
if (pos_update)
{
- ephysics_body_move(ep->body,
- ed->x + pf->final.x,
- ed->y + pf->final.y,
- pf->physics->z);
+ EPH_CALL(ephysics_body_move)
+ (ep->body,
+ ed->x + pf->final.x,
+ ed->y + pf->final.y,
+ pf->physics->z);
ep->x = pf->final.x;
ep->y = pf->final.y;
ep->w = pf->final.w;
ep->h = pf->final.h;
}
- ephysics_body_geometry_get(ep->body, &x, &y, &z, &w, &h, &d);
+ EPH_CALL(ephysics_body_geometry_get)(ep->body, &x, &y, &z, &w, &h, &d);
if ((d) && (d != pf->physics->depth))
- ephysics_body_resize(ep->body, w, h, pf->physics->depth);
+ EPH_CALL(ephysics_body_resize)(ep->body, w, h, pf->physics->depth);
if (z != pf->physics->z)
- ephysics_body_move(ep->body, x, y, pf->physics->z);
+ EPH_CALL(ephysics_body_move)(ep->body, x, y, pf->physics->z);
- ephysics_body_material_set(ep->body, pf->physics->material);
+ EPH_CALL(ephysics_body_material_set)(ep->body, pf->physics->material);
if (!pf->physics->material)
{
if (pf->physics->density)
- ephysics_body_density_set(ep->body, pf->physics->density);
+ EPH_CALL(ephysics_body_density_set)(ep->body, pf->physics->density);
else
- ephysics_body_mass_set(ep->body, pf->physics->mass);
+ EPH_CALL(ephysics_body_mass_set)(ep->body, pf->physics->mass);
}
if ((ep->part->physics_body == EDJE_PART_PHYSICS_BODY_SOFT_BOX) ||
(ep->part->physics_body == EDJE_PART_PHYSICS_BODY_SOFT_SPHERE) ||
(ep->part->physics_body == EDJE_PART_PHYSICS_BODY_SOFT_CYLINDER) ||
(ep->part->physics_body == EDJE_PART_PHYSICS_BODY_CLOTH))
- ephysics_body_soft_body_hardness_set(ep->body,
- pf->physics->hardness * 100);
+ EPH_CALL(ephysics_body_soft_body_hardness_set)
+ (ep->body, pf->physics->hardness * 100);
}
if (!pf->physics->material)
{
- ephysics_body_restitution_set(ep->body, pf->physics->restitution);
- ephysics_body_friction_set(ep->body, pf->physics->friction);
+ EPH_CALL(ephysics_body_restitution_set)(ep->body, pf->physics->restitution);
+ EPH_CALL(ephysics_body_friction_set)(ep->body, pf->physics->friction);
}
- ephysics_body_damping_set(ep->body, pf->physics->damping.linear,
- pf->physics->damping.angular);
- ephysics_body_sleeping_threshold_set(ep->body, pf->physics->sleep.linear,
- pf->physics->sleep.angular);
- ephysics_body_light_set(ep->body, pf->physics->light_on);
- ephysics_body_back_face_culling_set(ep->body, pf->physics->backcull);
+ EPH_CALL(ephysics_body_damping_set)(ep->body, pf->physics->damping.linear,
+ pf->physics->damping.angular);
+ EPH_CALL(ephysics_body_sleeping_threshold_set)(ep->body, pf->physics->sleep.linear,
+ pf->physics->sleep.angular);
+ EPH_CALL(ephysics_body_light_set)(ep->body, pf->physics->light_on);
+ EPH_CALL(ephysics_body_back_face_culling_set)(ep->body, pf->physics->backcull);
}
static void
_edje_physics_body_update_cb(void *data, EPhysics_Body *body, void *event_info EINA_UNUSED)
{
Edje_Real_Part *rp = data;
- Edje *ed = ephysics_body_data_get(body);
+ Edje *ed;
- ephysics_body_geometry_get(body, &(rp->x), &(rp->y), NULL,
- &(rp->w), &(rp->h), NULL);
- ephysics_body_evas_object_update(body);
+ if (!EPH_LOAD()) return;
+ ed = EPH_CALL(ephysics_body_data_get(body));
+ EPH_CALL(ephysics_body_geometry_get)(body, &(rp->x), &(rp->y), NULL,
+ &(rp->w), &(rp->h), NULL);
+ EPH_CALL(ephysics_body_evas_object_update)(body);
ed->dirty = EINA_TRUE;
}
@@ -3447,63 +3454,64 @@ _edje_physics_body_add(Edje *ed, Edje_Real_Part *rp, EPhysics_World *world)
Edje_Physics_Face *pface;
Eina_List *l;
+ if (!EPH_LOAD()) return;
switch (rp->part->physics_body)
{
case EDJE_PART_PHYSICS_BODY_RIGID_BOX:
- rp->body = ephysics_body_box_add(world);
+ rp->body = EPH_CALL(ephysics_body_box_add)(world);
break;
case EDJE_PART_PHYSICS_BODY_RIGID_SPHERE:
- rp->body = ephysics_body_sphere_add(world);
+ rp->body = EPH_CALL(ephysics_body_sphere_add)(world);
break;
case EDJE_PART_PHYSICS_BODY_RIGID_CYLINDER:
- rp->body = ephysics_body_cylinder_add(world);
+ rp->body = EPH_CALL(ephysics_body_cylinder_add)(world);
break;
case EDJE_PART_PHYSICS_BODY_SOFT_BOX:
- rp->body = ephysics_body_soft_box_add(world);
+ rp->body = EPH_CALL(ephysics_body_soft_box_add)(world);
break;
case EDJE_PART_PHYSICS_BODY_SOFT_SPHERE:
- rp->body = ephysics_body_soft_sphere_add(world, 0);
+ rp->body = EPH_CALL(ephysics_body_soft_sphere_add)(world, 0);
break;
case EDJE_PART_PHYSICS_BODY_SOFT_CYLINDER:
- rp->body = ephysics_body_soft_cylinder_add(world);
+ rp->body = EPH_CALL(ephysics_body_soft_cylinder_add)(world);
break;
case EDJE_PART_PHYSICS_BODY_CLOTH:
- rp->body = ephysics_body_cloth_add(world, 0, 0);
+ rp->body = EPH_CALL(ephysics_body_cloth_add)(world, 0, 0);
break;
case EDJE_PART_PHYSICS_BODY_BOUNDARY_TOP:
- rp->body = ephysics_body_top_boundary_add(world);
+ rp->body = EPH_CALL(ephysics_body_top_boundary_add)(world);
resize = EINA_FALSE;
break;
case EDJE_PART_PHYSICS_BODY_BOUNDARY_BOTTOM:
- rp->body = ephysics_body_bottom_boundary_add(world);
+ rp->body = EPH_CALL(ephysics_body_bottom_boundary_add)(world);
resize = EINA_FALSE;
break;
case EDJE_PART_PHYSICS_BODY_BOUNDARY_RIGHT:
- rp->body = ephysics_body_right_boundary_add(world);
+ rp->body = EPH_CALL(ephysics_body_right_boundary_add)(world);
resize = EINA_FALSE;
break;
case EDJE_PART_PHYSICS_BODY_BOUNDARY_LEFT:
- rp->body = ephysics_body_left_boundary_add(world);
+ rp->body = EPH_CALL(ephysics_body_left_boundary_add)(world);
resize = EINA_FALSE;
break;
case EDJE_PART_PHYSICS_BODY_BOUNDARY_FRONT:
- rp->body = ephysics_body_front_boundary_add(world);
+ rp->body = EPH_CALL(ephysics_body_front_boundary_add)(world);
resize = EINA_FALSE;
break;
case EDJE_PART_PHYSICS_BODY_BOUNDARY_BACK:
- rp->body = ephysics_body_back_boundary_add(world);
+ rp->body = EPH_CALL(ephysics_body_back_boundary_add)(world);
resize = EINA_FALSE;
break;
@@ -3525,15 +3533,15 @@ _edje_physics_body_add(Edje *ed, Edje_Real_Part *rp, EPhysics_World *world)
edje_object_file_set(edje_obj, ed->path, pface->source);
evas_object_resize(edje_obj, 1, 1);
- ephysics_body_face_evas_object_set(rp->body, pface->type,
- edje_obj, EINA_FALSE);
+ EPH_CALL(ephysics_body_face_evas_object_set)(rp->body, pface->type,
+ edje_obj, EINA_FALSE);
rp->body_faces = eina_list_append(rp->body_faces, edje_obj);
}
- ephysics_body_evas_object_set(rp->body, rp->object, resize);
- ephysics_body_event_callback_add(rp->body, EPHYSICS_CALLBACK_BODY_UPDATE,
- _edje_physics_body_update_cb, rp);
- ephysics_body_data_set(rp->body, ed);
+ EPH_CALL(ephysics_body_evas_object_set)(rp->body, rp->object, resize);
+ EPH_CALL(ephysics_body_event_callback_add)(rp->body, EPHYSICS_CALLBACK_BODY_UPDATE,
+ _edje_physics_body_update_cb, rp);
+ EPH_CALL(ephysics_body_data_set)(rp->body, ed);
}
#endif
diff --git a/src/lib/edje/edje_embryo.c b/src/lib/edje/edje_embryo.c
index a246499ff4..f7eeab68c9 100644
--- a/src/lib/edje/edje_embryo.c
+++ b/src/lib/edje/edje_embryo.c
@@ -4197,32 +4197,36 @@ _edje_embryo_fn_physics_components_get(Embryo_Program *ep, Embryo_Cell *params,
static Embryo_Cell
_edje_embryo_fn_physics_impulse(Embryo_Program *ep, Embryo_Cell *params)
{
+ if (!EPH_LOAD()) return 0;
return _edje_embryo_fn_physics_components_set(
- ep, params, ephysics_body_central_impulse_apply);
+ ep, params, EPH_CALL(ephysics_body_central_impulse_apply));
}
/* physics_torque_impulse(part_id, Float:x, Float:y, Float:z) */
static Embryo_Cell
_edje_embryo_fn_physics_torque_impulse(Embryo_Program *ep, Embryo_Cell *params)
{
+ if (!EPH_LOAD()) return 0;
return _edje_embryo_fn_physics_components_set(
- ep, params, ephysics_body_torque_impulse_apply);
+ ep, params, EPH_CALL(ephysics_body_torque_impulse_apply));
}
/* physics_force(part_id, Float:x, Float:y, Float:z) */
static Embryo_Cell
_edje_embryo_fn_physics_force(Embryo_Program *ep, Embryo_Cell *params)
{
+ if (!EPH_LOAD()) return 0;
return _edje_embryo_fn_physics_components_set(
- ep, params, ephysics_body_central_force_apply);
+ ep, params, EPH_CALL(ephysics_body_central_force_apply));
}
/* physics_torque(part_id, Float:x, Float:y, Float:z) */
static Embryo_Cell
_edje_embryo_fn_physics_torque(Embryo_Program *ep, Embryo_Cell *params)
{
+ if (!EPH_LOAD()) return 0;
return _edje_embryo_fn_physics_components_set(
- ep, params, ephysics_body_torque_apply);
+ ep, params, EPH_CALL(ephysics_body_torque_apply));
}
/* physics_clear_forces(part_id) */
@@ -4235,13 +4239,14 @@ _edje_embryo_fn_physics_clear_forces(Embryo_Program *ep, Embryo_Cell *params)
CHKPARAM(1);
+ if (!EPH_LOAD()) return 0;
ed = embryo_program_data_get(ep);
part_id = params[1];
if (part_id < 0) return 0;
rp = ed->table_parts[part_id % ed->table_parts_size];
if ((rp) && (rp->body))
- ephysics_body_forces_clear(rp->body);
+ EPH_CALL(ephysics_body_forces_clear)(rp->body);
return 0;
}
@@ -4250,48 +4255,54 @@ _edje_embryo_fn_physics_clear_forces(Embryo_Program *ep, Embryo_Cell *params)
static Embryo_Cell
_edje_embryo_fn_physics_get_forces(Embryo_Program *ep, Embryo_Cell *params)
{
+ if (!EPH_LOAD()) return 0;
return _edje_embryo_fn_physics_components_get(
- ep, params, ephysics_body_forces_get);
+ ep, params, EPH_CALL(ephysics_body_forces_get));
}
/* physics_get_torques(part_id, &Float:x, &Float:y, &Float:z) */
static Embryo_Cell
_edje_embryo_fn_physics_get_torques(Embryo_Program *ep, Embryo_Cell *params)
{
+ if (!EPH_LOAD()) return 0;
return _edje_embryo_fn_physics_components_get(
- ep, params, ephysics_body_torques_get);
+ ep, params, EPH_CALL(ephysics_body_torques_get));
}
/* physics_set_velocity(part_id, Float:x, Float:y, Float:z) */
static Embryo_Cell
_edje_embryo_fn_physics_set_velocity(Embryo_Program *ep, Embryo_Cell *params)
{
+ if (!EPH_LOAD()) return 0;
return _edje_embryo_fn_physics_components_set(
- ep, params, ephysics_body_linear_velocity_set);
+ ep, params, EPH_CALL(ephysics_body_linear_velocity_set));
}
/* physics_get_velocity(part_id, &Float:x, &Float:y, &Float:z) */
static Embryo_Cell
_edje_embryo_fn_physics_get_velocity(Embryo_Program *ep, Embryo_Cell *params)
{
+ if (!EPH_LOAD()) return 0;
return _edje_embryo_fn_physics_components_get(
- ep, params, ephysics_body_linear_velocity_get);
+ ep, params, EPH_CALL(ephysics_body_linear_velocity_get));
}
/* physics_set_ang_velocity(part_id, Float:x, Float:y, Float:z) */
static Embryo_Cell
_edje_embryo_fn_physics_set_ang_velocity(Embryo_Program *ep, Embryo_Cell *params)
{
+ if (!EPH_LOAD()) return 0;
return _edje_embryo_fn_physics_components_set(
- ep, params, ephysics_body_angular_velocity_set);
+ ep, params, EPH_CALL(ephysics_body_angular_velocity_set));
}
/* physics_get_ang_velocity(part_id, &Float:x, &Float:y, &Float:z) */
static Embryo_Cell
_edje_embryo_fn_physics_get_ang_velocity(Embryo_Program *ep, Embryo_Cell *params)
{
+ if (!EPH_LOAD()) return 0;
return _edje_embryo_fn_physics_components_get(
- ep, params, ephysics_body_angular_velocity_get);
+ ep, params, EPH_CALL(ephysics_body_angular_velocity_get));
}
/* physics_stop(part_id) */
@@ -4304,13 +4315,14 @@ _edje_embryo_fn_physics_stop(Embryo_Program *ep, Embryo_Cell *params)
CHKPARAM(1);
+ if (!EPH_LOAD()) return 0;
ed = embryo_program_data_get(ep);
part_id = params[1];
if (part_id < 0) return 0;
rp = ed->table_parts[part_id % ed->table_parts_size];
if ((rp) && (rp->body))
- ephysics_body_stop(rp->body);
+ EPH_CALL(ephysics_body_stop)(rp->body);
return 0;
}
@@ -4325,6 +4337,7 @@ _edje_embryo_fn_physics_set_rotation(Embryo_Program *ep, Embryo_Cell *params)
CHKPARAM(5);
+ if (!EPH_LOAD()) return 0;
ed = embryo_program_data_get(ep);
part_id = params[1];
if (part_id < 0) return 0;
@@ -4340,9 +4353,9 @@ _edje_embryo_fn_physics_set_rotation(Embryo_Program *ep, Embryo_Cell *params)
y = (double)EMBRYO_CELL_TO_FLOAT(params[4]);
z = (double)EMBRYO_CELL_TO_FLOAT(params[5]);
- ephysics_quaternion_set(&quat, x, y, z, w);
- ephysics_quaternion_normalize(&quat);
- ephysics_body_rotation_set(rp->body, &quat);
+ EPH_CALL(ephysics_quaternion_set)(&quat, x, y, z, w);
+ EPH_CALL(ephysics_quaternion_normalize)(&quat);
+ EPH_CALL(ephysics_body_rotation_set)(rp->body, &quat);
}
return 0;
@@ -4358,6 +4371,7 @@ _edje_embryo_fn_physics_get_rotation(Embryo_Program *ep, Embryo_Cell *params)
CHKPARAM(5);
+ if (!EPH_LOAD()) return 0;
ed = embryo_program_data_get(ep);
part_id = params[1];
if (part_id < 0) return 0;
@@ -4368,8 +4382,8 @@ _edje_embryo_fn_physics_get_rotation(Embryo_Program *ep, Embryo_Cell *params)
EPhysics_Quaternion quat;
double w, x, y, z;
- ephysics_body_rotation_get(rp->body, &quat);
- ephysics_quaternion_get(&quat, &x, &y, &z, &w);
+ EPH_CALL(ephysics_body_rotation_get)(rp->body, &quat);
+ EPH_CALL(ephysics_quaternion_get)(&quat, &x, &y, &z, &w);
SETFLOAT(w, params[2]);
SETFLOAT(x, params[3]);
diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c
index 89683a5cf1..0d43704d8e 100644
--- a/src/lib/edje/edje_load.c
+++ b/src/lib/edje/edje_load.c
@@ -503,9 +503,8 @@ static void
_edje_physics_world_update_cb(void *data, EPhysics_World *world EINA_UNUSED, void *event_info EINA_UNUSED)
{
Edje *edje = data;
- _edje_recalc_do(edje);
+ if (EPH_LOAD()) _edje_recalc_do(edje);
}
-
#endif
int
@@ -546,10 +545,13 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
#ifdef HAVE_EPHYSICS
/* clear physics world / shutdown ephysics */
- if ((ed->collection) && (ed->collection->physics_enabled))
+ if ((ed->collection) && (ed->collection->physics_enabled) && (ed->world))
{
- ephysics_world_del(ed->world);
- ephysics_shutdown();
+ if (EPH_LOAD())
+ {
+ EPH_CALL(ephysics_world_del)(ed->world);
+ EPH_CALL(ephysics_shutdown)();
+ }
}
#endif
@@ -606,17 +608,20 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
if (ed->collection->physics_enabled)
#ifdef HAVE_EPHYSICS
{
- ephysics_init();
- ed->world = ephysics_world_new();
- ephysics_world_event_callback_add(
- ed->world, EPHYSICS_CALLBACK_WORLD_UPDATE,
- _edje_physics_world_update_cb, ed);
- ephysics_world_rate_set(ed->world,
- ed->collection->physics.world.rate);
- ephysics_world_gravity_set(
- ed->world, ed->collection->physics.world.gravity.x,
- ed->collection->physics.world.gravity.y,
- ed->collection->physics.world.gravity.z);
+ if (EPH_LOAD())
+ {
+ EPH_CALL(ephysics_init)();
+ ed->world = EPH_CALL(ephysics_world_new)();
+ EPH_CALL(ephysics_world_event_callback_add)
+ (ed->world, EPHYSICS_CALLBACK_WORLD_UPDATE,
+ _edje_physics_world_update_cb, ed);
+ EPH_CALL(ephysics_world_rate_set)
+ (ed->world, ed->collection->physics.world.rate);
+ EPH_CALL(ephysics_world_gravity_set)
+ (ed->world, ed->collection->physics.world.gravity.x,
+ ed->collection->physics.world.gravity.y,
+ ed->collection->physics.world.gravity.z);
+ }
}
#else
ERR("Edje compiled without support to physics.");
diff --git a/src/lib/edje/edje_main.c b/src/lib/edje/edje_main.c
index 13809e6a2c..ee7ecd2deb 100644
--- a/src/lib/edje/edje_main.c
+++ b/src/lib/edje/edje_main.c
@@ -21,6 +21,11 @@ static const Edje_Calc_Params_Physics default_calc_physics = {
0.0, 0.0, 0.0, 0.0, 0.0, { 0.0, 0.0 }, { 0.0, 0.0 }, 0, 0, { { 0, 0, 0 }, { 0, 0, 0 } }, 0, 0, 0, 0
};
+#ifdef HAVE_EPHYSICS
+static void _edje_ephysics_clear(void);
+#endif
+
+
/*============================================================================*
* API *
*============================================================================*/
@@ -199,6 +204,10 @@ _edje_shutdown_core(void)
ecore_imf_shutdown();
#endif
+#ifdef HAVE_EPHYSICS
+ _edje_ephysics_clear();
+#endif
+
efreet_shutdown();
evas_shutdown();
eet_shutdown();
@@ -315,3 +324,131 @@ _edje_need_imf(void)
#endif
}
+#ifdef HAVE_EPHYSICS
+Edje_Ephysics *_edje_ephysics = NULL;
+
+Eina_Bool
+_edje_ephysics_load(void)
+{
+ if (_edje_ephysics)
+ {
+ if (!_edje_ephysics->mod)
+ {
+ ERR("Cannot find libpulse!");
+ return EINA_FALSE;
+ }
+ return EINA_TRUE;
+ }
+ ERR("PHYYYYYYYYYYYYYYZIKS");
+ _edje_ephysics = calloc(1, sizeof(Edje_Ephysics));
+ if (!_edje_ephysics) return EINA_FALSE;
+# define LOAD(x) \
+ if (!_edje_ephysics->mod) { \
+ if ((_edje_ephysics->mod = eina_module_new(x))) { \
+ if (!eina_module_load(_edje_ephysics->mod)) { \
+ eina_module_free(_edje_ephysics->mod); \
+ _edje_ephysics->mod = NULL; \
+ } \
+ } \
+ }
+# if defined(_WIN32) || defined(__CYGWIN__)
+ LOAD("libephysics-1.dll");
+ LOAD("libephysics.dll");
+# elif defined(__APPLE__) && defined(__MACH__)
+ LOAD("libephysics.1.dylib");
+ LOAD("libephysics.1.so");
+ LOAD("libephysics.so.1");
+# else
+ LOAD("libephysics.so.1");
+# endif
+# undef LOAD
+ if (!_edje_ephysics->mod) return EINA_FALSE;
+# define SYM(x) \
+ if (!(_edje_ephysics->x = eina_module_symbol_get(_edje_ephysics->mod, #x))) { \
+ ERR("libpulse - cannot find %s", #x); \
+ goto err; \
+ }
+ SYM(ephysics_init);
+ SYM(ephysics_shutdown);
+ SYM(ephysics_world_new);
+ SYM(ephysics_world_del);
+ SYM(ephysics_world_event_callback_add)
+ SYM(ephysics_world_rate_set)
+ SYM(ephysics_world_gravity_set)
+ SYM(ephysics_world_render_geometry_set);
+ SYM(ephysics_world_render_geometry_get);
+ SYM(ephysics_quaternion_set)
+ SYM(ephysics_quaternion_get)
+ SYM(ephysics_quaternion_normalize)
+ SYM(ephysics_body_box_add)
+ SYM(ephysics_body_sphere_add)
+ SYM(ephysics_body_cylinder_add)
+ SYM(ephysics_body_soft_box_add)
+ SYM(ephysics_body_soft_sphere_add)
+ SYM(ephysics_body_soft_cylinder_add)
+ SYM(ephysics_body_cloth_add)
+ SYM(ephysics_body_top_boundary_add)
+ SYM(ephysics_body_bottom_boundary_add)
+ SYM(ephysics_body_right_boundary_add)
+ SYM(ephysics_body_left_boundary_add)
+ SYM(ephysics_body_front_boundary_add)
+ SYM(ephysics_body_back_boundary_add)
+ SYM(ephysics_body_central_impulse_apply)
+ SYM(ephysics_body_torque_impulse_apply)
+ SYM(ephysics_body_central_force_apply)
+ SYM(ephysics_body_torque_apply)
+ SYM(ephysics_body_forces_clear)
+ SYM(ephysics_body_linear_velocity_set)
+ SYM(ephysics_body_angular_velocity_set)
+ SYM(ephysics_body_stop)
+ SYM(ephysics_body_rotation_set)
+ SYM(ephysics_body_forces_get)
+ SYM(ephysics_body_torques_get)
+ SYM(ephysics_body_linear_velocity_get)
+ SYM(ephysics_body_angular_velocity_get)
+ SYM(ephysics_body_linear_movement_enable_set)
+ SYM(ephysics_body_angular_movement_enable_set)
+ SYM(ephysics_body_move)
+ SYM(ephysics_body_geometry_get)
+ SYM(ephysics_body_resize)
+ SYM(ephysics_body_material_set)
+ SYM(ephysics_body_density_set)
+ SYM(ephysics_body_mass_set)
+ SYM(ephysics_body_soft_body_hardness_set)
+ SYM(ephysics_body_restitution_set)
+ SYM(ephysics_body_friction_set)
+ SYM(ephysics_body_damping_set)
+ SYM(ephysics_body_sleeping_threshold_set)
+ SYM(ephysics_body_light_set)
+ SYM(ephysics_body_back_face_culling_set)
+ SYM(ephysics_body_evas_object_update)
+ SYM(ephysics_body_face_evas_object_set)
+ SYM(ephysics_body_evas_object_set)
+ SYM(ephysics_body_event_callback_add)
+ SYM(ephysics_body_data_set)
+ SYM(ephysics_body_data_get)
+ SYM(ephysics_body_rotation_get)
+#undef SYM
+ return EINA_TRUE;
+err:
+ if (_edje_ephysics->mod)
+ {
+ eina_module_free(_edje_ephysics->mod);
+ _edje_ephysics->mod = NULL;
+ }
+ return EINA_FALSE;
+}
+
+static void
+_edje_ephysics_clear(void)
+{
+ if (_edje_ephysics)
+ {
+ if (_edje_ephysics->mod)
+ eina_module_free(_edje_ephysics->mod);
+ free(_edje_ephysics);
+ _edje_ephysics = NULL;
+ }
+}
+#endif
+
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index fd53254723..daf304114e 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -3279,6 +3279,85 @@ Edje_Vector_Data * _edje_ref_vector_data(Edje *ed, int svg_id);
EAPI void _edje_svg_node_free(Svg_Node *node);
+#ifdef HAVE_EPHYSICS
+Eina_Bool _edje_ephysics_load(void);
+
+typedef struct _Edje_Ephysics Edje_Ephysics;
+
+struct _Edje_Ephysics
+{
+ Eina_Module *mod;
+
+ int (*ephysics_init) (void);
+ int (*ephysics_shutdown) (void);
+ EPhysics_World *(*ephysics_world_new) (void);
+ void (*ephysics_world_del) (EPhysics_World *world);
+ void (*ephysics_world_event_callback_add) (EPhysics_World *world, EPhysics_Callback_World_Type type, EPhysics_World_Event_Cb func, const void *data);
+ void (*ephysics_world_rate_set) (EPhysics_World *world, double rate);
+ void (*ephysics_world_gravity_set) (EPhysics_World *world, double gx, double gy, double gz);
+ void (*ephysics_world_render_geometry_set) (EPhysics_World *world, Evas_Coord x, Evas_Coord y, Evas_Coord z, Evas_Coord w, Evas_Coord h, Evas_Coord d);
+ void (*ephysics_world_render_geometry_get) (const EPhysics_World *world, Evas_Coord *x, Evas_Coord *y, Evas_Coord *z, Evas_Coord *w, Evas_Coord *h, Evas_Coord *d);
+ void (*ephysics_quaternion_set) (EPhysics_Quaternion *quat, double x, double y, double z, double w);
+ void (*ephysics_quaternion_get) (const EPhysics_Quaternion *quat, double *x, double *y, double *z, double *w);
+ void (*ephysics_quaternion_normalize) (EPhysics_Quaternion *quat);
+ EPhysics_Body *(*ephysics_body_box_add) (EPhysics_World *world);
+ EPhysics_Body *(*ephysics_body_sphere_add) (EPhysics_World *world);
+ EPhysics_Body *(*ephysics_body_cylinder_add) (EPhysics_World *world);
+ EPhysics_Body *(*ephysics_body_soft_box_add) (EPhysics_World *world);
+ EPhysics_Body *(*ephysics_body_soft_sphere_add) (EPhysics_World *world, int granularity);
+ EPhysics_Body *(*ephysics_body_soft_cylinder_add) (EPhysics_World *world);
+ EPhysics_Body *(*ephysics_body_cloth_add) (EPhysics_World *world, unsigned short rows, unsigned short columns);
+ EPhysics_Body *(*ephysics_body_top_boundary_add) (EPhysics_World *world);
+ EPhysics_Body *(*ephysics_body_bottom_boundary_add) (EPhysics_World *world);
+ EPhysics_Body *(*ephysics_body_right_boundary_add) (EPhysics_World *world);
+ EPhysics_Body *(*ephysics_body_left_boundary_add) (EPhysics_World *world);
+ EPhysics_Body *(*ephysics_body_front_boundary_add) (EPhysics_World *world);
+ EPhysics_Body *(*ephysics_body_back_boundary_add) (EPhysics_World *world);
+ void (*ephysics_body_central_impulse_apply) (EPhysics_Body *body, double x, double y, double z);
+ void (*ephysics_body_torque_impulse_apply) (EPhysics_Body *body, double pitch, double yaw, double roll);
+ void (*ephysics_body_central_force_apply) (EPhysics_Body *body, double x, double y, double z);
+ void (*ephysics_body_torque_apply) (EPhysics_Body *body, double torque_x, double torque_y, double torque_z);
+ void (*ephysics_body_forces_clear) (EPhysics_Body *body);
+ void (*ephysics_body_linear_velocity_set) (EPhysics_Body *body, double x, double y, double z);
+ void (*ephysics_body_angular_velocity_set) (EPhysics_Body *body, double x, double y, double z);
+ void (*ephysics_body_stop) (EPhysics_Body *body);
+ void (*ephysics_body_rotation_set) (EPhysics_Body *body, EPhysics_Quaternion *quat);
+ void (*ephysics_body_forces_get) (const EPhysics_Body *body, double *x, double *y, double *z);
+ void (*ephysics_body_torques_get) (const EPhysics_Body *body, double *x, double *y, double *z);
+ void (*ephysics_body_linear_velocity_get) (const EPhysics_Body *body, double *x, double *y, double *z);
+ void (*ephysics_body_angular_velocity_get) (const EPhysics_Body *body, double *x, double *y, double *z);
+ void (*ephysics_body_linear_movement_enable_set) (EPhysics_Body *body, Eina_Bool enable_x, Eina_Bool enable_y, Eina_Bool enable_z);
+ void (*ephysics_body_angular_movement_enable_set) (EPhysics_Body *body, Eina_Bool enable_x, Eina_Bool enable_y, Eina_Bool enable_z);
+ void (*ephysics_body_move) (EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord z);
+ void (*ephysics_body_geometry_get) (const EPhysics_Body *body, Evas_Coord *x, Evas_Coord *y, Evas_Coord *z, Evas_Coord *w, Evas_Coord *h, Evas_Coord *d);
+ void (*ephysics_body_resize) (EPhysics_Body *body, Evas_Coord w, Evas_Coord h, Evas_Coord d);
+ void (*ephysics_body_material_set) (EPhysics_Body *body, EPhysics_Body_Material material);
+ void (*ephysics_body_density_set) (EPhysics_Body *body, double density);
+ void (*ephysics_body_mass_set) (EPhysics_Body *body, double mass);
+ void (*ephysics_body_soft_body_hardness_set) (EPhysics_Body *body, double hardness);
+ void (*ephysics_body_restitution_set) (EPhysics_Body *body, double restitution);
+ void (*ephysics_body_friction_set) (EPhysics_Body *body, double friction);
+ void (*ephysics_body_damping_set) (EPhysics_Body *body, double linear_damping, double angular_damping);
+ void (*ephysics_body_sleeping_threshold_set) (EPhysics_Body *body, double linear_threshold, double angular_threshold);
+ void (*ephysics_body_light_set) (EPhysics_Body *body, Eina_Bool enable);
+ void (*ephysics_body_back_face_culling_set) (EPhysics_Body *body, Eina_Bool enable);
+ void (*ephysics_body_evas_object_update) (EPhysics_Body *body);
+ void (*ephysics_body_face_evas_object_set) (EPhysics_Body *body, EPhysics_Body_Face face, Evas_Object *evas_obj, Eina_Bool use_obj_pos);
+ void (*ephysics_body_evas_object_set) (EPhysics_Body *body, Evas_Object *evas_obj, Eina_Bool use_obj_pos);
+ void (*ephysics_body_event_callback_add) (EPhysics_Body *body, EPhysics_Callback_Body_Type type, EPhysics_Body_Event_Cb func, const void *data);
+ void (*ephysics_body_data_set) (EPhysics_Body *body, void *data);
+ void *(*ephysics_body_data_get) (const EPhysics_Body *body);
+ EPhysics_Quaternion *(*ephysics_body_rotation_get) (const EPhysics_Body *body, EPhysics_Quaternion *rotation);
+};
+
+extern Edje_Ephysics *_edje_ephysics;
+#define EPH_LOAD() _edje_ephysics_load()
+#define EPH_CALL(x) _edje_ephysics->x
+
+#endif
+
+
+
#ifdef HAVE_LIBREMIX
#include <remix/remix.h>
#endif
diff --git a/src/lib/edje/edje_program.c b/src/lib/edje/edje_program.c
index 99ac484388..3aa1a76343 100644
--- a/src/lib/edje/edje_program.c
+++ b/src/lib/edje/edje_program.c
@@ -1074,79 +1074,106 @@ low_mem_current:
#ifdef HAVE_EPHYSICS
case EDJE_ACTION_TYPE_PHYSICS_IMPULSE:
- if (!_edje_physics_action_set(ed, pr, ephysics_body_central_impulse_apply))
- goto break_prog;
+ if (EPH_LOAD())
+ {
+ if (!_edje_physics_action_set(ed, pr, EPH_CALL(ephysics_body_central_impulse_apply)))
+ goto break_prog;
+ }
break;
case EDJE_ACTION_TYPE_PHYSICS_TORQUE_IMPULSE:
- if (!_edje_physics_action_set(ed, pr, ephysics_body_torque_impulse_apply))
- goto break_prog;
+ if (EPH_LOAD())
+ {
+ if (!_edje_physics_action_set(ed, pr, EPH_CALL(ephysics_body_torque_impulse_apply)))
+ goto break_prog;
+ }
break;
case EDJE_ACTION_TYPE_PHYSICS_FORCE:
- if (!_edje_physics_action_set(ed, pr, ephysics_body_central_force_apply))
- goto break_prog;
+ if (EPH_LOAD())
+ {
+ if (!_edje_physics_action_set(ed, pr, EPH_CALL(ephysics_body_central_force_apply)))
+ goto break_prog;
+ }
break;
case EDJE_ACTION_TYPE_PHYSICS_TORQUE:
- if (!_edje_physics_action_set(ed, pr, ephysics_body_torque_apply))
- goto break_prog;
+ if (EPH_LOAD())
+ {
+ if (!_edje_physics_action_set(ed, pr, EPH_CALL(ephysics_body_torque_apply)))
+ goto break_prog;
+ }
break;
case EDJE_ACTION_TYPE_PHYSICS_FORCES_CLEAR:
- if (_edje_block_break(ed))
- goto break_prog;
- EINA_LIST_FOREACH(pr->targets, l, pt)
+ if (EPH_LOAD())
{
- if (pt->id >= 0)
+ if (_edje_block_break(ed))
+ goto break_prog;
+ EINA_LIST_FOREACH(pr->targets, l, pt)
{
- rp = ed->table_parts[pt->id % ed->table_parts_size];
- if ((rp) && (rp->body))
- ephysics_body_forces_clear(rp->body);
+ if (pt->id >= 0)
+ {
+ rp = ed->table_parts[pt->id % ed->table_parts_size];
+ if ((rp) && (rp->body))
+ EPH_CALL(ephysics_body_forces_clear)(rp->body);
+ }
}
}
break;
case EDJE_ACTION_TYPE_PHYSICS_VEL_SET:
- if (!_edje_physics_action_set(ed, pr, ephysics_body_linear_velocity_set))
- goto break_prog;
+ if (EPH_LOAD())
+ {
+ if (!_edje_physics_action_set(ed, pr, EPH_CALL(ephysics_body_linear_velocity_set)))
+ goto break_prog;
+ }
break;
case EDJE_ACTION_TYPE_PHYSICS_ANG_VEL_SET:
- if (!_edje_physics_action_set(ed, pr, ephysics_body_angular_velocity_set))
- goto break_prog;
+ if (EPH_LOAD())
+ {
+ if (!_edje_physics_action_set(ed, pr, EPH_CALL(ephysics_body_angular_velocity_set)))
+ goto break_prog;
+ }
break;
case EDJE_ACTION_TYPE_PHYSICS_STOP:
- if (_edje_block_break(ed))
- goto break_prog;
- EINA_LIST_FOREACH(pr->targets, l, pt)
+ if (EPH_LOAD())
{
- if (pt->id >= 0)
+ if (_edje_block_break(ed))
+ goto break_prog;
+ EINA_LIST_FOREACH(pr->targets, l, pt)
{
- rp = ed->table_parts[pt->id % ed->table_parts_size];
- if ((rp) && (rp->body))
- ephysics_body_stop(rp->body);
+ if (pt->id >= 0)
+ {
+ rp = ed->table_parts[pt->id % ed->table_parts_size];
+ if ((rp) && (rp->body))
+ EPH_CALL(ephysics_body_stop)(rp->body);
+ }
}
}
break;
case EDJE_ACTION_TYPE_PHYSICS_ROT_SET:
- if (_edje_block_break(ed))
- goto break_prog;
- EINA_LIST_FOREACH(pr->targets, l, pt)
+ if (EPH_LOAD())
{
- if (pt->id >= 0)
+ if (_edje_block_break(ed))
+ goto break_prog;
+ EINA_LIST_FOREACH(pr->targets, l, pt)
{
- rp = ed->table_parts[pt->id % ed->table_parts_size];
- if ((rp) && (rp->body))
+ if (pt->id >= 0)
{
- EPhysics_Quaternion quat;
- ephysics_quaternion_set(&quat, pr->physics.x,
- pr->physics.y, pr->physics.z,
- pr->physics.w);
- ephysics_quaternion_normalize(&quat);
- ephysics_body_rotation_set(rp->body, &quat);
+ rp = ed->table_parts[pt->id % ed->table_parts_size];
+ if ((rp) && (rp->body))
+ {
+ EPhysics_Quaternion quat;
+ EPH_CALL(ephysics_quaternion_set)(&quat, pr->physics.x,
+ pr->physics.y, pr->physics.z,
+ pr->physics.w);
+ EPH_CALL(ephysics_quaternion_normalize)(&quat);
+ EPH_CALL(ephysics_body_rotation_set)(rp->body, &quat);
+ }
}
}
}
diff --git a/src/lib/edje/edje_smart.c b/src/lib/edje/edje_smart.c
index dff5823973..03fda4c419 100644
--- a/src/lib/edje/edje_smart.c
+++ b/src/lib/edje/edje_smart.c
@@ -156,10 +156,13 @@ _edje_object_efl_canvas_group_group_del(Eo *obj, Edje *ed)
if (_edje_lua_script_only(ed)) _edje_lua_script_only_shutdown(ed);
#ifdef HAVE_EPHYSICS
/* clear physics world / shutdown ephysics */
- if ((ed->collection) && (ed->collection->physics_enabled))
+ if ((ed->collection) && (ed->collection->physics_enabled) && (ed->world))
{
- ephysics_world_del(ed->world);
- ephysics_shutdown();
+ if (EPH_LOAD())
+ {
+ EPH_CALL(ephysics_world_del)(ed->world);
+ EPH_CALL(ephysics_shutdown)();
+ }
}
#endif
if (ed->persp) edje_object_perspective_set(obj, NULL);
@@ -272,9 +275,12 @@ _edje_object_efl_canvas_group_group_resize(Eo *obj EINA_UNUSED, Edje *ed, Evas_C
ed->h = h;
#ifdef HAVE_EPHYSICS
if ((ed->collection) && (ed->world))
- ephysics_world_render_geometry_set(
- ed->world, ed->x, ed->y, ed->collection->physics.world.z,
- ed->w, ed->h, ed->collection->physics.world.depth);
+ {
+ if (EPH_LOAD())
+ EPH_CALL(ephysics_world_render_geometry_set)
+ (ed->world, ed->x, ed->y, ed->collection->physics.world.z,
+ ed->w, ed->h, ed->collection->physics.world.depth);
+ }
#endif
#ifdef EDJE_CALC_CACHE
ed->all_part_change = EINA_TRUE;