On Sat, Aug 16, 2008 at 3:15 AM, Jose Gonzalez <[EMAIL PROTECTED]> wrote:
> Just to make it clear what I think about this: This kind of thing is
> something that really needs to be done, one way or another. :)
>
> Some time back, I thought about having the edje recalc function called
> by smart class render-pre/post funcs, and these funcs I wanted to be called
> by the obj's internal render-pre/post ones as this would be useful for
> creating
> semi-custom, stateful, objs that rendered to image buffers (possibly native
> surfaces). But I saw that there were problems with that due to the very kinds
> of things you mention, the events system and possibly other things, as I
> mentioned to Cedric once here.
> You could have an additional smart class func, say a "calculate" one and
> then do as you suggest.. but the main issue here is whether this kind of smart
> class specific approach is the "best" way to deal with this kind of general
> issue.
> I've mentioned two other possible ways to deal with this in a more generic
> manner - for example an ecore_evas based one akin to what's done with
> sub-canvases
> (which is useful for those), or a more 'evas only' one akin to what you have
> here
> but using user supplied callbacks. There are other possibilities.. evas could
> expose an EVAS_RENDER_EVENT and have callbacks one can add for such, called
> prior
> to the internal evas-render loop... and other possibilities.
> I don't know what might be best.. just that this is something needed but
> that needs more thought, some experimenting, etc. Maybe raster, nathan,
> hisham,
> and others can give more feedback on this - maybe your proposal *is* the best
> way to deal with this general issue, but it won't hurt to consider other
> possible
> ways if they have potentially wider applicability. :)
Ok, here is a patch that improve the speed for evas part of Gustavo
work. I did rename the callback to calculate. Regarding if it's the
best way, that I don't know, but it's easy to implement on both side
and fast.
Between the edje patch is currently not correct as many getter expect
the underlying object to be calculated. If you apply the attached
patch (not really a smart patch) you will see that many user of edje
expect it to be calculated at some point.
--
Cedric BAIL
diff --git a/src/lib/Evas.h b/src/lib/Evas.h
index 1c45061..e001ac5 100644
--- a/src/lib/Evas.h
+++ b/src/lib/Evas.h
@@ -129,7 +129,7 @@ typedef enum _Evas_Aspect_Control
} Evas_Aspect_Control;
-#define EVAS_SMART_CLASS_VERSION 1 /** the version you have to put into the version field in the smart class struct */
+#define EVAS_SMART_CLASS_VERSION 2 /** the version you have to put into the version field in the smart class struct */
struct _Evas_Smart_Class /** a smart object class */
{
const char *name; /** the string name of the class */
@@ -145,6 +145,7 @@ struct _Evas_Smart_Class /** a smart object class */
void (*color_set) (Evas_Object *o, int r, int g, int b, int a); // FIXME: DELETE ME
void (*clip_set) (Evas_Object *o, Evas_Object *clip); // FIXME: DELETE ME
void (*clip_unset) (Evas_Object *o); // FIXME: DELETE ME
+ void (*calculate) (Evas_Object *o);
const void *data;
};
@@ -738,6 +739,7 @@ extern "C" {
EAPI void evas_object_smart_callback_add (Evas_Object *obj, const char *event, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data);
EAPI void *evas_object_smart_callback_del (Evas_Object *obj, const char *event, void (*func) (void *data, Evas_Object *obj, void *event_info));
EAPI void evas_object_smart_callback_call (Evas_Object *obj, const char *event, void *event_info);
+ EAPI void evas_object_smart_changed (Evas_Object *obj);
/* events */
EAPI void evas_event_freeze (Evas *e);
diff --git a/src/lib/canvas/evas_main.c b/src/lib/canvas/evas_main.c
index 27b3ce6..1a9b34c 100644
--- a/src/lib/canvas/evas_main.c
+++ b/src/lib/canvas/evas_main.c
@@ -70,6 +70,7 @@ evas_new(void)
evas_array_setup(&e->pending_objects, 16);
evas_array_setup(&e->obscuring_objects, 16);
evas_array_setup(&e->temporary_objects, 16);
+ evas_array_setup(&e->calculate_objects, 16);
return e;
}
diff --git a/src/lib/canvas/evas_object_smart.c b/src/lib/canvas/evas_object_smart.c
index aaffd3e..ec42e10 100644
--- a/src/lib/canvas/evas_object_smart.c
+++ b/src/lib/canvas/evas_object_smart.c
@@ -429,6 +429,21 @@ evas_object_smart_callback_call(Evas_Object *obj, const char *event, void *event
evas_object_smart_callbacks_clear(obj);
}
+/**
+ * Mark smart object as changed, dirty.
+ *
+ * This will inform the scene that it changed and needs to be redraw.
+ */
+EAPI void
+evas_object_smart_changed(Evas_Object *obj)
+{
+ MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
+ return;
+ MAGIC_CHECK_END();
+ evas_object_change(obj);
+ evas_render_object_calc(obj);
+}
+
/* internal calls */
static void
evas_object_smart_callbacks_clear(Evas_Object *obj)
diff --git a/src/lib/canvas/evas_render.c b/src/lib/canvas/evas_render.c
index 8eb6a96..1d54384 100644
--- a/src/lib/canvas/evas_render.c
+++ b/src/lib/canvas/evas_render.c
@@ -325,6 +325,28 @@ Evas_Bool pending_change(void *data, void *gdata)
return obj->changed;
}
+static void
+_evas_render_call_smart_pre_renders(Evas_Array *calculate)
+{
+ unsigned int i;
+
+ for (i = 0; i < calculate->count; ++i)
+ {
+ Evas_Object *obj;
+
+ obj = _evas_array_get(calculate, i);
+
+ if (obj->recalc && obj->smart.smart &&
+ obj->smart.smart->smart_class &&
+ obj->smart.smart->smart_class->calculate)
+ obj->smart.smart->smart_class->calculate(obj);
+
+ obj->recalc = 0;
+ }
+
+ evas_array_flush(calculate);
+}
+
static Evas_List *
evas_render_updates_internal(Evas *e, unsigned char make_updates, unsigned char do_draw)
{
@@ -341,6 +363,8 @@ evas_render_updates_internal(Evas *e, unsigned char make_updates, unsigned char
MAGIC_CHECK_END();
if (!e->changed) return NULL;
+ _evas_render_call_smart_pre_renders(&e->calculate_objects);
+
/* Check if the modified object mean recalculating every thing */
if (!e->invalidate)
_evas_render_check_pending_objects(&e->pending_objects, e);
@@ -730,3 +754,22 @@ evas_render_object_recalc(Evas_Object *obj)
}
}
+void
+evas_render_object_calc(Evas_Object *obj)
+{
+ MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
+ return;
+ MAGIC_CHECK_END();
+
+ if ((!obj->recalc) && (obj->delete_me < 2))
+ {
+ Evas *e;
+
+ e = obj->layer->evas;
+ if (!e || e->cleanup) return ;
+
+ if (!obj->recalc)
+ _evas_array_append(&e->calculate_objects, obj);
+ obj->recalc = 1;
+ }
+}
diff --git a/src/lib/include/evas_private.h b/src/lib/include/evas_private.h
index 7e73815..7ba0829 100644
--- a/src/lib/include/evas_private.h
+++ b/src/lib/include/evas_private.h
@@ -287,6 +287,7 @@ struct _Evas
Evas_Array pending_objects;
Evas_Array obscuring_objects;
Evas_Array temporary_objects;
+ Evas_Array calculate_objects;
int delete_grabs;
int walking_grabs;
@@ -426,6 +427,7 @@ struct _Evas_Object
Evas_Bool changed : 1;
Evas_Bool is_active : 1;
Evas_Bool render_pre : 1;
+ Evas_Bool recalc : 1;
Evas_Bool rect_del : 1;
Evas_Bool mouse_in : 1;
Evas_Bool pre_render_done : 1;
@@ -743,8 +745,9 @@ EAPI int _evas_module_engine_inherit(Evas_Func *funcs, char *name);
void evas_render_invalidate(Evas *e);
void evas_render_object_recalc(Evas_Object *obj);
+void evas_render_object_calc(Evas_Object *obj);
-#define EVAS_API_OVERRIDE(func, api, prefix) \
+#define EVAS_API_OVERRIDE(func, api, prefix) \
(api)->func = prefix##func
#include "evas_inline.x"
diff --git a/src/bin/e_box.c b/src/bin/e_box.c
index f610a86..401de38 100644
--- a/src/bin/e_box.c
+++ b/src/bin/e_box.c
@@ -652,6 +652,7 @@ _e_box_smart_init(void)
_e_box_smart_color_set,
_e_box_smart_clip_set,
_e_box_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
diff --git a/src/bin/e_editable.c b/src/bin/e_editable.c
index fdb3965..eae56e3 100644
--- a/src/bin/e_editable.c
+++ b/src/bin/e_editable.c
@@ -87,6 +87,7 @@ e_editable_add(Evas *evas)
_e_editable_color_set,
_e_editable_clip_set,
_e_editable_clip_unset,
+ NULL,
NULL
};
_e_editable_smart = evas_smart_class_new(&sc);
diff --git a/src/bin/e_entry.c b/src/bin/e_entry.c
index f19d068..a08664d 100644
--- a/src/bin/e_entry.c
+++ b/src/bin/e_entry.c
@@ -93,6 +93,7 @@ e_entry_add(Evas *evas)
_e_entry_color_set,
_e_entry_clip_set,
_e_entry_clip_unset,
+ NULL,
NULL
};
_e_entry_smart = evas_smart_class_new(&sc);
diff --git a/src/bin/e_flowlayout.c b/src/bin/e_flowlayout.c
index 8e0bdfd..9e85a7a 100644
--- a/src/bin/e_flowlayout.c
+++ b/src/bin/e_flowlayout.c
@@ -836,6 +836,7 @@ _e_flowlayout_smart_init(void)
_e_flowlayout_smart_color_set,
_e_flowlayout_smart_clip_set,
_e_flowlayout_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
diff --git a/src/bin/e_fm.c b/src/bin/e_fm.c
index c8b8381..2a64331 100644
--- a/src/bin/e_fm.c
+++ b/src/bin/e_fm.c
@@ -418,6 +418,7 @@ e_fm2_init(void)
_e_fm2_smart_color_set, /* color_set */
_e_fm2_smart_clip_set, /* clip_set */
_e_fm2_smart_clip_unset, /* clip_unset */
+ NULL,
NULL
};
_e_fm2_smart = evas_smart_class_new(&sc);
diff --git a/src/bin/e_gadcon.c b/src/bin/e_gadcon.c
index 733f9ec..bb55637 100644
--- a/src/bin/e_gadcon.c
+++ b/src/bin/e_gadcon.c
@@ -3108,6 +3108,7 @@ _e_gadcon_layout_smart_init(void)
_e_gadcon_layout_smart_color_set,
_e_gadcon_layout_smart_clip_set,
_e_gadcon_layout_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
diff --git a/src/bin/e_icon.c b/src/bin/e_icon.c
index 7f2d73c..db05930 100644
--- a/src/bin/e_icon.c
+++ b/src/bin/e_icon.c
@@ -345,6 +345,7 @@ _e_icon_smart_init(void)
_e_icon_smart_color_set,
_e_icon_smart_clip_set,
_e_icon_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
diff --git a/src/bin/e_ilist.c b/src/bin/e_ilist.c
index dab1093..a061e24 100644
--- a/src/bin/e_ilist.c
+++ b/src/bin/e_ilist.c
@@ -728,6 +728,7 @@ _e_smart_init(void)
_e_smart_color_set,
_e_smart_clip_set,
_e_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
diff --git a/src/bin/e_layout.c b/src/bin/e_layout.c
index e0a60fa..d105525 100644
--- a/src/bin/e_layout.c
+++ b/src/bin/e_layout.c
@@ -364,6 +364,7 @@ _e_layout_smart_init(void)
_e_layout_smart_color_set,
_e_layout_smart_clip_set,
_e_layout_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
diff --git a/src/bin/e_livethumb.c b/src/bin/e_livethumb.c
index 33f1bec..d5acd96 100644
--- a/src/bin/e_livethumb.c
+++ b/src/bin/e_livethumb.c
@@ -210,6 +210,7 @@ _e_smart_init(void)
_e_smart_color_set,
_e_smart_clip_set,
_e_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
diff --git a/src/bin/e_pan.c b/src/bin/e_pan.c
index 7dd946f..4b55c2b 100644
--- a/src/bin/e_pan.c
+++ b/src/bin/e_pan.c
@@ -263,6 +263,7 @@ _e_smart_init(void)
_e_smart_color_set,
_e_smart_clip_set,
_e_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
diff --git a/src/bin/e_scrollframe.c b/src/bin/e_scrollframe.c
index fa72ea2..1d6df86 100644
--- a/src/bin/e_scrollframe.c
+++ b/src/bin/e_scrollframe.c
@@ -1042,6 +1042,7 @@ _e_smart_init(void)
_e_smart_color_set,
_e_smart_clip_set,
_e_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
diff --git a/src/bin/e_slidecore.c b/src/bin/e_slidecore.c
index 82d2d90..3c5383a 100644
--- a/src/bin/e_slidecore.c
+++ b/src/bin/e_slidecore.c
@@ -410,6 +410,7 @@ _e_smart_init(void)
_e_smart_color_set,
_e_smart_clip_set,
_e_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
diff --git a/src/bin/e_slider.c b/src/bin/e_slider.c
index a1dd15a..2f78898 100644
--- a/src/bin/e_slider.c
+++ b/src/bin/e_slider.c
@@ -542,6 +542,7 @@ _e_smart_init(void)
_e_smart_color_set,
_e_smart_clip_set,
_e_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
diff --git a/src/bin/e_slidesel.c b/src/bin/e_slidesel.c
index 8ba7f23..ee4cf8c 100644
--- a/src/bin/e_slidesel.c
+++ b/src/bin/e_slidesel.c
@@ -366,6 +366,7 @@ _e_smart_init(void)
_e_smart_color_set,
_e_smart_clip_set,
_e_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
diff --git a/src/bin/e_spectrum.c b/src/bin/e_spectrum.c
index 6c98bc6..4380014 100644
--- a/src/bin/e_spectrum.c
+++ b/src/bin/e_spectrum.c
@@ -167,6 +167,7 @@ _e_spectrum_smart_init(void)
_e_spectrum_smart_color_set,
_e_spectrum_smart_clip_set,
_e_spectrum_smart_clip_unset,
+ NULL,
NULL
};
_e_spectrum_smart = evas_smart_class_new(&sc);
diff --git a/src/bin/e_table.c b/src/bin/e_table.c
index 2661995..b602bac 100644
--- a/src/bin/e_table.c
+++ b/src/bin/e_table.c
@@ -839,6 +839,7 @@ _e_table_smart_init(void)
_e_table_smart_color_set,
_e_table_smart_clip_set,
_e_table_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
diff --git a/src/bin/e_tlist.c b/src/bin/e_tlist.c
index 4d559d2..9a497e5 100644
--- a/src/bin/e_tlist.c
+++ b/src/bin/e_tlist.c
@@ -537,7 +537,7 @@ _e_smart_init(void)
EVAS_SMART_CLASS_VERSION,
_e_smart_add, _e_smart_del, _e_smart_move, _e_smart_resize,
_e_smart_show, _e_smart_hide, _e_smart_color_set,
- _e_smart_clip_set, _e_smart_clip_unset, NULL
+ _e_smart_clip_set, _e_smart_clip_unset, NULL, NULL
};
_e_smart = evas_smart_class_new(&sc);
}
diff --git a/src/bin/e_widget.c b/src/bin/e_widget.c
index d69a3d4..953c014 100644
--- a/src/bin/e_widget.c
+++ b/src/bin/e_widget.c
@@ -577,6 +577,7 @@ _e_smart_init(void)
_e_smart_color_set,
_e_smart_clip_set,
_e_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel