From bfcec2d7ae02f6c82f4e341a4279eb2a736c3e81 Mon Sep 17 00:00:00 2001 From: cedric Date: Tue, 17 Jul 2012 09:09:45 +0000 Subject: [PATCH] evas: fix evas map life cycle. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@73963 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- ChangeLog | 1 + NEWS | 1 + src/lib/canvas/evas_map.c | 76 ++++++++++++++++++++++++---------- src/lib/canvas/evas_object_image.c | 2 +- src/lib/canvas/evas_object_line.c | 2 +- src/lib/canvas/evas_object_main.c | 13 ++++++ src/lib/canvas/evas_object_polygon.c | 2 +- src/lib/canvas/evas_object_rectangle.c | 2 +- src/lib/canvas/evas_object_smart.c | 2 +- src/lib/canvas/evas_object_text.c | 2 +- src/lib/canvas/evas_object_textblock.c | 2 +- src/lib/canvas/evas_object_textgrid.c | 2 +- src/lib/include/evas_private.h | 2 + 13 files changed, 78 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 247fc54..f127ad8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -888,4 +888,5 @@ 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 --- 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. diff --git a/src/lib/canvas/evas_map.c b/src/lib/canvas/evas_map.c index 23c8de1..df3f165 100644 --- a/src/lib/canvas/evas_map.c +++ b/src/lib/canvas/evas_map.c @@ -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); diff --git a/src/lib/canvas/evas_object_image.c b/src/lib/canvas/evas_object_image.c index b18ac65..cefbd05 100644 --- a/src/lib/canvas/evas_object_image.c +++ b/src/lib/canvas/evas_object_image.c @@ -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 */ diff --git a/src/lib/canvas/evas_object_line.c b/src/lib/canvas/evas_object_line.c index b58fe40..177421d 100644 --- a/src/lib/canvas/evas_object_line.c +++ b/src/lib/canvas/evas_object_line.c @@ -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; } diff --git a/src/lib/canvas/evas_object_main.c b/src/lib/canvas/evas_object_main.c index 44eb6bd..d20be57 100644 --- a/src/lib/canvas/evas_object_main.c +++ b/src/lib/canvas/evas_object_main.c @@ -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; diff --git a/src/lib/canvas/evas_object_polygon.c b/src/lib/canvas/evas_object_polygon.c index 0bb740a..34931b2 100644 --- a/src/lib/canvas/evas_object_polygon.c +++ b/src/lib/canvas/evas_object_polygon.c @@ -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; } diff --git a/src/lib/canvas/evas_object_rectangle.c b/src/lib/canvas/evas_object_rectangle.c index da38342..fa90f42 100644 --- a/src/lib/canvas/evas_object_rectangle.c +++ b/src/lib/canvas/evas_object_rectangle.c @@ -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 diff --git a/src/lib/canvas/evas_object_smart.c b/src/lib/canvas/evas_object_smart.c index 28ed4cb..82f0368 100644 --- a/src/lib/canvas/evas_object_smart.c +++ b/src/lib/canvas/evas_object_smart.c @@ -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) diff --git a/src/lib/canvas/evas_object_text.c b/src/lib/canvas/evas_object_text.c index 606496d..2afc588 100644 --- a/src/lib/canvas/evas_object_text.c +++ b/src/lib/canvas/evas_object_text.c @@ -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; } diff --git a/src/lib/canvas/evas_object_textblock.c b/src/lib/canvas/evas_object_textblock.c index 914a815..51db5d6 100644 --- a/src/lib/canvas/evas_object_textblock.c +++ b/src/lib/canvas/evas_object_textblock.c @@ -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; */ } diff --git a/src/lib/canvas/evas_object_textgrid.c b/src/lib/canvas/evas_object_textgrid.c index ae7693e..f047518 100644 --- a/src/lib/canvas/evas_object_textgrid.c +++ b/src/lib/canvas/evas_object_textgrid.c @@ -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; diff --git a/src/lib/include/evas_private.h b/src/lib/include/evas_private.h index 18d440a..ad6785a 100644 --- a/src/lib/include/evas_private.h +++ b/src/lib/include/evas_private.h @@ -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); -- 2.7.4