On Mon, Apr 14, 2008 at 11:55 AM, Cedric BAIL <[EMAIL PROTECTED]> wrote:
> On Sun, Apr 13, 2008 at 9:52 PM, Gustavo Sverzut Barbieri
>  <[EMAIL PROTECTED]> wrote:
>  > On Sun, Apr 13, 2008 at 1:33 PM, Cedric BAIL <[EMAIL PROTECTED]> wrote:
>  >  > On Fri, Apr 11, 2008 at 8:56 PM, Cedric BAIL <[EMAIL PROTECTED]> wrote:
>  >    - evas_array seems very useful, make it available to evas as a
>  >  whole! Just have it to take "void *" and it will do just fine. Also,
>  >  I'd make the increase amount (16) configurable after the array is
>  >  created (or provide an alternative constructor).
>
>  Good idea, but as this are small functions and some are used a lot I
>  like the idea of seeing them inlined. As there are more of this kind
>  of function in Evas, small functions used a lot, I did move them after
>  some profiling inside src/lib/include/evas_inline.x. This give us a
>  little bit of speedup with only a small increase in library size. The
>  function that could be inlined are :
>  - evas_object_is_opaque
>  - evas_event_passes_through
>  - evas_object_is_visible
>  - evas_object_clippers_is_visible
>  - evas_object_is_in_output_rect
>  - evas_object_is_active
>  - evas_object_coords_recalc
>  - evas_object_clip_recalc
>
>  Are people interested by this kind of patch ? I would add
>  evas_object_array_push to this list also.

Because code is better than discussion, here is a patch that does
exactly that. Comment are welcome :-)

-- 
Cedric BAIL
diff --git a/src/lib/canvas/evas_clip.c b/src/lib/canvas/evas_clip.c
index bd7dd54..dfc3e4f 100644
--- a/src/lib/canvas/evas_clip.c
+++ b/src/lib/canvas/evas_clip.c
@@ -2,57 +2,6 @@
 #include "evas_private.h"
 
 void
-evas_object_clip_recalc(Evas_Object *obj)
-{
-   int cx, cy, cw, ch, cvis, cr, cg, cb, ca;
-   int nx, ny, nw, nh, nvis, nr, ng, nb, na;
-
-   if (obj->layer->evas->events_frozen > 0) return;
-//   if (!obj->cur.clipper->cur.cache.clip.dirty) return;
-   evas_object_coords_recalc(obj);
-   cx = obj->cur.geometry.x; cy = obj->cur.geometry.y;
-   cw = obj->cur.geometry.w; ch = obj->cur.geometry.h;
-////   cx = obj->cur.cache.geometry.x; cy = obj->cur.cache.geometry.y;
-////   cw = obj->cur.cache.geometry.w; ch = obj->cur.cache.geometry.h;
-   if (obj->cur.color.a == 0) cvis = 0;
-   else cvis = obj->cur.visible;
-   cr = obj->cur.color.r; cg = obj->cur.color.g;
-   cb = obj->cur.color.b; ca = obj->cur.color.a;
-   if (obj->cur.clipper)
-     {
-// this causes problems... hmmm
-//	if (obj->cur.clipper->cur.cache.clip.dirty)
-	  evas_object_clip_recalc(obj->cur.clipper);
-	nx = obj->cur.clipper->cur.cache.clip.x;
-	ny = obj->cur.clipper->cur.cache.clip.y;
-	nw = obj->cur.clipper->cur.cache.clip.w;
-	nh = obj->cur.clipper->cur.cache.clip.h;
-	nvis = obj->cur.clipper->cur.cache.clip.visible;
-	nr = obj->cur.clipper->cur.cache.clip.r;
-	ng = obj->cur.clipper->cur.cache.clip.g;
-	nb = obj->cur.clipper->cur.cache.clip.b;
-	na = obj->cur.clipper->cur.cache.clip.a;
-	RECTS_CLIP_TO_RECT(cx, cy, cw, ch, nx, ny, nw, nh);
-	cvis = cvis * nvis;
-	cr = (cr * (nr + 1)) >> 8;
-	cg = (cg * (ng + 1)) >> 8;
-	cb = (cb * (nb + 1)) >> 8;
-	ca = (ca * (na + 1)) >> 8;
-     }
-   if ((ca == 0) || (cw <= 0) || (ch <= 0)) cvis = 0;
-   obj->cur.cache.clip.x = cx;
-   obj->cur.cache.clip.y = cy;
-   obj->cur.cache.clip.w = cw;
-   obj->cur.cache.clip.h = ch;
-   obj->cur.cache.clip.visible = cvis;
-   obj->cur.cache.clip.r = cr;
-   obj->cur.cache.clip.g = cg;
-   obj->cur.cache.clip.b = cb;
-   obj->cur.cache.clip.a = ca;
-   obj->cur.cache.clip.dirty = 0;
-}
-
-void
 evas_object_clip_dirty(Evas_Object *obj)
 {
    Evas_List *l;
@@ -76,18 +25,6 @@ evas_object_recalc_clippees(Evas_Object *obj)
 }
 
 int
-evas_object_clippers_is_visible(Evas_Object *obj)
-{
-   if (obj->cur.visible)
-     {
-	if (obj->cur.clipper)
-	  return evas_object_clippers_is_visible(obj->cur.clipper);
-	return 1;
-     }
-   return 0;
-}
-
-int
 evas_object_clippers_was_visible(Evas_Object *obj)
 {
    if (obj->prev.visible)
diff --git a/src/lib/canvas/evas_events.c b/src/lib/canvas/evas_events.c
index c31ac15..3eb6346 100644
--- a/src/lib/canvas/evas_events.c
+++ b/src/lib/canvas/evas_events.c
@@ -1,24 +1,6 @@
 #include "evas_common.h"
 #include "evas_private.h"
 
-int
-evas_event_passes_through(Evas_Object *obj)
-{
-   if (obj->layer->evas->events_frozen > 0) return 1;
-   if (obj->pass_events) return 1;
-   if (obj->parent_cache_valid) return obj->parent_pass_events;
-   if (obj->smart.parent)
-     {
-	int par_pass;
-	
-	par_pass = evas_event_passes_through(obj->smart.parent);
-	obj->parent_cache_valid = 1;
-	obj->parent_pass_events = par_pass;
-	return par_pass;
-     }
-   return 0;
-}
-
 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)
 {
diff --git a/src/lib/canvas/evas_object_main.c b/src/lib/canvas/evas_object_main.c
index e5e5fde..e19bebf 100644
--- a/src/lib/canvas/evas_object_main.c
+++ b/src/lib/canvas/evas_object_main.c
@@ -302,53 +302,6 @@ evas_object_render_pre_effect_updates(Evas_List *updates, Evas_Object *obj, int
      }
 }
 
-void
-evas_object_coords_recalc(Evas_Object *obj)
-{
-   if (obj->smart.smart) return;
-////   if (obj->cur.cache.geometry.validity == obj->layer->evas->output_validity)
-////     return;
-////   obj->cur.cache.geometry.x =
-////     evas_coord_world_x_to_screen(obj->layer->evas, obj->cur.geometry.x);
-////   obj->cur.cache.geometry.y =
-////     evas_coord_world_y_to_screen(obj->layer->evas, obj->cur.geometry.y);
-////   obj->cur.cache.geometry.w =
-////     evas_coord_world_x_to_screen(obj->layer->evas, obj->cur.geometry.w) -
-////     evas_coord_world_x_to_screen(obj->layer->evas, 0);
-////   obj->cur.cache.geometry.h =
-////     evas_coord_world_y_to_screen(obj->layer->evas, obj->cur.geometry.h) -
-////     evas_coord_world_y_to_screen(obj->layer->evas, 0);
-   if (obj->func->coords_recalc) obj->func->coords_recalc(obj);
-////   obj->cur.cache.geometry.validity = obj->layer->evas->output_validity;
-}
-
-int
-evas_object_is_active(Evas_Object *obj)
-{
-   if (obj->smart.smart) return 0;
-   if ((evas_object_is_visible(obj) || evas_object_was_visible(obj)) &&
-       (evas_object_is_in_output_rect(obj, 0, 0, obj->layer->evas->output.w,
-				      obj->layer->evas->output.h) ||
-	evas_object_was_in_output_rect(obj, 0, 0, obj->layer->evas->output.w,
-				       obj->layer->evas->output.h)))
-     return 1;
-   return 0;
-}
-
-int
-evas_object_is_in_output_rect(Evas_Object *obj, int x, int y, int w, int h)
-{
-   if (obj->smart.smart) return 0;
-   /* assumes coords have been recalced */
-   if ((RECTS_INTERSECT(x, y, w, h,
-			obj->cur.cache.clip.x,
-			obj->cur.cache.clip.y,
-			obj->cur.cache.clip.w,
-			obj->cur.cache.clip.h)))
-     return 1;
-   return 0;
-}
-
 int
 evas_object_was_in_output_rect(Evas_Object *obj, int x, int y, int w, int h)
 {
@@ -364,21 +317,6 @@ evas_object_was_in_output_rect(Evas_Object *obj, int x, int y, int w, int h)
 }
 
 int
-evas_object_is_visible(Evas_Object *obj)
-{
-   if (obj->smart.smart) return 0;
-   if ((obj->cur.visible) &&
-       (obj->cur.cache.clip.visible) &&
-       (obj->cur.cache.clip.a > 0))
-     {
-	if (obj->func->is_visible)
-	  return obj->func->is_visible(obj);
-	return 1;
-     }
-   return 0;
-}
-
-int
 evas_object_was_visible(Evas_Object *obj)
 {
    if (obj->smart.smart) return 0;
@@ -394,19 +332,6 @@ evas_object_was_visible(Evas_Object *obj)
 }
 
 int
-evas_object_is_opaque(Evas_Object *obj)
-{
-   if (obj->smart.smart) return 0;
-   if (obj->cur.cache.clip.a == 255)
-     {
-	if (obj->func->is_opaque)
-	  return obj->func->is_opaque(obj);
-	return 1;
-     }
-   return 0;
-}
-
-int
 evas_object_was_opaque(Evas_Object *obj)
 {
    if (obj->smart.smart) return 0;
diff --git a/src/lib/include/Makefile.am b/src/lib/include/Makefile.am
index 07bb2c0..1570bf4 100644
--- a/src/lib/include/Makefile.am
+++ b/src/lib/include/Makefile.am
@@ -2,6 +2,7 @@
 MAINTAINERCLEANFILES = Makefile.in
 
 EXTRA_DIST = \
+evas_inline.x \
 evas_private.h \
 evas_options.h \
 evas_macros.h \
diff --git a/src/lib/include/evas_inline.x b/src/lib/include/evas_inline.x
new file mode 100644
index 0000000..2489c94
--- /dev/null
+++ b/src/lib/include/evas_inline.x
@@ -0,0 +1,161 @@
+#ifndef EVAS_INLINE_H
+#define EVAS_INLINE_H
+
+static inline int
+evas_object_is_opaque(Evas_Object *obj)
+{
+   if (obj->smart.smart) return 0;
+   if (obj->cur.cache.clip.a == 255)
+     {
+	if (obj->func->is_opaque)
+	  return obj->func->is_opaque(obj);
+	return 1;
+     }
+   return 0;
+}
+
+static inline int
+evas_event_passes_through(Evas_Object *obj)
+{
+   if (obj->layer->evas->events_frozen > 0) return 1;
+   if (obj->pass_events) return 1;
+   if (obj->parent_cache_valid) return obj->parent_pass_events;
+   if (obj->smart.parent)
+     {
+	int par_pass;
+	
+	par_pass = evas_event_passes_through(obj->smart.parent);
+	obj->parent_cache_valid = 1;
+	obj->parent_pass_events = par_pass;
+	return par_pass;
+     }
+   return 0;
+}
+
+static inline int
+evas_object_is_visible(Evas_Object *obj)
+{
+   if (obj->smart.smart) return 0;
+   if ((obj->cur.visible) &&
+       (obj->cur.cache.clip.visible) &&
+       (obj->cur.cache.clip.a > 0))
+     {
+	if (obj->func->is_visible)
+	  return obj->func->is_visible(obj);
+	return 1;
+     }
+   return 0;
+}
+
+static inline int
+evas_object_clippers_is_visible(Evas_Object *obj)
+{
+   if (obj->cur.visible)
+     {
+	if (obj->cur.clipper)
+	  return evas_object_clippers_is_visible(obj->cur.clipper);
+	return 1;
+     }
+   return 0;
+}
+
+static inline int
+evas_object_is_in_output_rect(Evas_Object *obj, int x, int y, int w, int h)
+{
+   if (obj->smart.smart) return 0;
+   /* assumes coords have been recalced */
+   if ((RECTS_INTERSECT(x, y, w, h,
+			obj->cur.cache.clip.x,
+			obj->cur.cache.clip.y,
+			obj->cur.cache.clip.w,
+			obj->cur.cache.clip.h)))
+     return 1;
+   return 0;
+}
+
+static inline int
+evas_object_is_active(Evas_Object *obj)
+{
+   if (obj->smart.smart) return 0;
+   if ((evas_object_is_visible(obj) || evas_object_was_visible(obj)) &&
+       (evas_object_is_in_output_rect(obj, 0, 0, obj->layer->evas->output.w,
+				      obj->layer->evas->output.h) ||
+	evas_object_was_in_output_rect(obj, 0, 0, obj->layer->evas->output.w,
+				       obj->layer->evas->output.h)))
+     return 1;
+   return 0;
+}
+
+static inline void
+evas_object_coords_recalc(Evas_Object *obj)
+{
+   if (obj->smart.smart) return;
+////   if (obj->cur.cache.geometry.validity == obj->layer->evas->output_validity)
+////     return;
+////   obj->cur.cache.geometry.x =
+////     evas_coord_world_x_to_screen(obj->layer->evas, obj->cur.geometry.x);
+////   obj->cur.cache.geometry.y =
+////     evas_coord_world_y_to_screen(obj->layer->evas, obj->cur.geometry.y);
+////   obj->cur.cache.geometry.w =
+////     evas_coord_world_x_to_screen(obj->layer->evas, obj->cur.geometry.w) -
+////     evas_coord_world_x_to_screen(obj->layer->evas, 0);
+////   obj->cur.cache.geometry.h =
+////     evas_coord_world_y_to_screen(obj->layer->evas, obj->cur.geometry.h) -
+////     evas_coord_world_y_to_screen(obj->layer->evas, 0);
+   if (obj->func->coords_recalc) obj->func->coords_recalc(obj);
+////   obj->cur.cache.geometry.validity = obj->layer->evas->output_validity;
+}
+
+static inline void
+evas_object_clip_recalc(Evas_Object *obj)
+{
+   int cx, cy, cw, ch, cvis, cr, cg, cb, ca;
+   int nx, ny, nw, nh, nvis, nr, ng, nb, na;
+
+   if (obj->layer->evas->events_frozen > 0) return;
+//   if (!obj->cur.clipper->cur.cache.clip.dirty) return;
+   evas_object_coords_recalc(obj);
+   cx = obj->cur.geometry.x; cy = obj->cur.geometry.y;
+   cw = obj->cur.geometry.w; ch = obj->cur.geometry.h;
+////   cx = obj->cur.cache.geometry.x; cy = obj->cur.cache.geometry.y;
+////   cw = obj->cur.cache.geometry.w; ch = obj->cur.cache.geometry.h;
+   if (obj->cur.color.a == 0) cvis = 0;
+   else cvis = obj->cur.visible;
+   cr = obj->cur.color.r; cg = obj->cur.color.g;
+   cb = obj->cur.color.b; ca = obj->cur.color.a;
+   if (obj->cur.clipper)
+     {
+// this causes problems... hmmm
+//	if (obj->cur.clipper->cur.cache.clip.dirty)
+	  evas_object_clip_recalc(obj->cur.clipper);
+	nx = obj->cur.clipper->cur.cache.clip.x;
+	ny = obj->cur.clipper->cur.cache.clip.y;
+	nw = obj->cur.clipper->cur.cache.clip.w;
+	nh = obj->cur.clipper->cur.cache.clip.h;
+	RECTS_CLIP_TO_RECT(cx, cy, cw, ch, nx, ny, nw, nh);
+
+	nvis = obj->cur.clipper->cur.cache.clip.visible;
+	nr = obj->cur.clipper->cur.cache.clip.r;
+	ng = obj->cur.clipper->cur.cache.clip.g;
+	nb = obj->cur.clipper->cur.cache.clip.b;
+	na = obj->cur.clipper->cur.cache.clip.a;
+	cvis = cvis * nvis;
+	cr = (cr * (nr + 1)) >> 8;
+	cg = (cg * (ng + 1)) >> 8;
+	cb = (cb * (nb + 1)) >> 8;
+	ca = (ca * (na + 1)) >> 8;
+     }
+   if ((ca == 0) || (cw <= 0) || (ch <= 0)) cvis = 0;
+   obj->cur.cache.clip.x = cx;
+   obj->cur.cache.clip.y = cy;
+   obj->cur.cache.clip.w = cw;
+   obj->cur.cache.clip.h = ch;
+   obj->cur.cache.clip.visible = cvis;
+   obj->cur.cache.clip.r = cr;
+   obj->cur.cache.clip.g = cg;
+   obj->cur.cache.clip.b = cb;
+   obj->cur.cache.clip.a = ca;
+   obj->cur.cache.clip.dirty = 0;
+}
+
+#endif
diff --git a/src/lib/include/evas_private.h b/src/lib/include/evas_private.h
index 317e985..0116fa8 100644
--- a/src/lib/include/evas_private.h
+++ b/src/lib/include/evas_private.h
@@ -710,7 +710,7 @@ Evas_List *evas_object_render_pre_clipper_change(Evas_List *updates, Evas_Object
 Evas_List *evas_object_render_pre_prev_cur_add(Evas_List *updates, Evas_Object *obj);
 void evas_object_render_pre_effect_updates(Evas_List *updates, Evas_Object *obj, int is_v, int was_v);
 Evas_List * evas_rects_return_difference_rects(int x, int y, int w, int h, int xx, int yy, int ww, int hh);
-void evas_object_clip_recalc(Evas_Object *obj);
+
 void evas_object_clip_dirty(Evas_Object *obj);
 void evas_object_recalc_clippees(Evas_Object *obj);
 Evas_Layer *evas_layer_new(Evas *e);
@@ -719,21 +719,15 @@ void evas_layer_free(Evas_Layer *lay);
 Evas_Layer *evas_layer_find(Evas *e, int layer_num);
 void evas_layer_add(Evas_Layer *lay);
 void evas_layer_del(Evas_Layer *lay);
-void evas_object_coords_recalc(Evas_Object *obj);
-int evas_object_is_active(Evas_Object *obj);
-int evas_object_is_in_output_rect(Evas_Object *obj, int x, int y, int w, int h);
-int evas_object_was_in_output_rect(Evas_Object *obj, int x, int y, int w, int h);
-int evas_object_is_visible(Evas_Object *obj);
+
 int evas_object_was_visible(Evas_Object *obj);
-int evas_object_is_opaque(Evas_Object *obj);
+int evas_object_was_in_output_rect(Evas_Object *obj, int x, int y, int w, int h);
+
 int evas_object_was_opaque(Evas_Object *obj);
 int evas_object_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
 int evas_object_was_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
-//void evas_object_recalc_clippees(Evas_Object *obj);
-int evas_object_clippers_is_visible(Evas_Object *obj);
 int evas_object_clippers_was_visible(Evas_Object *obj);
 void evas_object_event_callback_call(Evas_Object *obj, Evas_Callback_Type type, void *event_info);
-int evas_event_passes_through(Evas_Object *obj);
 Evas_List *evas_event_objects_event_list(Evas *e, Evas_Object *stop, int x, int y);
 int evas_file_path_is_full_path(const char *path);
 char *evas_file_path_join(const char *path, const char *end);
@@ -832,8 +826,10 @@ void _evas_walk(Evas *e);
 void _evas_unwalk(Evas *e);
        
 EAPI int _evas_module_engine_inherit(Evas_Func *funcs, char *name);
-       
-#define EVAS_API_OVERRIDE(func, api, prefix) \
+
+#include "evas_inline.x"
+
+#define EVAS_API_OVERRIDE(func, api, prefix)    \
      (api)->func = prefix##func
 #ifdef __cplusplus
 }
-------------------------------------------------------------------------
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-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to