map support in edje - first cut, missing features like back-face culling.
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 16 Feb 2010 16:20:15 +0000 (16:20 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 16 Feb 2010 16:20:15 +0000 (16:20 +0000)
also no dependency tracking etc. etc.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/edje@46216 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/bin/edje_cc_handlers.c
src/lib/Edje.h
src/lib/edje_calc.c
src/lib/edje_data.c
src/lib/edje_private.h

index 03ed35d..28583bf 100644 (file)
@@ -201,6 +201,15 @@ static void st_collections_group_parts_part_description_box_min(void);
 static void st_collections_group_parts_part_description_table_homogeneous(void);
 static void st_collections_group_parts_part_description_table_align(void);
 static void st_collections_group_parts_part_description_table_padding(void);
+static void st_collections_group_parts_part_description_map_perspective(void);
+static void st_collections_group_parts_part_description_map_light(void);
+static void st_collections_group_parts_part_description_map_rotation_center(void);
+static void st_collections_group_parts_part_description_map_rotation_x(void);
+static void st_collections_group_parts_part_description_map_rotation_y(void);
+static void st_collections_group_parts_part_description_map_rotation_z(void);
+static void st_collections_group_parts_part_description_map_on(void);
+static void st_collections_group_parts_part_description_perspective_zplane(void);
+static void st_collections_group_parts_part_description_perspective_focal(void);
 static void st_collections_group_parts_part_api(void);
 
 /* external part parameters */
@@ -413,6 +422,15 @@ New_Statement_Handler statement_handlers[] =
      {"collections.group.parts.part.description.table.homogeneous", st_collections_group_parts_part_description_table_homogeneous},
      {"collections.group.parts.part.description.table.align", st_collections_group_parts_part_description_table_align},
      {"collections.group.parts.part.description.table.padding", st_collections_group_parts_part_description_table_padding},
+     {"collections.group.parts.part.description.map.perspective", st_collections_group_parts_part_description_map_perspective},
+     {"collections.group.parts.part.description.map.light", st_collections_group_parts_part_description_map_light},
+     {"collections.group.parts.part.description.map.rotation.center", st_collections_group_parts_part_description_map_rotation_center},
+     {"collections.group.parts.part.description.map.rotation.x", st_collections_group_parts_part_description_map_rotation_x},
+     {"collections.group.parts.part.description.map.rotation.y", st_collections_group_parts_part_description_map_rotation_y},
+     {"collections.group.parts.part.description.map.rotation.z", st_collections_group_parts_part_description_map_rotation_z},
+     {"collections.group.parts.part.description.map.on", st_collections_group_parts_part_description_map_on},
+     {"collections.group.parts.part.description.perspective.zplane", st_collections_group_parts_part_description_perspective_zplane},
+     {"collections.group.parts.part.description.perspective.focal", st_collections_group_parts_part_description_perspective_focal},
      {"collections.group.parts.part.description.params.int", st_collections_group_parts_part_description_params_int},
      {"collections.group.parts.part.description.params.double", st_collections_group_parts_part_description_params_double},
      {"collections.group.parts.part.description.params.string", st_collections_group_parts_part_description_params_string},
@@ -590,6 +608,9 @@ New_Object_Handler object_handlers[] =
      {"collections.group.parts.part.description.gradient.rel2", NULL},
      {"collections.group.parts.part.description.box", NULL},
      {"collections.group.parts.part.description.table", NULL},
+     {"collections.group.parts.part.description.map", NULL},
+     {"collections.group.parts.part.description.map.rotation", NULL},
+     {"collections.group.parts.part.description.perspective", NULL},
      {"collections.group.parts.part.description.params", NULL},
      {"collections.group.parts.part.description.color_classes", NULL}, /* dup */
      {"collections.group.parts.part.description.color_classes.color_class", ob_color_class}, /* dup */
@@ -3064,6 +3085,15 @@ ob_collections_group_parts_part_description(void)
    ed->table.align.y = FROM_DOUBLE(0.5);
    ed->table.padding.x = 0;
    ed->table.padding.y = 0;
+   ed->map.id_persp = -1;
+   ed->map.id_light = -1;
+   ed->map.rot.id_center = -1;
+   ed->map.rot.x = FROM_DOUBLE(0.0);
+   ed->map.rot.y = FROM_DOUBLE(0.0);
+   ed->map.rot.z = FROM_DOUBLE(0.0);
+   ed->map.on = 0;
+   ed->persp.zplane = 0;
+   ed->persp.focal = 1000;
    ed->external_params = NULL;
 }
 
@@ -5588,6 +5618,177 @@ static void st_collections_group_parts_part_description_table_padding(void)
 }
 
 static void
+st_collections_group_parts_part_description_map_perspective(void)
+{
+   Edje_Part_Collection *pc;
+   Edje_Part *ep;
+   Edje_Part_Description *ed;
+
+   check_arg_count(1);
+   
+   pc = eina_list_data_get(eina_list_last(edje_collections));
+   ep = eina_list_data_get(eina_list_last(pc->parts));
+   
+   ed = ep->default_desc;
+   if (ep->other_desc) ed = eina_list_data_get(eina_list_last(ep->other_desc));
+     {
+       char *name;
+
+       name = parse_str(0);
+       data_queue_part_lookup(pc, name, &(ed->map.id_persp));
+       free(name);
+     }
+}
+
+static void
+st_collections_group_parts_part_description_map_light(void)
+{
+   Edje_Part_Collection *pc;
+   Edje_Part *ep;
+   Edje_Part_Description *ed;
+
+   check_arg_count(1);
+   
+   pc = eina_list_data_get(eina_list_last(edje_collections));
+   ep = eina_list_data_get(eina_list_last(pc->parts));
+   
+   ed = ep->default_desc;
+   if (ep->other_desc) ed = eina_list_data_get(eina_list_last(ep->other_desc));
+     {
+       char *name;
+
+       name = parse_str(0);
+       data_queue_part_lookup(pc, name, &(ed->map.id_light));
+       free(name);
+     }
+}
+
+static void
+st_collections_group_parts_part_description_map_rotation_center(void)
+{
+   Edje_Part_Collection *pc;
+   Edje_Part *ep;
+   Edje_Part_Description *ed;
+
+   check_arg_count(1);
+   
+   pc = eina_list_data_get(eina_list_last(edje_collections));
+   ep = eina_list_data_get(eina_list_last(pc->parts));
+   
+   ed = ep->default_desc;
+   if (ep->other_desc) ed = eina_list_data_get(eina_list_last(ep->other_desc));
+     {
+       char *name;
+
+       name = parse_str(0);
+       data_queue_part_lookup(pc, name, &(ed->map.rot.id_center));
+       free(name);
+     }
+}
+
+static void
+st_collections_group_parts_part_description_map_rotation_x(void)
+{
+   Edje_Part_Collection *pc;
+   Edje_Part *ep;
+   Edje_Part_Description *ed;
+
+   check_arg_count(1);
+   
+   pc = eina_list_data_get(eina_list_last(edje_collections));
+   ep = eina_list_data_get(eina_list_last(pc->parts));
+   
+   ed = ep->default_desc;
+   if (ep->other_desc) ed = eina_list_data_get(eina_list_last(ep->other_desc));
+   ed->map.rot.x = FROM_DOUBLE(parse_float(0));
+}
+
+static void
+st_collections_group_parts_part_description_map_rotation_y(void)
+{
+   Edje_Part_Collection *pc;
+   Edje_Part *ep;
+   Edje_Part_Description *ed;
+
+   check_arg_count(1);
+   
+   pc = eina_list_data_get(eina_list_last(edje_collections));
+   ep = eina_list_data_get(eina_list_last(pc->parts));
+   
+   ed = ep->default_desc;
+   if (ep->other_desc) ed = eina_list_data_get(eina_list_last(ep->other_desc));
+   ed->map.rot.y = FROM_DOUBLE(parse_float(0));
+}
+
+static void
+st_collections_group_parts_part_description_map_rotation_z(void)
+{
+   Edje_Part_Collection *pc;
+   Edje_Part *ep;
+   Edje_Part_Description *ed;
+
+   check_arg_count(1);
+   
+   pc = eina_list_data_get(eina_list_last(edje_collections));
+   ep = eina_list_data_get(eina_list_last(pc->parts));
+   
+   ed = ep->default_desc;
+   if (ep->other_desc) ed = eina_list_data_get(eina_list_last(ep->other_desc));
+   ed->map.rot.z = FROM_DOUBLE(parse_float(0));
+}
+
+static void
+st_collections_group_parts_part_description_map_on(void)
+{
+   Edje_Part_Collection *pc;
+   Edje_Part *ep;
+   Edje_Part_Description *ed;
+
+   check_arg_count(1);
+   
+   pc = eina_list_data_get(eina_list_last(edje_collections));
+   ep = eina_list_data_get(eina_list_last(pc->parts));
+   
+   ed = ep->default_desc;
+   if (ep->other_desc) ed = eina_list_data_get(eina_list_last(ep->other_desc));
+   ed->map.on = parse_bool(0);
+}
+
+static void
+st_collections_group_parts_part_description_perspective_zplane(void)
+{
+   Edje_Part_Collection *pc;
+   Edje_Part *ep;
+   Edje_Part_Description *ed;
+
+   check_arg_count(1);
+   
+   pc = eina_list_data_get(eina_list_last(edje_collections));
+   ep = eina_list_data_get(eina_list_last(pc->parts));
+   
+   ed = ep->default_desc;
+   if (ep->other_desc) ed = eina_list_data_get(eina_list_last(ep->other_desc));
+   ed->persp.zplane = parse_int(0);
+}
+
+static void
+st_collections_group_parts_part_description_perspective_focal(void)
+{
+   Edje_Part_Collection *pc;
+   Edje_Part *ep;
+   Edje_Part_Description *ed;
+
+   check_arg_count(1);
+   
+   pc = eina_list_data_get(eina_list_last(edje_collections));
+   ep = eina_list_data_get(eina_list_last(pc->parts));
+   
+   ed = ep->default_desc;
+   if (ep->other_desc) ed = eina_list_data_get(eina_list_last(ep->other_desc));
+   ed->persp.focal = parse_int_range(0, 1, 0x7fffffff);
+}
+
+static void
 _st_collections_group_parts_part_description_params(Edje_External_Param_Type type)
 {
    Edje_Part_Collection *pc;
index 030625f..70864d9 100644 (file)
@@ -514,28 +514,38 @@ extern "C" {
    EAPI void         edje_message_signal_process        (void);
 
    /* edje_external.c */
-  EAPI Eina_Bool edje_external_type_register(const char *type_name, const Edje_External_Type *type_info);
-  EAPI Eina_Bool edje_external_type_unregister(const char *type_name);
-
-  EAPI void      edje_external_type_array_register(const Edje_External_Type_Info *array);
-  EAPI void      edje_external_type_array_unregister(const Edje_External_Type_Info *array);
-
-  EAPI unsigned int edje_external_type_abi_version_get(void) EINA_CONST;
-
-
-  EAPI Eina_Iterator *edje_external_iterator_get(void);
-  EAPI Edje_External_Param *edje_external_param_find(const Eina_List *params, const char *key);
-  EAPI Eina_Bool edje_external_param_int_get(const Eina_List *params, const char *key, int *ret);
-  EAPI Eina_Bool edje_external_param_double_get(const Eina_List *params, const char *key, double *ret);
-  EAPI Eina_Bool edje_external_param_string_get(const Eina_List *params, const char *key, const char **ret);
-  EAPI Eina_Bool edje_external_param_bool_get(const Eina_List *params, const char *key, Eina_Bool *ret);
-  EAPI const Edje_External_Param_Info *edje_external_param_info_get(const char *type_name);
-
-  /* edje_module.c */
-  EAPI Eina_Bool edje_module_load(const char *module);
-  EAPI const Eina_List *edje_available_modules_get(void);
-
-
+   EAPI Eina_Bool edje_external_type_register(const char *type_name, const Edje_External_Type *type_info);
+   EAPI Eina_Bool edje_external_type_unregister(const char *type_name);
+   
+   EAPI void      edje_external_type_array_register(const Edje_External_Type_Info *array);
+   EAPI void      edje_external_type_array_unregister(const Edje_External_Type_Info *array);
+   
+   EAPI unsigned int edje_external_type_abi_version_get(void) EINA_CONST;
+   
+   
+   EAPI Eina_Iterator *edje_external_iterator_get(void);
+   EAPI Edje_External_Param *edje_external_param_find(const Eina_List *params, const char *key);
+   EAPI Eina_Bool edje_external_param_int_get(const Eina_List *params, const char *key, int *ret);
+   EAPI Eina_Bool edje_external_param_double_get(const Eina_List *params, const char *key, double *ret);
+   EAPI Eina_Bool edje_external_param_string_get(const Eina_List *params, const char *key, const char **ret);
+   EAPI Eina_Bool edje_external_param_bool_get(const Eina_List *params, const char *key, Eina_Bool *ret);
+   EAPI const Edje_External_Param_Info *edje_external_param_info_get(const char *type_name);
+   
+   /* edje_module.c */
+   EAPI Eina_Bool edje_module_load(const char *module);
+   EAPI const Eina_List *edje_available_modules_get(void);
+
+   /* perspective info for maps inside edje objects */
+#if 1 // WORKING ONಈIT! these will work later. first perspectivg within 1 object
+   typedef struct _Edje_Perspective Edje_Perspective;
+   
+   EAPI Edje_Perspective       *edje_perspective_new       (Evas *e);
+   EAPI void                    edje_perspective_free      (Edje_Perspective *ps);
+   EAPI void                    edje_perspective_set       (Edje_Perspective *ps, Evas_Coord px, Evas_Coord py, Evas_Coord z0, Evas_Coord foc);
+   EAPI void                    edje_object_perspective_set(Evas_Object *obj, Edje_Perspective *persp);
+   EAPI const Edje_Perspective *edje_object_perspective_get(Evas_Object *obj);
+#endif
+   
 #ifdef __cplusplus
 }
 #endif
index 1402355..54cb206 100644 (file)
@@ -1927,6 +1927,8 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags)
      }
    if (!ed->calc_only)
      {
+        Evas_Object *mo;
+        
        /* Common move, resize and color_set for all part. */
        switch (ep->part->type)
          {
@@ -2010,9 +2012,112 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags)
                  evas_object_resize(ep->swallowed_object, pf->w, pf->h);
                  evas_object_show(ep->swallowed_object);
               }
-            else
-              evas_object_hide(ep->swallowed_object);
+            else evas_object_hide(ep->swallowed_object);
+             mo = ep->swallowed_object;
          }
+        else mo = ep->object;
+        if (chosen_desc->map.on)
+          {
+             Evas_Map *map;
+             Evas_Coord cx, cy, px, py, zplane, foc, lx, ly, lz;
+             double rx, ry, rz;
+             int lr, lg, lb, lar, lag, lab;
+
+             map = evas_map_new(4);
+             evas_map_util_points_populate_from_geometry
+               (map, ed->x + pf->x, ed->y + pf->y, pf->w, pf->h, 0);
+             
+             cx = ed->x + pf->x + (pf->w / 2);
+             cy = ed->y + pf->y + (pf->h / 2);
+             if ((chosen_desc->map.rot.id_center >= 0) &&
+                 (chosen_desc->map.rot.id_center != ep->part->id))
+               {
+                  Edje_Real_Part *ep2 =
+                    ed->table_parts[chosen_desc->map.rot.id_center % 
+                                    ed->table_parts_size];
+                  if (ep2)
+                    {
+                       if (!ep2->calculated)
+                         _edje_part_recalc(ed, ep2, flags);
+                       cx = ed->x + ep2->x + (ep2->w / 2);
+                       cy = ed->y + ep2->y + (ep2->h / 2);
+                    }
+               }
+             if ((ep->param2) && (ep->description_pos != ZERO))
+               {
+                  rx = TO_DOUBLE(ep->param1.description->map.rot.x +
+                                 SCALE(ep->description_pos, 
+                                       SUB(ep->param2->description->map.rot.x,
+                                           ep->param1.description->map.rot.x)));
+                  ry = TO_DOUBLE(ep->param1.description->map.rot.y +
+                                 SCALE(ep->description_pos, 
+                                       SUB(ep->param2->description->map.rot.y,
+                                           ep->param1.description->map.rot.y)));
+                  rz = TO_DOUBLE(ep->param1.description->map.rot.z +
+                                 SCALE(ep->description_pos, 
+                                       SUB(ep->param2->description->map.rot.z,
+                                           ep->param1.description->map.rot.z)));
+               }
+             else
+               {
+                  rx = TO_DOUBLE(ep->param1.description->map.rot.x);
+                  ry = TO_DOUBLE(ep->param1.description->map.rot.y);
+                  rz = TO_DOUBLE(ep->param1.description->map.rot.z);
+               }
+             evas_map_util_3d_rotate(map, rx, ry, rz, cx, cy, 0);
+             if ((chosen_desc->map.id_light >= 0) &&
+                 (chosen_desc->map.id_light != ep->part->id))
+               {
+                  Edje_Real_Part *ep2 =
+                    ed->table_parts[chosen_desc->map.id_light %
+                                    ed->table_parts_size];
+                  if (ep2)
+                    {
+                       if (!ep2->calculated)
+                         _edje_part_recalc(ed, ep2, flags);
+                       lx = ed->x + ep2->x + (ep2->w / 2);
+                       ly = ed->y + ep2->y + (ep2->h / 2);
+                       lz = ep2->param1.description->persp.zplane;
+                       lr = ep2->param1.description->color.r;
+                       lg = ep2->param1.description->color.g;
+                       lb = ep2->param1.description->color.b;
+                       lar = ep2->param1.description->color2.r;
+                       lag = ep2->param1.description->color2.g;
+                       lab = ep2->param1.description->color2.b;
+                       evas_map_util_3d_lighting(map, lx, ly, lz,
+                                                 lr, lg, lb, lar, lag, lab);
+                    }
+               }
+             px = ed->x + (ed->w / 2);
+             py = ed->y + (ed->h / 2);
+             zplane = 0;
+             foc = 1000;
+             if ((chosen_desc->map.id_persp >= 0) &&
+                 (chosen_desc->map.id_persp != ep->part->id))
+               {
+                  Edje_Real_Part *ep2 =
+                    ed->table_parts[chosen_desc->map.id_persp %
+                                    ed->table_parts_size];
+                  if (ep2)
+                    {
+                       if (!ep2->calculated)
+                         _edje_part_recalc(ed, ep2, flags);
+                       px = ed->x + ep2->x + (ep2->w / 2);
+                       py = ed->y + ep2->y + (ep2->h / 2);
+                       zplane = ep2->param1.description->persp.zplane;
+                       foc = ep2->param1.description->persp.focal;
+                    }
+                  evas_map_util_3d_perspective(map, px, py, zplane, foc);
+               }
+             evas_object_map_set(mo, map);
+             evas_object_map_enable_set(mo, 1);
+             evas_map_free(map);
+          }
+        else
+          {
+             evas_object_map_enable_set(mo, 0);
+             evas_object_map_set(mo, NULL);
+          }
      }
 
    ep->x = pf->x;
index 41d9c14..5e17003 100644 (file)
@@ -349,6 +349,15 @@ _edje_edd_init(void)
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "table.align.y", table.align.y, EDJE_T_FLOAT);
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "table.padding.x", table.padding.x, EET_T_INT);
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "table.padding.y", table.padding.y, EET_T_INT);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "map.id_persp", map.id_persp, EET_T_INT);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "map.id_light", map.id_light, EET_T_INT);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "map.rot.id_center", map.rot.id_center, EET_T_INT);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "map.rot.x", map.rot.x, EDJE_T_FLOAT);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "map.rot.y", map.rot.y, EDJE_T_FLOAT);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "map.rot.z", map.rot.z, EDJE_T_FLOAT);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "map.on", map.on, EET_T_UCHAR);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "persp.zplane", persp.zplane, EET_T_INT);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "persp.focal", persp.focal, EET_T_INT);
    EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_part_description, Edje_Part_Description, "external_params", external_params, _edje_edd_edje_external_param);
 
    EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Pack_Element);
index 2e6b414..c631b56 100644 (file)
@@ -125,6 +125,14 @@ EAPI extern int _edje_default_log_dom ;
  * ? all unsafe calls that may result in callbacks must be marked and dealt with
  */
 
+struct _Edje_Perspective
+{
+   Evas       *e;
+   Evas_Coord  px, py;
+   Evas_Coord  z0, foc;
+   Eina_List  *users;
+};
+
 struct _Edje_Position_Scale
 {
    FLOAT_T x, y;
@@ -656,17 +664,20 @@ struct _Edje_Part_Description
       } padding;
    } table;
    
-#if 0
-   // // // // //
    struct {
+      int id_persp;
+      int id_light;
       struct {
-         double ax, ay, az;
+         int id_center;
+         FLOAT_T x, y, z;
       } rot;
-      // FIXME: center point is another part id
-      // FIXME: perspective should other part or global value/obj
+      unsigned char on;
    } map;
-   // // // // //
-#endif
+   
+   struct {
+      int zplane;
+      int focal;
+   } persp;
    
    Edje_Color color, color2, color3;  /* color for rect or text, shadow etc. */
    Eina_List *external_params; /* parameters for external objects */
@@ -831,7 +842,7 @@ struct _Edje_Calc_Params
       } text; // 36
    } type; // 40
    unsigned char    visible : 1;
-   unsigned char    smooth : 1; // 4
+   unsigned char    smooth : 1; // 1
 }; // 96
 
 struct _Edje_Real_Part_State
@@ -928,9 +939,9 @@ struct _Edje_Real_Part
    unsigned char             calculated; // 1
    unsigned char             calculating; // 1
 
-   unsigned char             still_in   : 1; // 2
+   unsigned char             still_in   : 1; // 1
 #ifdef EDJE_CALC_CACHE
-   unsigned char             invalidate : 1;
+   unsigned char             invalidate : 1; // 0
 #endif
 }; //  260
 // WITH EDJE_CALC_CACHE: 400
@@ -1057,7 +1068,6 @@ struct _Edje_Var
    unsigned char type;
 };
 
-
 typedef enum _Edje_Queue
 {
    EDJE_QUEUE_APP,