From: Enlightenment S. <no-...@en...> - 2009-12-18 17:46:01
|
Log: Elm map : increase the speed when marker are updated Author: watchwolf Date: 2009-12-18 09:45:47 -0800 (Fri, 18 Dec 2009) New Revision: 44549 Modified: trunk/TMP/st/elementary/src/lib/elm_map.c Modified: trunk/TMP/st/elementary/src/lib/elm_map.c =================================================================== --- trunk/TMP/st/elementary/src/lib/elm_map.c 2009-12-18 17:41:43 UTC (rev 44548) +++ trunk/TMP/st/elementary/src/lib/elm_map.c 2009-12-18 17:45:47 UTC (rev 44549) @@ -162,7 +162,7 @@ Ecore_Job *markers_place_job; Eina_Matrixsparse *markers[19]; - Eina_List *groups_displayed; + Eina_List *cells_displayed; // list of Eina_Matrixsparse_Cell Evas_Coord markers_max_num; Evas_Coord marker_w, marker_h; Evas_Coord marker_max_w, marker_max_h; @@ -204,7 +204,7 @@ static void marker_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh); static void _bubble_sc_hits_changed_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void +static void rect_place(Evas_Object *obj, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh) { Widget_Data *wd = elm_widget_data_get(obj); @@ -233,12 +233,13 @@ } } -static void +static void marker_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh) { Widget_Data *wd = elm_widget_data_get(obj); Evas_Coord ax, ay, gw, gh, tx, ty; Eina_List *l, *l_next, *markers; + Eina_Matrixsparse_Cell *cell; Marker_Group *group; int xx, yy, ww, hh; char buf[PATH_MAX]; @@ -257,46 +258,18 @@ if(wd->zoom != wd->marker_zoom) { - EINA_LIST_FOREACH_SAFE(wd->groups_displayed, l, l_next, group) + EINA_LIST_FREE(wd->cells_displayed, cell) { - if(group->obj) + EINA_LIST_FOREACH_SAFE(eina_matrixsparse_cell_data_get(cell), l, l_next, group) { - _group_object_free(group); + if(group->obj) + _group_object_free(group); } } } wd->marker_zoom = wd->zoom; - //hide groups no more displayed - EINA_LIST_FOREACH_SAFE(wd->groups_displayed, l, l_next, group) - { - xx = group->x; - yy = group->y; - ww = group->w; - hh = group->h; - - if(ww<=0) ww = 1; - if(hh<=0) hh = 1; - - if ((gw != g->w) && (g->w > 0)) - { - tx = xx; - xx = ((long long )gw * xx) / g->w; - ww = (((long long)gw * (tx + ww)) / g->w) - xx; - } - if ((gh != g->h) && (g->h > 0)) - { - ty = yy; - yy = ((long long)gh * yy) / g->h; - hh = (((long long)gh * (ty + hh)) / g->h) - yy; - } - - if(group->obj && - !(xx-px+ax+ox >= ox && xx-px+ax+ox<= ox+ow - && yy-py+ay+oy >= oy && yy-py+ay+oy<= oy+oh)) - _group_object_free(group); - } - + g_xx = wd->pan_x / wd->tsize; if(g_xx < 0) g_xx = 0; @@ -309,10 +282,29 @@ g_hh = oh / wd->tsize + 1; if(g_yy + g_hh >= g->gh) g_hh = g->gh - g_yy - 1; + //hide groups no more displayed + EINA_LIST_FREE(wd->cells_displayed, cell) + { + eina_matrixsparse_cell_position_get(cell, (unsigned long *)&y, (unsigned long *)&x); + if(y < g_yy || y > g_yy + g_hh || x < g_xx || x > g_xx + g_ww) + { + EINA_LIST_FOREACH_SAFE(eina_matrixsparse_cell_data_get(cell), l, l_next, group) + { + if(group->obj) + _group_object_free(group); + } + } + } + for (y = g_yy; y <= g_yy + g_hh; y++) { for (x = g_xx; x <= g_xx + g_ww; x++) { + eina_matrixsparse_cell_idx_get(wd->markers[wd->zoom], y, x, &cell); + if(!cell) + continue ; + wd->cells_displayed = eina_list_append(wd->cells_displayed, cell); + if(!wd->markers[wd->zoom]) continue ; @@ -377,7 +369,7 @@ } } -static void +static void grid_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh) { Widget_Data *wd = elm_widget_data_get(obj); @@ -430,7 +422,7 @@ eina_iterator_free(it); } -static void +static void grid_clear(Evas_Object *obj, Grid *g) { Widget_Data *wd = elm_widget_data_get(obj); @@ -481,7 +473,7 @@ g->gh = 0; } -static void +static void _tile_update(Grid_Item *gi) { gi->want = EINA_FALSE; @@ -506,7 +498,7 @@ } -static void +static void _tile_downloaded(void *data, const char *file, int status) { Grid_Item *gi = data; @@ -551,7 +543,7 @@ return g; } -static void +static void grid_load(Evas_Object *obj, Grid *g) { Widget_Data *wd = elm_widget_data_get(obj); @@ -743,7 +735,7 @@ } } -static void +static void grid_clearall(Evas_Object *obj) { Widget_Data *wd = elm_widget_data_get(obj); @@ -756,7 +748,7 @@ } } -static void +static void _smooth_update(Evas_Object *obj) { Widget_Data *wd = elm_widget_data_get(obj); @@ -777,7 +769,7 @@ } } -static void +static void _grid_raise(Grid *g) { Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid); @@ -795,7 +787,7 @@ eina_iterator_free(it); } -static int +static int _scr_timeout(void *data) { Widget_Data *wd = elm_widget_data_get(data); @@ -805,7 +797,7 @@ return 0; } -static void +static void _scr(void *data, Evas_Object *obj, void *event_info) { Widget_Data *wd = elm_widget_data_get(data); @@ -818,7 +810,7 @@ wd->scr_timer = ecore_timer_add(0.5, _scr_timeout, data); } -static int +static int zoom_do(Evas_Object *obj, double t) { Widget_Data *wd = elm_widget_data_get(obj); @@ -863,7 +855,7 @@ return 1; } -static int +static int _zoom_anim(void *data) { Evas_Object *obj = data; @@ -891,7 +883,7 @@ return go; } -static int +static int _long_press(void *data) { Widget_Data *wd = elm_widget_data_get(data); @@ -901,7 +893,7 @@ return 0; } -static void +static void _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info) { Widget_Data *wd = elm_widget_data_get(data); @@ -918,7 +910,7 @@ wd->long_timer = ecore_timer_add(1.0, _long_press, data); } -static void +static void _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info) { Widget_Data *wd = elm_widget_data_get(data); @@ -938,7 +930,7 @@ static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_NULL; -static void +static void _del_hook(Evas_Object *obj) { Widget_Data *wd = elm_widget_data_get(obj); @@ -951,7 +943,7 @@ free(wd); } -static void +static void _del_pre_hook(Evas_Object *obj) { Marker_Group *group; @@ -996,7 +988,7 @@ wd->pan_smart = NULL; } -static void +static void _theme_hook(Evas_Object *obj) { Widget_Data *wd = elm_widget_data_get(obj); @@ -1005,7 +997,7 @@ _sizing_eval(obj); } -static void +static void _sizing_eval(Evas_Object *obj) { Widget_Data *wd = elm_widget_data_get(obj); @@ -1016,7 +1008,7 @@ evas_object_size_hint_max_set(obj, maxw, maxh); } -static void +static void _calc_job(void *data) { Widget_Data *wd = data; @@ -1046,7 +1038,7 @@ evas_object_smart_changed(wd->pan_smart); } -static void +static void _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y) { Pan *sd = evas_object_smart_data_get(obj); @@ -1056,7 +1048,7 @@ evas_object_smart_changed(obj); } -static void +static void _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y) { Pan *sd = evas_object_smart_data_get(obj); @@ -1064,7 +1056,7 @@ if (y) *y = sd->wd->pan_y; } -static void +static void _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y) { Pan *sd = evas_object_smart_data_get(obj); @@ -1078,7 +1070,7 @@ if (y) *y = oh; } -static void +static void _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h) { Pan *sd = evas_object_smart_data_get(obj); @@ -1086,7 +1078,7 @@ if (h) *h = sd->wd->minh; } -static void +static void _pan_add(Evas_Object *obj) { Pan *sd; @@ -1101,7 +1093,7 @@ evas_object_smart_data_set(obj, sd); } -static void +static void _pan_del(Evas_Object *obj) { Pan *sd = evas_object_smart_data_get(obj); @@ -1109,7 +1101,7 @@ _pan_sc.del(obj); } -static void +static void _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h) { Pan *sd = evas_object_smart_data_get(obj); @@ -1121,7 +1113,7 @@ sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd); } -static void +static void _pan_calculate(Evas_Object *obj) { Pan *sd = evas_object_smart_data_get(obj); @@ -1139,7 +1131,7 @@ } } -static void +static void _hold_on(void *data, Evas_Object *obj, void *event_info) { Widget_Data *wd = elm_widget_data_get(obj); @@ -1147,7 +1139,7 @@ elm_smart_scroller_hold_set(wd->scr, 1); } -static void +static void _hold_off(void *data, Evas_Object *obj, void *event_info) { Widget_Data *wd = elm_widget_data_get(obj); @@ -1155,7 +1147,7 @@ elm_smart_scroller_hold_set(wd->scr, 0); } -static void +static void _freeze_on(void *data, Evas_Object *obj, void *event_info) { Widget_Data *wd = elm_widget_data_get(obj); @@ -1163,7 +1155,7 @@ elm_smart_scroller_freeze_set(wd->scr, 1); } -static void +static void _freeze_off(void *data, Evas_Object *obj, void *event_info) { Widget_Data *wd = elm_widget_data_get(obj); @@ -1171,19 +1163,19 @@ elm_smart_scroller_freeze_set(wd->scr, 0); } -static void +static void _scr_anim_start(void *data, Evas_Object *obj, void *event_info) { evas_object_smart_callback_call(data, "scroll,anim,start", NULL); } -static void +static void _scr_anim_stop(void *data, Evas_Object *obj, void *event_info) { evas_object_smart_callback_call(data, "scroll,anim,stop", NULL); } -static void +static void _scr_drag_start(void *data, Evas_Object *obj, void *event_info) { Widget_Data *wd = elm_widget_data_get(data); @@ -1191,20 +1183,20 @@ evas_object_smart_callback_call(data, "scroll,drag,start", NULL); } -static void +static void _scr_drag_stop(void *data, Evas_Object *obj, void *event_info) { evas_object_smart_callback_call(data, "scroll,drag,stop", NULL); } -static void +static void _scr_scroll(void *data, Evas_Object *obj, void *event_info) { evas_object_smart_callback_call(data, "scroll", NULL); } -static void +static void _group_object_create(Marker_Group *group) { if(group->obj) return ; @@ -1233,11 +1225,9 @@ if(group->open) _group_bubble_create(group); - - group->wd->groups_displayed = eina_list_append(group->wd->groups_displayed, group); } -static void +static void _group_object_free(Marker_Group *group) { if(!group->obj) return ; @@ -1251,11 +1241,9 @@ group->obj = NULL; _group_bubble_free(group); - - group->wd->groups_displayed = eina_list_remove(group->wd->groups_displayed, group); } -static void +static void _group_bubble_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) { Marker_Group *group = data; @@ -1267,7 +1255,7 @@ evas_object_raise(group->rect); } -static void +static void _group_bubble_create(Marker_Group *group) { if(group->bubble) return ; @@ -1301,7 +1289,7 @@ _group_bubble_place(data); } -static void +static void _group_bubble_content_update(Marker_Group *group) { Eina_List *l; @@ -1350,7 +1338,7 @@ } } -static void +static void _group_bubble_content_free(Marker_Group *group) { Eina_List *l; @@ -1371,7 +1359,7 @@ group->sc = NULL; } -static void +static void _group_bubble_free(Marker_Group *group) { if(!group->bubble) return ; @@ -1385,7 +1373,7 @@ _group_bubble_content_free(group); } -static void +static void _group_bubble_place(Marker_Group *group) { Evas_Coord x, y, w; @@ -1411,7 +1399,7 @@ evas_object_show(group->rect); } -static void +static void _group_bringin_cb(void *data, Evas_Object *obj, const char *emission, const char *soure) { Marker_Group *group = data; @@ -1422,7 +1410,7 @@ elm_map_geo_region_bring_in(group->wd->obj, marker->longitude, marker->latitude); } -static void +static void _group_open_cb(void *data, Evas_Object *obj, const char *emission, const char *soure) { Marker_Group *group = data; @@ -2038,7 +2026,7 @@ tabi[1] = tabi[4] = tabi[6] = -1; tabi[2] = tabi[0] = tabi[7] = 0; tabi[3] = tabi[5] = tabi[8] = 1; - + tabj[1] = tabj[2] = tabj[3] = -1; tabj[4] = tabj[0] = tabj[5] = 0; tabj[6] = tabj[7] = tabj[8] = 1; @@ -2067,7 +2055,7 @@ for(j=0, group=NULL; j<9 && !group; j++) { - EINA_LIST_FOREACH(eina_matrixsparse_data_idx_get(wd->markers[i], mpj + tabj[j], mpi + tabi[j]), + EINA_LIST_FOREACH(eina_matrixsparse_data_idx_get(wd->markers[i], mpj + tabj[j], mpi + tabi[j]), l, group) { if(ELM_RECTS_INTERSECT( marker->x[i]-sizew/4, marker->y[i]-sizeh/4, sizew, sizeh, @@ -2285,7 +2273,7 @@ * * @param marker The marker. */ -EAPI void +EAPI void elm_map_marker_update(Elm_Map_Marker *marker) { if(marker->content) |