evas: fix evas map life cycle.
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 17 Jul 2012 09:09:45 +0000 (09:09 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 17 Jul 2012 09:09:45 +0000 (09:09 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@73963 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

13 files changed:
ChangeLog
NEWS
src/lib/canvas/evas_map.c
src/lib/canvas/evas_object_image.c
src/lib/canvas/evas_object_line.c
src/lib/canvas/evas_object_main.c
src/lib/canvas/evas_object_polygon.c
src/lib/canvas/evas_object_rectangle.c
src/lib/canvas/evas_object_smart.c
src/lib/canvas/evas_object_text.c
src/lib/canvas/evas_object_textblock.c
src/lib/canvas/evas_object_textgrid.c
src/lib/include/evas_private.h

index 247fc54..f127ad8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 2012-07-17  Cedric Bail
 
        * Fix garbage left by mapped smart object when they fly away from the canvas.
+       * Fix map life cycle.
 
diff --git a/NEWS b/NEWS
index 8caf2b0..4075b4c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,7 @@ Fixes:
    * Add svg rendering with Esvg
    * Don't accept broken map.
    * Fix garbage left by mapped smart object when they fly away from the canvas.
+   * Fix map life cycle.
 
 Removal:
    * Remove EVAS_FRAME_QUEUING, EVAS_SLI, METRIC_CACHE and WORD_CACHE.
index 23c8de1..df3f165 100644 (file)
@@ -42,36 +42,46 @@ _evas_map_calc_map_geometry(Evas_Object *obj)
    // It has an infinite loop bug.
    if (obj->prev.map)
      {
-        // FIXME: this causes an infinite loop somewhere... hard to debug
-        if (obj->prev.map->count == obj->cur.map->count)
+        if (obj->prev.map != obj->cur.map)
           {
-             const Evas_Map_Point *p2;
+             // FIXME: this causes an infinite loop somewhere... hard to debug
+             if (obj->prev.map->count == obj->cur.map->count)
+               {
+                  const Evas_Map_Point *p2;
 
-             p = obj->cur.map->points;
-             p_end = p + obj->cur.map->count;
-             p2 = obj->prev.map->points;
+                  p = obj->cur.map->points;
+                  p_end = p + obj->cur.map->count;
+                  p2 = obj->prev.map->points;
 
-             for (; p < p_end; p++, p2++)
-               {
-                  if ((p->a != p2->a) ||
-                      (p->r != p2->r) ||
-                      (p->g != p2->g) ||
-                      (p->b != p2->b))
+                  for (; p < p_end; p++, p2++)
                     {
-                       ch = 1;
-                       break;
+                       if ((p->a != p2->a) ||
+                           (p->r != p2->r) ||
+                           (p->g != p2->g) ||
+                           (p->b != p2->b))
+                         {
+                            ch = 1;
+                            break;
+                         }
+                       if ((p->x != p2->x) ||
+                           (p->y != p2->y) ||
+                           (p->z != p2->z))
+                         {
+                            ch = 1;
+                            break;
+                         }
                     }
-                  if ((p->x != p2->x) ||
-                      (p->y != p2->y) ||
-                      (p->z != p2->z))
+
+                  if (!ch)
                     {
-                       ch = 1;
-                       break;
+                       if (obj->cache_map) evas_map_free(obj->cache_map); 
+                       obj->cache_map = obj->cur.map;
+                       obj->cur.map = obj->prev.map;
                     }
                }
+             else
+               ch = 1;
           }
-        else
-           ch = 1;
      }
    else
       ch = 1;
@@ -468,8 +478,19 @@ evas_object_map_set(Evas_Object *obj, const Evas_Map *map)
                   obj->cur.map->surface = NULL;
                }
              obj->prev.geometry = obj->cur.map->normal_geometry;
-             _evas_map_free(obj, obj->cur.map);
-             obj->cur.map = NULL;
+
+             if (obj->prev.map == obj->cur.map)
+               obj->cur.map = NULL;
+             else if (!obj->cache_map)
+               {
+                  obj->cache_map = obj->cur.map;
+                  obj->cur.map = NULL;
+               }
+             else
+               {
+                  _evas_map_free(obj, obj->cur.map);
+                  obj->cur.map = NULL;
+               }
 
              if (!obj->prev.map)
                {
@@ -485,6 +506,15 @@ evas_object_map_set(Evas_Object *obj, const Evas_Map *map)
         return;
      }
 
+   if (obj->prev.map == obj->cur.map)
+     obj->cur.map = NULL;
+
+   if (!obj->cur.map)
+     {
+        obj->cur.map = obj->cache_map;
+        obj->cache_map = NULL;
+     }
+
    // We do have the same exact count of point in this map, so just copy it
    if ((obj->cur.map) && (obj->cur.map->count == map->count))
      _evas_map_copy(obj->cur.map, map);
index b18ac65..cefbd05 100644 (file)
@@ -3456,7 +3456,7 @@ evas_object_image_render_post(Evas_Object *obj)
    EINA_LIST_FREE(o->pixel_updates, r)
      eina_rectangle_free(r);
    /* move cur to prev safely for object data */
-   obj->prev = obj->cur;
+   evas_object_cur_prev(obj);
    o->prev = o->cur;
    o->changed = 0;
    /* FIXME: copy strings across */
index b58fe40..177421d 100644 (file)
@@ -379,7 +379,7 @@ evas_object_line_render_post(Evas_Object *obj)
    /* remove those pesky changes */
    evas_object_clip_changes_clean(obj);
    /* move cur to prev safely for object data */
-   obj->prev = obj->cur;
+   evas_object_cur_prev(obj);
    o->prev = o->cur;
    o->changed = EINA_FALSE;
 }
index 44eb6bd..d20be57 100644 (file)
@@ -41,6 +41,17 @@ evas_object_change_reset(Evas_Object *obj)
 }
 
 void
+evas_object_cur_prev(Evas_Object *obj)
+{
+   if (obj->cur.map != obj->prev.map)
+     {
+        if (obj->cache_map) evas_map_free(obj->cache_map);
+        obj->cache_map = obj->prev.map;
+     }
+   obj->prev = obj->cur;
+}
+
+void
 evas_object_free(Evas_Object *obj, int clean_layer)
 {
    int was_smart_child = 0;
@@ -50,6 +61,8 @@ evas_object_free(Evas_Object *obj, int clean_layer)
 #endif
    if (!strcmp(obj->type, "image")) evas_object_image_video_surface_set(obj, NULL);
    evas_object_map_set(obj, NULL);
+   if (obj->prev.map) evas_map_free(obj->prev.map);
+   if (obj->cache_map) evas_map_free(obj->cache_map);
    evas_object_grabs_cleanup(obj);
    evas_object_intercept_cleanup(obj);
    if (obj->smart.parent) was_smart_child = 1;
index 0bb740a..34931b2 100644 (file)
@@ -439,7 +439,7 @@ evas_object_polygon_render_post(Evas_Object *obj)
    /* remove those pesky changes */
    evas_object_clip_changes_clean(obj);
    /* move cur to prev safely for object data */
-   obj->prev = obj->cur;
+   evas_object_cur_prev(obj);
    o->changed = 0;
 }
 
index da38342..fa90f42 100644 (file)
@@ -279,7 +279,7 @@ evas_object_rectangle_render_post(Evas_Object *obj)
    /* remove those pesky changes */
    evas_object_clip_changes_clean(obj);
    /* move cur to prev safely for object data */
-   obj->prev = obj->cur;
+   evas_object_cur_prev(obj);
 }
 
 static int
index 28ed4cb..82f0368 100644 (file)
@@ -1234,7 +1234,7 @@ evas_object_smart_render_pre(Evas_Object *obj)
 static void
 evas_object_smart_render_post(Evas_Object *obj)
 {
-   obj->prev = obj->cur;
+   evas_object_cur_prev(obj);
 }
 
 static unsigned int evas_object_smart_id_get(Evas_Object *obj)
index 606496d..2afc588 100644 (file)
@@ -1795,7 +1795,7 @@ evas_object_text_render_post(Evas_Object *obj)
    /* remove those pesky changes */
    evas_object_clip_changes_clean(obj);
    /* move cur to prev safely for object data */
-   obj->prev = obj->cur;
+   evas_object_cur_prev(obj);
    o->prev = o->cur;
    o->changed = 0;
 }
index 914a815..51db5d6 100644 (file)
@@ -9869,7 +9869,7 @@ evas_object_textblock_render_post(Evas_Object *obj)
    /* remove those pesky changes */
    evas_object_clip_changes_clean(obj);
    /* move cur to prev safely for object data */
-   obj->prev = obj->cur;
+   evas_object_cur_prev(obj);
 /*   o->prev = o->cur; */
 /*   o->changed = 0; */
 }
index ae7693e..f047518 100644 (file)
@@ -841,7 +841,7 @@ evas_object_textgrid_render_post(Evas_Object *obj)
    /* remove those pesky changes */
    evas_object_clip_changes_clean(obj);
    /* move cur to prev safely for object data */
-   obj->prev = obj->cur;
+   evas_object_cur_prev(obj);
    o->prev = o->cur;
    o->changed = 0;
 
index 18d440a..ad6785a 100644 (file)
@@ -543,6 +543,7 @@ struct _Evas_Object
       Eina_Bool             parent_cached_surface : 1;
    } cur, prev;
 
+   Evas_Map                   *cache_map;
    char                       *name;
 
    Evas_Intercept_Func        *interceptors;
@@ -911,6 +912,7 @@ extern "C" {
 
 Evas_Object *evas_object_new(Evas *e);
 void evas_object_change_reset(Evas_Object *obj);
+void evas_object_cur_prev(Evas_Object *obj);
 void evas_object_free(Evas_Object *obj, int clean_layer);
 void evas_object_update_bounding_box(Evas_Object *obj);
 void evas_object_inject(Evas_Object *obj, Evas *e);