summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/edje/edje_calc.c275
-rw-r--r--src/lib/edje/edje_private.h1
2 files changed, 276 insertions, 0 deletions
diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c
index f213d85eef..898e0dabeb 100644
--- a/src/lib/edje/edje_calc.c
+++ b/src/lib/edje/edje_calc.c
@@ -26,6 +26,71 @@ static void _edje_part_recalc_single(Edje *ed, Edje_Rea
26#define EINA_COW_CALC_MAP_END(Calc, Write) \ 26#define EINA_COW_CALC_MAP_END(Calc, Write) \
27 EINA_COW_WRITE_END(_edje_calc_params_map_cow, Calc->map, Write); 27 EINA_COW_WRITE_END(_edje_calc_params_map_cow, Calc->map, Write);
28 28
29#ifdef BUILD_EDJE_FP
30
31#define TYPE_EPSILON FLT_EPSILON
32
33#else
34
35#define TYPE_EPSILON DBL_EPSILON
36
37#endif
38
39
40#define SET_QUATERNION(type) \
41 double norm; \
42 Eina_Quaternion quaternion; \
43 \
44 eina_quaternion_set(&quaternion, pd_##type->type.orientation.data[0], \
45 pd_##type->type.orientation.data[1], \
46 pd_##type->type.orientation.data[2], \
47 pd_##type->type.orientation.data[3]); \
48 \
49 norm = eina_quaternion_norm(&quaternion); \
50 \
51 if ((norm - 0.0) <= TYPE_EPSILON) \
52 ERR("%s %s", \
53 "{0, 0, 0, 0} quaternion gives rotation on non-zero angle", \
54 "around axis without orientation"); \
55 \
56 eina_quaternion_scale(&quaternion, &quaternion, 1/norm); \
57 \
58 eo_do(ep->node, \
59 evas_canvas3d_node_orientation_set(quaternion.x, quaternion.y, \
60 quaternion.z, quaternion.w));
61
62#define SET_LOOK_AT(type) \
63 eo_do(ep->node, \
64 evas_canvas3d_node_look_at_set(pd_##type->type.position.space, \
65 pd_##type->type.orientation.data[0], \
66 pd_##type->type.orientation.data[1], \
67 pd_##type->type.orientation.data[2], \
68 pd_##type->type.position.space, \
69 pd_##type->type.orientation.data[3], \
70 pd_##type->type.orientation.data[4], \
71 pd_##type->type.orientation.data[5]));
72
73#define SET_LOOK_TO(type) \
74 Edje_Real_Part *look_to; \
75 Evas_Real x, y ,z; \
76 look_to = ed->table_parts[pd_##type->type.orientation.look_to % ed->table_parts_size]; \
77 eo_do(look_to->node, \
78 evas_canvas3d_node_position_get(pd_##type->type.position.space, &x, &y, &z)); \
79 eo_do(ep->node, \
80 evas_canvas3d_node_look_at_set(pd_##type->type.position.space, x, y, z, \
81 pd_##type->type.position.space, \
82 pd_##type->type.orientation.data[3], \
83 pd_##type->type.orientation.data[4], \
84 pd_##type->type.orientation.data[5]));
85
86#define SET_ANGLE_AXIS(type) \
87 eo_do(ep->node, \
88 evas_canvas3d_node_orientation_angle_axis_set(pd_##type->type.orientation.data[0], \
89 pd_##type->type.orientation.data[1], \
90 pd_##type->type.orientation.data[2], \
91 pd_##type->type.orientation.data[3]));
92
93
29void 94void
30_edje_part_pos_set(Edje *ed, Edje_Real_Part *ep, int mode, FLOAT_T pos, FLOAT_T v1, FLOAT_T v2, FLOAT_T v3, FLOAT_T v4) 95_edje_part_pos_set(Edje *ed, Edje_Real_Part *ep, int mode, FLOAT_T pos, FLOAT_T v1, FLOAT_T v2, FLOAT_T v3, FLOAT_T v4)
31{ 96{
@@ -286,6 +351,9 @@ case EDJE_PART_TYPE_##Short: \
286 EDIT_ALLOC_POOL_RTL(BOX, Box, box); 351 EDIT_ALLOC_POOL_RTL(BOX, Box, box);
287 EDIT_ALLOC_POOL_RTL(TABLE, Table, table); 352 EDIT_ALLOC_POOL_RTL(TABLE, Table, table);
288 EDIT_ALLOC_POOL_RTL(EXTERNAL, External, external_params); 353 EDIT_ALLOC_POOL_RTL(EXTERNAL, External, external_params);
354 EDIT_ALLOC_POOL_RTL(CAMERA, Camera, camera);
355 EDIT_ALLOC_POOL_RTL(LIGHT, Light, light);
356 EDIT_ALLOC_POOL_RTL(MESH_NODE, Mesh_Node, mesh_node);
289 } 357 }
290 358
291 if (desc_rtl) 359 if (desc_rtl)
@@ -2479,6 +2547,9 @@ _edje_part_recalc_single(Edje *ed,
2479 case EDJE_PART_TYPE_SWALLOW: 2547 case EDJE_PART_TYPE_SWALLOW:
2480 case EDJE_PART_TYPE_GROUP: 2548 case EDJE_PART_TYPE_GROUP:
2481 case EDJE_PART_TYPE_PROXY: 2549 case EDJE_PART_TYPE_PROXY:
2550 case EDJE_PART_TYPE_MESH_NODE:
2551 case EDJE_PART_TYPE_LIGHT:
2552 case EDJE_PART_TYPE_CAMERA:
2482 break; 2553 break;
2483 2554
2484 case EDJE_PART_TYPE_GRADIENT: 2555 case EDJE_PART_TYPE_GRADIENT:
@@ -4077,6 +4148,210 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
4077 case EDJE_PART_TYPE_SPACER: 4148 case EDJE_PART_TYPE_SPACER:
4078 /* We really should do nothing on SPACER part */ 4149 /* We really should do nothing on SPACER part */
4079 break; 4150 break;
4151 case EDJE_PART_TYPE_CAMERA:
4152 {
4153 Evas_Canvas3D_Camera *camera = NULL;
4154 Edje_Part_Description_Camera *pd_camera;
4155
4156 pd_camera = (Edje_Part_Description_Camera*) ep->chosen_description;
4157 eo_do(ep->node, camera = evas_canvas3d_node_camera_get());
4158
4159 eo_do(camera,
4160 evas_canvas3d_camera_projection_perspective_set(pd_camera->camera.camera.fovy, pd_camera->camera.camera.aspect,
4161 pd_camera->camera.camera.frustum_near, pd_camera->camera.camera.frustum_far));
4162
4163 eo_do(ep->node,
4164 evas_canvas3d_node_position_set(pd_camera->camera.position.point.x, pd_camera->camera.position.point.y,
4165 pd_camera->camera.position.point.z));
4166 switch (pd_camera->camera.orientation.type)
4167 {
4168 case EVAS_CANVAS3D_NODE_ORIENTATION_TYPE_NONE:
4169 case EVAS_CANVAS3D_NODE_ORIENTATION_TYPE_QUATERNION:
4170 {
4171 SET_QUATERNION(camera)
4172 break;
4173 }
4174 case EVAS_CANVAS3D_NODE_ORIENTATION_TYPE_LOOK_AT:
4175 SET_LOOK_AT(camera)
4176 break;
4177 case EVAS_CANVAS3D_NODE_ORIENTATION_TYPE_LOOK_TO:
4178 {
4179 SET_LOOK_TO(camera)
4180 break;
4181 }
4182 case EVAS_CANVAS3D_NODE_ORIENTATION_TYPE_ANGLE_AXIS:
4183 SET_ANGLE_AXIS(camera)
4184 break;
4185 }
4186 break;
4187 }
4188 case EDJE_PART_TYPE_LIGHT:
4189 {
4190 Evas_Canvas3D_Light *light = NULL;
4191 Edje_Part_Description_Light *pd_light;
4192
4193 pd_light = (Edje_Part_Description_Light*) ep->chosen_description;
4194 eo_do(ep->node, light = evas_canvas3d_node_light_get());
4195
4196 eo_do(light,
4197 evas_canvas3d_light_ambient_set(pd_light->light.properties.ambient.r / 255, pd_light->light.properties.ambient.g / 255,
4198 pd_light->light.properties.ambient.b / 255, pd_light->light.properties.ambient.a / 255),
4199 evas_canvas3d_light_diffuse_set(pd_light->light.properties.diffuse.r / 255, pd_light->light.properties.diffuse.g / 255,
4200 pd_light->light.properties.diffuse.b / 255, pd_light->light.properties.diffuse.a / 255),
4201 evas_canvas3d_light_specular_set(pd_light->light.properties.specular.r / 255, pd_light->light.properties.specular.g / 255,
4202 pd_light->light.properties.specular.b / 255, pd_light->light.properties.specular.a / 255),
4203 evas_canvas3d_light_directional_set(EINA_TRUE));
4204
4205 eo_do(ep->node,
4206 evas_canvas3d_node_position_set(pd_light->light.position.point.x, pd_light->light.position.point.y,
4207 pd_light->light.position.point.z));
4208 switch (pd_light->light.orientation.type)
4209 {
4210 case EVAS_CANVAS3D_NODE_ORIENTATION_TYPE_NONE:
4211 case EVAS_CANVAS3D_NODE_ORIENTATION_TYPE_QUATERNION:
4212 {
4213 SET_QUATERNION(light);
4214 break;
4215 }
4216 case EVAS_CANVAS3D_NODE_ORIENTATION_TYPE_LOOK_AT:
4217 SET_LOOK_AT(light)
4218 break;
4219 case EVAS_CANVAS3D_NODE_ORIENTATION_TYPE_LOOK_TO:
4220 {
4221 SET_LOOK_TO(light)
4222 break;
4223 }
4224 case EVAS_CANVAS3D_NODE_ORIENTATION_TYPE_ANGLE_AXIS:
4225 SET_ANGLE_AXIS(light)
4226 break;
4227 }
4228 break;
4229 }
4230 case EDJE_PART_TYPE_MESH_NODE:
4231 {
4232 Evas_Canvas3D_Material *material = NULL;
4233 Evas_Canvas3D_Texture *texture = NULL;
4234 Evas_Canvas3D_Mesh *mesh = NULL;
4235 const char *proxy;
4236 Edje_Part_Description_Mesh_Node *pd_mesh_node;
4237 const Eina_List *meshes;
4238 const Eina_List *list;
4239
4240 eo_do(ep->node, meshes = evas_canvas3d_node_mesh_list_get());
4241
4242 EINA_LIST_FOREACH(meshes, list, mesh)
4243 {
4244 eo_do(mesh, material = evas_canvas3d_mesh_frame_material_get(0));
4245 eo_do(material, texture = evas_canvas3d_material_texture_get(EVAS_CANVAS3D_MATERIAL_DIFFUSE));
4246
4247 pd_mesh_node = (Edje_Part_Description_Mesh_Node*) ep->chosen_description;
4248
4249 eo_do(material,
4250 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_AMBIENT, EINA_TRUE),
4251 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_DIFFUSE, EINA_TRUE),
4252 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_SPECULAR, EINA_TRUE),
4253 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_NORMAL, pd_mesh_node->mesh_node.properties.normal),
4254 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_AMBIENT,
4255 pd_mesh_node->mesh_node.properties.ambient.r / 255,
4256 pd_mesh_node->mesh_node.properties.ambient.g / 255,
4257 pd_mesh_node->mesh_node.properties.ambient.b / 255,
4258 pd_mesh_node->mesh_node.properties.ambient.a / 255),
4259 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_DIFFUSE,
4260 pd_mesh_node->mesh_node.properties.diffuse.r / 255,
4261 pd_mesh_node->mesh_node.properties.diffuse.g / 255,
4262 pd_mesh_node->mesh_node.properties.diffuse.b / 255,
4263 pd_mesh_node->mesh_node.properties.diffuse.a / 255),
4264 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_SPECULAR,
4265 pd_mesh_node->mesh_node.properties.specular.r / 255,
4266 pd_mesh_node->mesh_node.properties.specular.g / 255,
4267 pd_mesh_node->mesh_node.properties.specular.b / 255,
4268 pd_mesh_node->mesh_node.properties.specular.a / 255),
4269 evas_canvas3d_material_shininess_set(pd_mesh_node->mesh_node.properties.shininess));
4270
4271 switch(pd_mesh_node->mesh_node.mesh.primitive)
4272 {
4273 case EVAS_CANVAS3D_MESH_PRIMITIVE_CUBE:
4274 {
4275 Eo *primitive = NULL;
4276
4277 eo_do(primitive,
4278 evas_canvas3d_primitive_form_set(EVAS_CANVAS3D_MESH_PRIMITIVE_CUBE));
4279
4280 eo_do(mesh,
4281 evas_canvas3d_mesh_from_primitive_set(0, primitive));
4282 break;
4283 }
4284 case EVAS_CANVAS3D_MESH_PRIMITIVE_SPHERE:
4285 {
4286 Eo *primitive = NULL;
4287
4288 eo_do(primitive,
4289 evas_canvas3d_primitive_form_set(EVAS_CANVAS3D_MESH_PRIMITIVE_SPHERE),
4290 evas_canvas3d_primitive_precision_set(20));
4291
4292 eo_do(mesh,
4293 evas_canvas3d_mesh_from_primitive_set(0, primitive));
4294 break;
4295 }
4296 default:
4297 break;
4298 }
4299
4300 if (pd_mesh_node->mesh_node.texture.need_texture && pd_mesh_node->mesh_node.texture.textured)
4301 {
4302 proxy = NULL;
4303
4304 eo_do(material,
4305 texture = evas_canvas3d_material_texture_get(EVAS_CANVAS3D_MATERIAL_DIFFUSE));
4306
4307 //proxy = _edje_image_name_find(ed, pd_mesh_node->mesh_node.texture.id);
4308 /*FIXME Conflict with function _edje_image_name_find (two places in edje_utils and edje_edit.c,
4309 temporary desicion need to clarify up to commit to phab*/
4310 proxy = ed->file->image_dir->entries[pd_mesh_node->mesh_node.texture.id].entry;
4311 if (proxy)
4312 {
4313 eo_do(texture,
4314 evas_canvas3d_texture_file_set(eina_stringshare_add(proxy), NULL),
4315 evas_canvas3d_texture_filter_set(pd_mesh_node->mesh_node.texture.filter1,
4316 pd_mesh_node->mesh_node.texture.filter2),
4317 evas_canvas3d_texture_wrap_set(pd_mesh_node->mesh_node.texture.wrap1,
4318 pd_mesh_node->mesh_node.texture.wrap2));
4319 }
4320 }
4321
4322 eo_do(mesh,
4323 evas_canvas3d_mesh_frame_material_set(0, material),
4324 evas_canvas3d_mesh_shade_mode_set(pd_mesh_node->mesh_node.properties.shade),
4325 evas_canvas3d_mesh_vertex_assembly_set(pd_mesh_node->mesh_node.mesh.assembly));
4326 eo_do(ep->node,
4327 evas_canvas3d_node_scale_set(ep->part->scale_3d.x, ep->part->scale_3d.y,
4328 ep->part->scale_3d.z),
4329 evas_canvas3d_node_position_set(pd_mesh_node->mesh_node.position.point.x,
4330 pd_mesh_node->mesh_node.position.point.y,
4331 pd_mesh_node->mesh_node.position.point.z));
4332 switch (pd_mesh_node->mesh_node.orientation.type)
4333 {
4334 case EVAS_CANVAS3D_NODE_ORIENTATION_TYPE_NONE:
4335 case EVAS_CANVAS3D_NODE_ORIENTATION_TYPE_QUATERNION:
4336 {
4337 SET_QUATERNION(mesh_node)
4338 break;
4339 }
4340 case EVAS_CANVAS3D_NODE_ORIENTATION_TYPE_LOOK_AT:
4341 SET_LOOK_AT(mesh_node)
4342 break;
4343 case EVAS_CANVAS3D_NODE_ORIENTATION_TYPE_LOOK_TO:
4344 {
4345 SET_LOOK_TO(mesh_node)
4346 break;
4347 }
4348 case EVAS_CANVAS3D_NODE_ORIENTATION_TYPE_ANGLE_AXIS:
4349 SET_ANGLE_AXIS(mesh_node)
4350 break;
4351 }
4352 }
4353 break;
4354 }
4080 } 4355 }
4081 4356
4082 /* Some object need special recalc. */ 4357 /* Some object need special recalc. */
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 91662e1834..fe8bc21f97 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -1823,6 +1823,7 @@ struct _Edje_Real_Part
1823 Edje_Part *part; // 4 1823 Edje_Part *part; // 4
1824 Evas_Object *object; // 4 1824 Evas_Object *object; // 4
1825 Evas_Object *nested_smart; // 4 1825 Evas_Object *nested_smart; // 4
1826 Eo *node; // 4
1826 Edje_Real_Part_Drag *drag; // 4 1827 Edje_Real_Part_Drag *drag; // 4
1827 Edje_Part_Description_Common *chosen_description; // 4 1828 Edje_Part_Description_Common *chosen_description; // 4
1828 // WITH EDJE_CALC_CACHE: 307 1829 // WITH EDJE_CALC_CACHE: 307