edje: reuse existing index instead of a direct pointer (-30KB).
authorCedric Bail <cedric.bail@samsung.com>
Mon, 8 Apr 2013 01:39:04 +0000 (10:39 +0900)
committerCedric Bail <cedric.bail@samsung.com>
Mon, 8 Apr 2013 03:16:22 +0000 (12:16 +0900)
This one does account for the fact that we always read relative
information even when only computing a part of it.

src/lib/edje/edje_calc.c
src/lib/edje/edje_edit.c
src/lib/edje/edje_embryo.c
src/lib/edje/edje_load.c
src/lib/edje/edje_private.h

index b19bfb3..7b309e7 100644 (file)
@@ -495,22 +495,12 @@ _edje_real_part_image_set(Edje *ed, Edje_Real_Part *ep, FLOAT_T pos)
 }
 
 static void
-_edje_real_part_rel_to_apply(Edje *ed, Edje_Real_Part *ep, Edje_Real_Part_State *state)
+_edje_real_part_rel_to_apply(Edje *ed EINA_UNUSED,
+                            Edje_Real_Part *ep,
+                            Edje_Real_Part_State *state)
 {
-   state->rel1_to_x = state->rel1_to_y = NULL;
-   state->rel2_to_x = state->rel2_to_y = NULL;
-
    if (state->description)
      {
-        if (state->description->rel1.id_x >= 0)
-          state->rel1_to_x = ed->table_parts[state->description->rel1.id_x % ed->table_parts_size];
-        if (state->description->rel1.id_y >= 0)
-          state->rel1_to_y = ed->table_parts[state->description->rel1.id_y % ed->table_parts_size];
-        if (state->description->rel2.id_x >= 0)
-          state->rel2_to_x = ed->table_parts[state->description->rel2.id_x % ed->table_parts_size];
-        if (state->description->rel2.id_y >= 0)
-          state->rel2_to_y = ed->table_parts[state->description->rel2.id_y % ed->table_parts_size];
-
         if (ep->part->type == EDJE_PART_TYPE_EXTERNAL)
           {
              Edje_Part_Description_External *external;
@@ -2735,6 +2725,11 @@ _edje_physics_body_add(Edje *edje, Edje_Real_Part *rp, EPhysics_World *world)
 }
 #endif
 
+#define Rel1X 0
+#define Rel1Y 1
+#define Rel2X 2 
+#define Rel2Y 3 
+
 void
 _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *state)
 {
@@ -2755,6 +2750,8 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
    Edje_Real_Part *center[2] = { NULL, NULL };
    Edje_Real_Part *light[2] = { NULL, NULL };
    Edje_Real_Part *persp[2] = { NULL, NULL };
+   Edje_Real_Part *rp1[4] = { NULL, NULL, NULL, NULL };
+   Edje_Real_Part *rp2[4] = { NULL, NULL, NULL, NULL };
    Edje_Calc_Params *p1, *pf;
    Edje_Part_Description_Common *chosen_desc;
    Edje_Real_Part *confine_to = NULL;
@@ -2832,39 +2829,60 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
      return ;
 #endif
 
+   if (ep->param1.description->rel1.id_x >= 0)
+     rp1[Rel1X] = ed->table_parts[ep->param1.description->rel1.id_x];
+   if (ep->param1.description->rel2.id_x >= 0)
+     rp1[Rel2X] = ed->table_parts[ep->param1.description->rel2.id_x];
+   if (ep->param1.description->rel1.id_y >= 0)
+     rp1[Rel1Y] = ed->table_parts[ep->param1.description->rel1.id_y];
+   if (ep->param1.description->rel2.id_y >= 0)
+     rp1[Rel2Y] = ed->table_parts[ep->param1.description->rel2.id_y];
+
+   if (ep->param2)
+     {
+        if (ep->param2->description->rel1.id_x >= 0)
+          rp2[Rel1X] = ed->table_parts[ep->param2->description->rel1.id_x];
+        if (ep->param2->description->rel2.id_x >= 0)
+          rp2[Rel2X] = ed->table_parts[ep->param2->description->rel2.id_x];
+        if (ep->param2->description->rel1.id_y >= 0)
+          rp2[Rel1Y] = ed->table_parts[ep->param2->description->rel1.id_y];
+        if (ep->param2->description->rel2.id_y >= 0)
+          rp2[Rel2Y] = ed->table_parts[ep->param2->description->rel2.id_y];
+     }
+
    if (flags & FLAG_X)
      {
         ep->calculating |= flags & FLAG_X;
-        if (ep->param1.rel1_to_x)
+       if (rp1[Rel1X])
           {
-             _edje_part_recalc(ed, ep->param1.rel1_to_x, FLAG_X, NULL);
+             _edje_part_recalc(ed, rp1[Rel1X], FLAG_X, NULL);
 #ifdef EDJE_CALC_CACHE
-             state1 = ep->param1.rel1_to_x->state;
+             state1 = rp1[Rel1X]->state;
 #endif
           }
-        if (ep->param1.rel2_to_x)
+        if (rp1[Rel2X])
           {
-             _edje_part_recalc(ed, ep->param1.rel2_to_x, FLAG_X, NULL);
+             _edje_part_recalc(ed, rp1[Rel2X], FLAG_X, NULL);
 #ifdef EDJE_CALC_CACHE
-             if (state1 < ep->param1.rel2_to_x->state)
-               state1 = ep->param1.rel2_to_x->state;
+             if (state1 < rp1[Rel2X]->state)
+               state1 = rp1[Rel2X]->state;
 #endif
           }
         if (ep->param2)
           {
-             if (ep->param2->rel1_to_x)
+             if (rp2[Rel1X])
                {
-                  _edje_part_recalc(ed, ep->param2->rel1_to_x, FLAG_X, NULL);
+                  _edje_part_recalc(ed, rp2[Rel1X], FLAG_X, NULL);
 #ifdef EDJE_CALC_CACHE
-                  state2 = ep->param2->rel1_to_x->state;
+                  state2 = rp2[Rel1X]->state;
 #endif
                }
-             if (ep->param2->rel2_to_x)
+             if (rp2[Rel2X])
                {
-                  _edje_part_recalc(ed, ep->param2->rel2_to_x, FLAG_X, NULL);
+                  _edje_part_recalc(ed, rp2[Rel2X], FLAG_X, NULL);
 #ifdef EDJE_CALC_CACHE
-                  if (state2 < ep->param2->rel2_to_x->state)
-                    state2 = ep->param2->rel2_to_x->state;
+                  if (state2 < rp2[Rel2X]->state)
+                    state2 = rp2[Rel2X]->state;
 #endif
                }
           }
@@ -2872,38 +2890,38 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
    if (flags & FLAG_Y)
      {
         ep->calculating |= flags & FLAG_Y;
-        if (ep->param1.rel1_to_y)
+        if (rp1[Rel1Y])
           {
-             _edje_part_recalc(ed, ep->param1.rel1_to_y, FLAG_Y, NULL);
+             _edje_part_recalc(ed, rp1[Rel1Y], FLAG_Y, NULL);
 #ifdef EDJE_CALC_CACHE
-             if (state1 < ep->param1.rel1_to_y->state)
-               state1 = ep->param1.rel1_to_y->state;
+             if (state1 < rp1[Rel1Y]->state)
+               state1 = rp1[Rel1Y]->state;
 #endif
           }
-        if (ep->param1.rel2_to_y)
+        if (rp1[Rel2Y])
           {
-             _edje_part_recalc(ed, ep->param1.rel2_to_y, FLAG_Y, NULL);
+             _edje_part_recalc(ed, rp1[Rel2Y], FLAG_Y, NULL);
 #ifdef EDJE_CALC_CACHE
-             if (state1 < ep->param1.rel2_to_y->state)
-               state1 = ep->param1.rel2_to_y->state;
+             if (state1 < rp1[Rel2Y]->state)
+               state1 = rp1[Rel2Y]->state;
 #endif
           }
         if (ep->param2)
           {
-             if (ep->param2->rel1_to_y)
+             if (rp2[Rel1Y])
                {
-                  _edje_part_recalc(ed, ep->param2->rel1_to_y, FLAG_Y, NULL);
+                  _edje_part_recalc(ed, rp2[Rel1Y], FLAG_Y, NULL);
 #ifdef EDJE_CALC_CACHE
-                  if (state2 < ep->param2->rel1_to_y->state)
-                    state2 = ep->param2->rel1_to_y->state;
+                  if (state2 < rp2[Rel1Y]->state)
+                    state2 = rp2[Rel1Y]->state;
 #endif
                }
-             if (ep->param2->rel2_to_y)
+             if (rp2[Rel2Y])
                {
-                  _edje_part_recalc(ed, ep->param2->rel2_to_y, FLAG_Y, NULL);
+                  _edje_part_recalc(ed, rp2[Rel2Y], FLAG_Y, NULL);
 #ifdef EDJE_CALC_CACHE
-                  if (state2 < ep->param2->rel2_to_y->state)
-                    state2 = ep->param2->rel2_to_y->state;
+                  if (state2 < rp2[Rel2Y]->state)
+                    state2 = rp2[Rel2Y]->state;
 #endif
                }
           }
@@ -2997,7 +3015,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
 #endif
           {
              _edje_part_recalc_single(ed, ep, ep->param1.description, chosen_desc, center[0], light[0], persp[0],
-                                      ep->param1.rel1_to_x, ep->param1.rel1_to_y, ep->param1.rel2_to_x, ep->param1.rel2_to_y,
+                                      rp1[Rel1X], rp1[Rel1Y], rp1[Rel2X], rp1[Rel2Y],
                                       confine_to,
                                       p1, pos);
 #ifdef EDJE_CALC_CACHE
@@ -3063,10 +3081,10 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
              _edje_part_recalc_single(ed, ep, ep->param2->description,
                                       chosen_desc,
                                       center[1], light[1], persp[1],
-                                      ep->param2->rel1_to_x,
-                                      ep->param2->rel1_to_y,
-                                      ep->param2->rel2_to_x,
-                                      ep->param2->rel2_to_y,
+                                      rp2[Rel1X],
+                                      rp2[Rel1Y],
+                                      rp2[Rel2X],
+                                      rp2[Rel2Y],
                                       confine_to,
                                       p2, pos);
 #ifdef EDJE_CALC_CACHE
index a1c7e4d..d306689 100644 (file)
@@ -2205,27 +2205,6 @@ edje_edit_part_del(Evas_Object *obj, const char* part)
        if (real->typedata.text->source == rp) real->typedata.text->source = NULL;
        if (real->typedata.text->text_source == rp) real->typedata.text->text_source = NULL;
 
-       if (real->param1.rel1_to_x == rp) real->param1.rel1_to_x = NULL;
-       if (real->param1.rel1_to_y == rp) real->param1.rel1_to_y = NULL;
-       if (real->param1.rel2_to_x == rp) real->param1.rel2_to_x = NULL;
-       if (real->param1.rel2_to_y == rp) real->param1.rel2_to_y = NULL;
-
-       if (real->param2)
-         {
-            if (real->param2->rel1_to_x == rp) real->param2->rel1_to_x = NULL;
-            if (real->param2->rel1_to_y == rp) real->param2->rel1_to_y = NULL;
-            if (real->param2->rel2_to_x == rp) real->param2->rel2_to_x = NULL;
-            if (real->param2->rel2_to_y == rp) real->param2->rel2_to_y = NULL;
-         }
-
-       if (real->custom)
-         {
-            if (real->custom->rel1_to_x == rp) real->custom->rel1_to_x = NULL;
-            if (real->custom->rel1_to_y == rp) real->custom->rel1_to_y = NULL;
-            if (real->custom->rel2_to_x == rp) real->custom->rel2_to_x = NULL;
-            if (real->custom->rel2_to_y == rp) real->custom->rel2_to_y = NULL;
-         }
-
        if (real->part->clip_to_id == rp->part->id)
          {
             evas_object_clip_set(real->object, ed->base->clipper);
index 8282b9a..24b9a3a 100644 (file)
@@ -1950,11 +1950,6 @@ _edje_embryo_fn_set_state_val(Embryo_Program *ep, Embryo_Cell *params)
         GETINT(rp->custom->description->rel1.id_x, params[3]);
         GETINT(rp->custom->description->rel1.id_y, params[4]);
 
-        if (rp->param1.description->rel1.id_x >= 0)
-          rp->param1.rel1_to_x = ed->table_parts[rp->param1.description->rel1.id_x % ed->table_parts_size];
-        if (rp->param1.description->rel1.id_y >= 0)
-          rp->param1.rel1_to_y = ed->table_parts[rp->param1.description->rel1.id_y % ed->table_parts_size];
-
         break;
       case EDJE_STATE_PARAM_REL1_OFFSET:
         CHKPARAM(4);
@@ -1976,11 +1971,6 @@ _edje_embryo_fn_set_state_val(Embryo_Program *ep, Embryo_Cell *params)
         GETINT(rp->custom->description->rel2.id_x, params[3]);
         GETINT(rp->custom->description->rel2.id_y, params[4]);
 
-        if (rp->param1.description->rel2.id_x >= 0)
-          rp->param1.rel2_to_x = ed->table_parts[rp->param1.description->rel2.id_x % ed->table_parts_size];
-        if (rp->param1.description->rel2.id_y >= 0)
-          rp->param1.rel2_to_y = ed->table_parts[rp->param1.description->rel2.id_y % ed->table_parts_size];
-
         break;
       case EDJE_STATE_PARAM_REL2_OFFSET:
         CHKPARAM(4);
index ed0d00f..809afed 100644 (file)
@@ -662,13 +662,13 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
                                                      be able to remove this when all theme are correctly rewritten. */
                         {
                            if (rp->param1.description->rel1.id_x >= 0)
-                             rp->param1.rel1_to_x = ed->table_parts[rp->param1.description->rel1.id_x % ed->table_parts_size];
+                             rp->param1.description->rel1.id_x %= ed->table_parts_size;
                            if (rp->param1.description->rel1.id_y >= 0)
-                             rp->param1.rel1_to_y = ed->table_parts[rp->param1.description->rel1.id_y % ed->table_parts_size];
+                             rp->param1.description->rel1.id_y %= ed->table_parts_size;
                            if (rp->param1.description->rel2.id_x >= 0)
-                             rp->param1.rel2_to_x = ed->table_parts[rp->param1.description->rel2.id_x % ed->table_parts_size];
+                             rp->param1.description->rel2.id_x %= ed->table_parts_size;
                            if (rp->param1.description->rel2.id_y >= 0)
-                             rp->param1.rel2_to_y = ed->table_parts[rp->param1.description->rel2.id_y % ed->table_parts_size];
+                             rp->param1.description->rel2.id_y %= ed->table_parts_size;
                         }
                       if (rp->part->clip_to_id >= 0)
                         {
index e16e25e..978be07 100644 (file)
@@ -1442,10 +1442,6 @@ struct _Edje_Real_Part_State
 {
    Edje_Part_Description_Common *description; // 4
    Edje_Part_Description_Common *description_rtl; // 4
-   Edje_Real_Part        *rel1_to_x; // 4
-   Edje_Real_Part        *rel1_to_y; // 4
-   Edje_Real_Part        *rel2_to_x; // 4
-   Edje_Real_Part        *rel2_to_y; // 4
 #ifdef EDJE_CALC_CACHE
    int                    state; // 4
    Edje_Calc_Params       p; // 271