Attached is a patch (txt so gmail/firefox don't think it's an
octet-stream and is removed by mailman) to add pre_render() to
Evas_Smart_Class. This patch applies on e17/libs and hacks edje and
emotion so we can test.

CAUTION: if you compile and install Evas with this patch, it will
change the EVAS_SMART_CLASS_VERSION, making ALL existing binaries
incompatible, so if you do this and your E or other Evas-dependent
application crashes, it will not restart until you reverse the patch,
compile and install the old (non-patched) Evas.

USE CASE:

Most users of smart objects end with nasty freeze/thaw to avoid heavy
computations, this can be seen in many places, including Edje. It
would be lot better if we could avoid this if we know when we need to
compute, recalc, reconfigure, ... things. And we know: before drawing!
So why not make this automatic?

IMPLEMENTATION:

I don't know this part of Evas internals that much, but I hacked it as
a walk of all objects (layers, then its objects) and checking if
object changed and if it is a smart and if it has the new pre_render
callback. In this case, call this function.   This is done BEFORE any
other stuff, before obscure, dirty, etc... calcs, so it will not
impact existing evas_render code at all.
    In order to mark smart objects dirty without doing any operation,
I added evas_object_smart_changed(), that will call
evas_object_changed(). Maybe something better could be done?

Edje was changed and _edje_recalc() just calls
evas_object_smart_changed(), while _edje_recalc_do() will do the
actual work. THIS IS A TEMPORARY HACK.

Emotion has no callback, so pre_render = NULL, just to make it compile.



NEXT STEPS:

If this proves to be correct, we need to patch all uses of
Evas_Smart_Class. This is about 50 on current cvs e17.


-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: [EMAIL PROTECTED]
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202
Index: edje/src/lib/edje_calc.c
===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/edje_calc.c,v
retrieving revision 1.127
diff -u -p -r1.127 edje_calc.c
--- edje/src/lib/edje_calc.c    7 Jun 2008 10:06:13 -0000       1.127
+++ edje/src/lib/edje_calc.c    14 Aug 2008 22:55:39 -0000
@@ -136,7 +136,16 @@ _edje_part_description_apply(Edje *ed, E
 void
 _edje_recalc(Edje *ed)
 {
+   puts("_edje_recalc postponed");
+   evas_object_smart_changed(ed->obj);
+}
+
+void
+_edje_recalc_do(Edje *ed)
+{
    int i;
+
+   puts(">>>>>>>>>> DO EDJE RECALC!");
 
    if (!ed->dirty) return;
    if (ed->freeze)
Index: edje/src/lib/edje_private.h
===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/edje_private.h,v
retrieving revision 1.154
diff -u -p -r1.154 edje_private.h
--- edje/src/lib/edje_private.h 14 Aug 2008 18:21:27 -0000      1.154
+++ edje/src/lib/edje_private.h 14 Aug 2008 22:55:39 -0000
@@ -1007,6 +1007,7 @@ void  _edje_part_pos_set(Edje *ed, Edje_
 Edje_Part_Description *_edje_part_description_find(Edje *ed, Edje_Real_Part 
*rp, const char *name, double val);
 void  _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, const char  
*d1, double v1, const char *d2, double v2);
 void  _edje_recalc(Edje *ed);
+void  _edje_recalc_do(Edje *ed);
 int   _edje_part_dragable_calc(Edje *ed, Edje_Real_Part *ep, double *x, double 
*y);
 void  _edje_dragable_pos_set(Edje *ed, Edje_Real_Part *ep, double x, double y);
 
Index: edje/src/lib/edje_smart.c
===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/edje_smart.c,v
retrieving revision 1.35
diff -u -p -r1.35 edje_smart.c
--- edje/src/lib/edje_smart.c   7 Jun 2008 10:06:13 -0000       1.35
+++ edje/src/lib/edje_smart.c   14 Aug 2008 22:55:39 -0000
@@ -13,6 +13,7 @@ static void _edje_smart_hide(Evas_Object
 static void _edje_smart_color_set(Evas_Object * obj, int r, int g, int b, int 
a);
 static void _edje_smart_clip_set(Evas_Object * obj, Evas_Object * clip);
 static void _edje_smart_clip_unset(Evas_Object * obj);
+static void _edje_smart_pre_render(Evas_Object * obj);
 
 static Evas_Smart *_edje_smart = NULL;
 
@@ -45,6 +46,7 @@ edje_object_add(Evas *evas)
               _edje_smart_color_set,
               _edje_smart_clip_set,
               _edje_smart_clip_unset,
+              _edje_smart_pre_render,
               NULL
          };
        _edje_smart = evas_smart_class_new(&sc);
@@ -236,4 +238,15 @@ _edje_smart_clip_unset(Evas_Object * obj
    if (!evas_object_clip_get(obj)) return;
    evas_object_clip_unset(ed->clipper);
 //   _edje_emit(ed, "clip_unset", NULL);
+}
+
+static void
+_edje_smart_pre_render(Evas_Object *obj)
+{
+   Edje *ed;
+
+   ed = evas_object_smart_data_get(obj);
+   if (!ed) return;
+   puts("_edje_smart_pre_render!");
+   _edje_recalc_do(ed);
 }
Index: emotion/src/lib/emotion_smart.c
===================================================================
RCS file: /cvs/e/e17/libs/emotion/src/lib/emotion_smart.c,v
retrieving revision 1.41
diff -u -p -r1.41 emotion_smart.c
--- emotion/src/lib/emotion_smart.c     15 May 2008 16:52:04 -0000      1.41
+++ emotion/src/lib/emotion_smart.c     14 Aug 2008 22:55:39 -0000
@@ -1164,6 +1164,7 @@ _smart_init(void)
               _smart_color_set,
               _smart_clip_set,
               _smart_clip_unset,
+              NULL,
               NULL
          };
         smart = evas_smart_class_new(&sc);
Index: evas/src/lib/Evas.h
===================================================================
RCS file: /cvs/e/e17/libs/evas/src/lib/Evas.h,v
retrieving revision 1.129
diff -u -p -r1.129 Evas.h
--- evas/src/lib/Evas.h 6 Aug 2008 02:37:24 -0000       1.129
+++ evas/src/lib/Evas.h 14 Aug 2008 22:55:40 -0000
@@ -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 obj
    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  (*pre_render)  (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);
Index: evas/src/lib/canvas/evas_object_smart.c
===================================================================
RCS file: /cvs/e/e17/libs/evas/src/lib/canvas/evas_object_smart.c,v
retrieving revision 1.31
diff -u -p -r1.31 evas_object_smart.c
--- evas/src/lib/canvas/evas_object_smart.c     1 May 2008 05:48:03 -0000       
1.31
+++ evas/src/lib/canvas/evas_object_smart.c     14 Aug 2008 22:55:40 -0000
@@ -429,6 +429,21 @@ evas_object_smart_callback_call(Evas_Obj
    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);
+}
+
+
 /* internal calls */
 static void
 evas_object_smart_callbacks_clear(Evas_Object *obj)
Index: evas/src/lib/canvas/evas_render.c
===================================================================
RCS file: /cvs/e/e17/libs/evas/src/lib/canvas/evas_render.c,v
retrieving revision 1.34
diff -u -p -r1.34 evas_render.c
--- evas/src/lib/canvas/evas_render.c   18 Jul 2008 13:31:06 -0000      1.34
+++ evas/src/lib/canvas/evas_render.c   14 Aug 2008 22:55:40 -0000
@@ -325,6 +325,34 @@ Evas_Bool pending_change(void *data, voi
    return obj->changed;
 }
 
+static void
+_evas_render_call_smart_pre_renders_on_layer(Evas_Layer *layer)
+{
+   Evas_Object_List *l;
+
+   for (l = (Evas_Object_List *)layer->objects; l; l = l->next)
+     {
+       Evas_Object *obj = (Evas_Object *)l;
+
+       if (obj->changed && obj->smart.smart &&
+           obj->smart.smart->smart_class &&
+           obj->smart.smart->smart_class->pre_render)
+         obj->smart.smart->smart_class->pre_render(obj);
+     }
+}
+
+static void
+_evas_render_call_smart_pre_renders(Evas *e)
+{
+   Evas_Object_List *l;
+
+   for (l = (Evas_Object_List *)e->layers; l; l = l->next)
+     {
+       Evas_Layer *layer = (Evas_Layer *)l;
+       _evas_render_call_smart_pre_renders_on_layer(layer);
+     }
+}
+
 static Evas_List *
 evas_render_updates_internal(Evas *e, unsigned char make_updates, unsigned 
char do_draw)
 {
@@ -340,6 +368,8 @@ evas_render_updates_internal(Evas *e, un
    return NULL;
    MAGIC_CHECK_END();
    if (!e->changed) return NULL;
+
+   _evas_render_call_smart_pre_renders(e);
 
    /* Check if the modified object mean recalculating every thing */
    if (!e->invalidate)
-------------------------------------------------------------------------
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

Reply via email to