Make layer number a short and Save 8 bytes.

By having a layer as a short (16 bits) we can pack it together with
the bitfields, saving 4 bytes per sub-struct, 8 bytes in total, also
bringing the struct down from 4 to 3 cachelines on my laptop.

Rationale: layers are mostly used to differentiate groups of objects
and they stacking, usually we have few layers and we use very large or
very small numbers to make a layer be at the top or at the bottom, but
usually we don't need so many layers.

Caution: code that use values like 999999 will break, so fix your
code! I'll provide another patch to fix all the CVS using these large
values.


SVN revision: 34420
This commit is contained in:
Gustavo Sverzut Barbieri 2008-05-01 06:18:21 +00:00
parent 7a82a3e43d
commit 27437c83cf
3 changed files with 8 additions and 8 deletions

View File

@ -704,8 +704,8 @@ extern "C" {
EAPI const char *evas_object_type_get (const Evas_Object *obj);
EAPI void evas_object_layer_set (Evas_Object *obj, int l);
EAPI int evas_object_layer_get (const Evas_Object *obj);
EAPI void evas_object_layer_set (Evas_Object *obj, short l);
EAPI short evas_object_layer_get (const Evas_Object *obj);
EAPI void evas_object_raise (Evas_Object *obj);
EAPI void evas_object_lower (Evas_Object *obj);

View File

@ -78,7 +78,7 @@ evas_layer_free(Evas_Layer *lay)
}
Evas_Layer *
evas_layer_find(Evas *e, int layer_num)
evas_layer_find(Evas *e, short layer_num)
{
Evas_Object_List *list;
@ -139,7 +139,7 @@ evas_layer_del(Evas_Layer *lay)
* @ingroup Evas_Object_Layer_Group
*/
EAPI void
evas_object_layer_set(Evas_Object *obj, int l)
evas_object_layer_set(Evas_Object *obj, short l)
{
Evas *e;
@ -187,7 +187,7 @@ evas_object_layer_set(Evas_Object *obj, int l)
* @return Number of the layer.
* @ingroup Evas_Object_Layer_Group
*/
EAPI int
EAPI short
evas_object_layer_get(const Evas_Object *obj)
{
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);

View File

@ -361,7 +361,7 @@ struct _Evas_Layer
{
Evas_Object_List _list_data;
int layer;
short layer;
Evas_Object *objects;
Evas *evas;
@ -416,8 +416,8 @@ struct _Evas_Object
struct {
unsigned char r, g, b, a;
} color;
int layer;
Evas_Object *clipper;
short layer;
Evas_Bool visible : 1;
Evas_Bool have_clipees : 1;
Evas_Bool anti_alias : 1;
@ -694,7 +694,7 @@ void evas_object_recalc_clippees(Evas_Object *obj);
Evas_Layer *evas_layer_new(Evas *e);
void evas_layer_pre_free(Evas_Layer *lay);
void evas_layer_free(Evas_Layer *lay);
Evas_Layer *evas_layer_find(Evas *e, int layer_num);
Evas_Layer *evas_layer_find(Evas *e, short layer_num);
void evas_layer_add(Evas_Layer *lay);
void evas_layer_del(Evas_Layer *lay);
void evas_object_coords_recalc(Evas_Object *obj);