Enlightenment CVS committal Author : barbieri Project : e17 Module : libs/evas
Dir : e17/libs/evas/src/lib/canvas Modified Files: evas_events.c evas_object_smart.c evas_object_text.c evas_render.c evas_stack.c Log Message: Save 20 bytes moving smart data to its specific object struct. This saves 20 bytes, bringing Evas_Object to 200 bytes, by moving data specific to smart objects to their own struct (Evas_Object_Smart). There is still one remaining member that could be removed: smart.smart, this is used mainly to identify if one object is a smart object or not. One possibility would be to add a bitfield to state that, but another possibility is to check Evas_Object::object_data and see if it's a smart or not. =================================================================== RCS file: /cvs/e/e17/libs/evas/src/lib/canvas/evas_events.c,v retrieving revision 1.58 retrieving revision 1.59 diff -u -3 -r1.58 -r1.59 --- evas_events.c 31 Mar 2008 21:38:38 -0000 1.58 +++ evas_events.c 1 May 2008 05:48:03 -0000 1.59 @@ -20,9 +20,9 @@ } static Evas_List * -_evas_event_object_list_in_get(Evas *e, Evas_List *in, Evas_Object_List *list, Evas_Object *stop, int x, int y, int *no_rep) +_evas_event_object_list_in_get(Evas *e, Evas_List *in, const Evas_Object_List *list, Evas_Object *stop, int x, int y, int *no_rep) { - Evas_Object_List *l; + const Evas_Object_List *l; if (!list) return in; for (l = list->last; l; l = l->prev) @@ -47,7 +47,7 @@ norep = 0; in = _evas_event_object_list_in_get(e, in, - obj->smart.contained, + evas_object_smart_members_get_direct(obj), stop, x, y, &norep); if (norep) { =================================================================== RCS file: /cvs/e/e17/libs/evas/src/lib/canvas/evas_object_smart.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -3 -r1.30 -r1.31 --- evas_object_smart.c 8 Feb 2008 22:35:19 -0000 1.30 +++ evas_object_smart.c 1 May 2008 05:48:03 -0000 1.31 @@ -8,6 +8,11 @@ { DATA32 magic; void *engine_data; + void *data; + Evas_List *callbacks; + Evas_Object_List *contained; + int walking_list; + Evas_Bool deletions_waiting : 1; }; struct _Evas_Smart_Callback @@ -78,7 +83,7 @@ MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART); return; MAGIC_CHECK_END(); - obj->smart.data = data; + o->data = data; } /** @@ -101,7 +106,7 @@ MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART); return NULL; MAGIC_CHECK_END(); - return obj->smart.data; + return o->data; } /** @@ -177,7 +182,7 @@ obj->cur.layer = obj->layer->layer; obj->layer->usage++; obj->smart.parent = smart_obj; - smart_obj->smart.contained = evas_object_list_append(smart_obj->smart.contained, obj); + o->contained = evas_object_list_append(o->contained, obj); evas_object_smart_member_cache_invalidate(obj); obj->restack = 1; evas_object_change(obj); @@ -197,12 +202,16 @@ EAPI void evas_object_smart_member_del(Evas_Object *obj) { + Evas_Object_Smart *o; + MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ); return; MAGIC_CHECK_END(); if (!obj->smart.parent) return; - obj->smart.parent->smart.contained = evas_object_list_remove(obj->smart.parent->smart.contained, obj); + + o = (Evas_Object_Smart *)(obj->smart.parent->object_data); + o->contained = evas_object_list_remove(o->contained, obj); obj->smart.parent = NULL; evas_object_smart_member_cache_invalidate(obj); obj->layer->usage--; @@ -237,20 +246,34 @@ EAPI Evas_List * evas_object_smart_members_get(const Evas_Object *obj) { + Evas_Object_Smart *o; Evas_List *members; Evas_Object_List *member; MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ); return NULL; MAGIC_CHECK_END(); - + o = (Evas_Object_Smart *)(obj->object_data); + MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART); + return NULL; + MAGIC_CHECK_END(); + members = NULL; - for (member = obj->smart.contained; member; member = member->next) + for (member = o->contained; member; member = member->next) members = evas_list_append(members, member); return members; } +const Evas_Object_List * +evas_object_smart_members_get_direct(const Evas_Object *obj) +{ + Evas_Object_Smart *o; + + o = (Evas_Object_Smart *)(obj->object_data); + return o->contained; +} + /** * Instantiates a new smart object described by @p s. * @@ -313,7 +336,7 @@ cb->event = evas_stringshare_add(event); cb->func = func; cb->func_data = (void *)data; - obj->smart.callbacks = evas_list_prepend(obj->smart.callbacks, cb); + o->callbacks = evas_list_prepend(o->callbacks, cb); } /** @@ -341,7 +364,7 @@ return NULL; MAGIC_CHECK_END(); if (!event) return NULL; - for (l = obj->smart.callbacks; l; l = l->next) + for (l = o->callbacks; l; l = l->next) { Evas_Smart_Callback *cb; @@ -352,7 +375,7 @@ data = cb->func_data; cb->delete_me = 1; - obj->smart.deletions_waiting = 1; + o->deletions_waiting = 1; evas_object_smart_callbacks_clear(obj); return data; } @@ -388,8 +411,8 @@ MAGIC_CHECK_END(); if (!event) return; if (obj->delete_me) return; - obj->smart.walking_list++; - for (l = obj->smart.callbacks; l; l = l->next) + o->walking_list++; + for (l = o->callbacks; l; l = l->next) { Evas_Smart_Callback *cb; @@ -402,7 +425,7 @@ if (obj->delete_me) break; } - obj->smart.walking_list--; + o->walking_list--; evas_object_smart_callbacks_clear(obj); } @@ -410,11 +433,14 @@ static void evas_object_smart_callbacks_clear(Evas_Object *obj) { + Evas_Object_Smart *o; Evas_List *l; - if (obj->smart.walking_list) return; - if (!obj->smart.deletions_waiting) return; - for (l = obj->smart.callbacks; l;) + o = (Evas_Object_Smart *)(obj->object_data); + + if (o->walking_list) return; + if (!o->deletions_waiting) return; + for (l = o->callbacks; l;) { Evas_Smart_Callback *cb; @@ -422,7 +448,7 @@ l = l->next; if (cb->delete_me) { - obj->smart.callbacks = evas_list_remove(obj->smart.callbacks, cb); + o->callbacks = evas_list_remove(o->callbacks, cb); if (cb->event) evas_stringshare_del(cb->event); free(cb); } @@ -444,40 +470,92 @@ void evas_object_smart_cleanup(Evas_Object *obj) { - Evas_Smart *s; + Evas_Object_Smart *o; - s = obj->smart.smart; if (obj->smart.parent) evas_object_smart_member_del(obj); - while (obj->smart.contained) - evas_object_smart_member_del((Evas_Object *)obj->smart.contained); - while (obj->smart.callbacks) + + o = (Evas_Object_Smart *)(obj->object_data); + if (o->magic == MAGIC_OBJ_SMART) { - Evas_Smart_Callback *cb; + while (o->contained) + evas_object_smart_member_del((Evas_Object *)o->contained); + + while (o->callbacks) + { + Evas_Smart_Callback *cb; + + cb = o->callbacks->data; + o->callbacks = evas_list_remove(o->callbacks, cb); + if (cb->event) evas_stringshare_del(cb->event); + free(cb); + } - cb = obj->smart.callbacks->data; - obj->smart.callbacks = evas_list_remove(obj->smart.callbacks, cb); - if (cb->event) evas_stringshare_del(cb->event); - free(cb); + o->data = NULL; } + obj->smart.parent = NULL; - obj->smart.data = NULL; obj->smart.smart = NULL; } void evas_object_smart_member_cache_invalidate(Evas_Object *obj) { + Evas_Object_Smart *o; Evas_Object_List *l; - + + o = (Evas_Object_Smart *)(obj->object_data); + if (o->magic != MAGIC_OBJ_SMART) + return; + obj->parent_cache_valid = 0; - for (l = obj->smart.contained; l; l = l->next) + for (l = o->contained; l; l = l->next) { Evas_Object *obj2; obj2 = (Evas_Object *)l; evas_object_smart_member_cache_invalidate(obj2); } +} + +void +evas_object_smart_member_raise(Evas_Object *member) +{ + Evas_Object_Smart *o; + + o = (Evas_Object_Smart *)(member->smart.parent->object_data); + o->contained = evas_object_list_remove(o->contained, member); + o->contained = evas_object_list_append(o->contained, member); +} + +void +evas_object_smart_member_lower(Evas_Object *member) +{ + Evas_Object_Smart *o; + + o = (Evas_Object_Smart *)(member->smart.parent->object_data); + o->contained = evas_object_list_remove(o->contained, member); + o->contained = evas_object_list_prepend(o->contained, member); +} + +void +evas_object_smart_member_stack_above(Evas_Object *member, Evas_Object *other) +{ + Evas_Object_Smart *o; + + o = (Evas_Object_Smart *)(member->smart.parent->object_data); + o->contained = evas_object_list_remove(o->contained, member); + o->contained = evas_object_list_append_relative(o->contained, member, other); +} + +void +evas_object_smart_member_stack_below(Evas_Object *member, Evas_Object *other) +{ + Evas_Object_Smart *o; + + o = (Evas_Object_Smart *)(member->smart.parent->object_data); + o->contained = evas_object_list_remove(o->contained, member); + o->contained = evas_object_list_prepend_relative(o->contained, member, other); } /* all nice and private */ =================================================================== RCS file: /cvs/e/e17/libs/evas/src/lib/canvas/evas_object_text.c,v retrieving revision 1.68 retrieving revision 1.69 diff -u -3 -r1.68 -r1.69 --- evas_object_text.c 8 Feb 2008 22:35:19 -0000 1.68 +++ evas_object_text.c 1 May 2008 05:48:03 -0000 1.69 @@ -1010,9 +1010,9 @@ { if (obj->smart.smart) { - Evas_Object_List *l3; + const Evas_Object_List *l3; - for (l3 = obj->smart.contained; l3; l3 = l3->next) + for (l3 = evas_object_smart_members_get_direct(obj); l3; l3 = l3->next) { obj = (Evas_Object *)l3; evas_font_object_rehint(obj); =================================================================== RCS file: /cvs/e/e17/libs/evas/src/lib/canvas/evas_render.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -3 -r1.27 -r1.28 --- evas_render.c 14 Apr 2008 09:31:31 -0000 1.27 +++ evas_render.c 1 May 2008 05:48:03 -0000 1.28 @@ -91,10 +91,10 @@ { if (obj->smart.smart) { - Evas_Object_List *l; + const Evas_Object_List *l; obj->func->render_pre(obj); - for (l = obj->smart.contained; l; l = l->next) + for (l = evas_object_smart_members_get_direct(obj); l; l = l->next) { Evas_Object *obj2; @@ -126,10 +126,10 @@ { if (obj->smart.smart) { - Evas_Object_List *l; + const Evas_Object_List *l; obj->func->render_pre(obj); - for (l = obj->smart.contained; l; l = l->next) + for (l = evas_object_smart_members_get_direct(obj); l; l = l->next) { Evas_Object *obj2; =================================================================== RCS file: /cvs/e/e17/libs/evas/src/lib/canvas/evas_stack.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -3 -r1.26 -r1.27 --- evas_stack.c 8 Feb 2008 22:35:19 -0000 1.26 +++ evas_stack.c 1 May 2008 05:48:03 -0000 1.27 @@ -56,10 +56,7 @@ return; } if (obj->smart.parent) - { - obj->smart.parent->smart.contained = evas_object_list_remove(obj->smart.parent->smart.contained, obj); - obj->smart.parent->smart.contained = evas_object_list_append(obj->smart.parent->smart.contained, obj); - } + evas_object_smart_member_raise(obj); else { if (obj->in_layer) @@ -115,10 +112,7 @@ return; } if (obj->smart.parent) - { - obj->smart.parent->smart.contained = evas_object_list_remove(obj->smart.parent->smart.contained, obj); - obj->smart.parent->smart.contained = evas_object_list_prepend(obj->smart.parent->smart.contained, obj); - } + evas_object_smart_member_lower(obj); else { if (obj->in_layer) @@ -195,8 +189,7 @@ // printf("BITCH! evas_object_stack_above(), %p not inside same smart as %p!\n", obj, above); return; } - obj->smart.parent->smart.contained = evas_object_list_remove(obj->smart.parent->smart.contained, obj); - obj->smart.parent->smart.contained = evas_object_list_append_relative(obj->smart.parent->smart.contained, obj, above); + evas_object_smart_member_stack_above(obj, above); } else { @@ -279,8 +272,7 @@ // printf("BITCH! evas_object_stack_below(), %p not inside same smart as %p!\n", obj, below); return; } - obj->smart.parent->smart.contained = evas_object_list_remove(obj->smart.parent->smart.contained, obj); - obj->smart.parent->smart.contained = evas_object_list_prepend_relative(obj->smart.parent->smart.contained, obj, below); + evas_object_smart_member_stack_below(obj, below); } else { ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs