Yeah, It's my mistake....!
I remade my patches to be applied sequentially.
Those also reflect hermet's reviews. :-)

2011/12/13 Carsten Haitzler <ras...@rasterman.com>:
> On Tue, 6 Dec 2011 14:05:02 +0900 Bluezery <ohpo...@gmail.com> said:
>
> patch 01 applies. patch 02 seems already partly in 01 - this isn't very 
> useful.
> 03 just fails to apply at all (once 0.1 is applied) and 04... is already
> applied... normally a patch series is a set of patches you can apply 
> separately
> (entirely) or if each builds on features of the previous one, then in sequence
> to gradually gain better/more features/fixes etc. but here this doesn't seem 
> to
> be the case. patch 01 is in now, but 02,03 and 04 need... some redoing.
>
>> Hello,
>>
>> I separate my path into 4 patches.
>> It should be patched sequentially
>>
>> (1) Grid Management
>> There are no caching mechanism in current elm_map.
>> So, too many network resources are wasted because elm_map keeps only
>> two grids and already downloaded images are downloaded again and
>> again. (This also slows the map loading speed)
>> I have changed this grid management policy.
>>
>> I have done followings.
>> 1. Create all grids (all zoom levels) when elm_map_add() is called (No
>> memory overhead because of sparse matrix)
>> 2. Clear all grids when map object is deleted.
>> 3. Loads necessary grids and unloads unused grids when zoom level is changed.
>>
>> Changed grid management have one weakness that memory and tmp size can
>> grow bigger while map object is live.
>> I think it may need API such as elm_map_cache_size_set().
>>
>> (2) Revoking gi->have
>> I restore the gi->have values. The removal of this is my mistake.
>> gi->have is needed because I cannot know whether this file is
>> downloading (just opened and not written) or downloaded state even if
>> image file exists.
>>
>> (3) Simplify grid_load()
>> There exists 3 state for grid items. i.e., downloaded, downloading, none
>> states. grid_load() does followings:
>> 1. if a grid item does not exist, create it.
>> 2. update a tile (if downloaded) or queues for download (if none) or
>> nothing  (if downloading)
>>
>> (4) Merging foreach
>> Two foreach loop can be merged.
>>
>> Please review this again.
>>
>> 2011년 12월 5일 오후 9:41, Daniel Juyung Seo <seojuyu...@gmail.com>님의 말:
>> > Yeah as Hermet mentioned, this is one big blob of patch which makes
>> > reviewers hard to review.
>> > Please separate your patch into a couple for patches for each feature.
>> > That will help reviewing and debugging.
>> > Thanks.
>> >
>> > Daniel Juyung Seo (SeoZ)
>> >
>> > 2011/12/5 ChunEon Park <her...@naver.com>:
>> >> please make one shot one kill.
>> >> Final change should not be included here.
>> >> ------------------------------------
>> >> -Regards, Hermet-
>> >>
>> >> -----Original Message-----
>> >> From: "Bluezery"&lt;ohpo...@gmail.com&gt;
>> >> To: "Enlightenment developer
>> >> list"&lt;enlightenment-devel@lists.sourceforge.net&gt; Cc:
>> >> Sent: 11-12-05(월) 19:38:24
>> >> Subject: [E-devel] [Patch][elm_map] Change grid management
>> >> Hi,
>> >> There are no caching mechanism in current elm_map.
>> >> So, too many network resources are wasted because elm_map keeps only
>> >> two grids and already downloaded images are downloaded again and
>> >> again. (This also slows the map loading speed)
>> >> I have changed this grid management policy.
>> >> I have done followings.
>> >> 1. Create all grids (all zoom levels) when elm_map_add() is called (No
>> >> memory overhead because of sparse matrix)
>> >> 2. Clear all grids when map object is deleted.
>> >> 3. Loads necessary grids and unloads unused grids when zoom level is
>> >> changed. Changed grid management have one weakness that memory and tmp
>> >> size can grow bigger while map object is live.
>> >> I think it may need API such as elm_map_cache_size_set().
>> >> Finally, I restore the gi->have values. The removal of this is my mistake.
>> >> gi->have is needed because I cannot know whether this file is
>> >> downloading (just opened and not written) or downloaded state even if
>> >> image file exists.
>> >> Please review this patch.
>> >> Thanks
>> >> --
>> >> BRs,
>> >> Kim.
>> >> ------------------------------------------------------------------------------
>> >> All the data continuously generated in your IT infrastructure
>> >> contains a definitive record of customers, application performance,
>> >> security threats, fraudulent activity, and more. Splunk takes this
>> >> data and makes sense of it. IT sense. And common sense.
>> >> http://p.sf.net/sfu/splunk-novd2d_______________________________________________
>> >> enlightenment-devel mailing list
>> >> enlightenment-devel@lists.sourceforge.net
>> >> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>> >> ------------------------------------------------------------------------------
>> >> All the data continuously generated in your IT infrastructure
>> >> contains a definitive record of customers, application performance,
>> >> security threats, fraudulent activity, and more. Splunk takes this
>> >> data and makes sense of it. IT sense. And common sense.
>> >> http://p.sf.net/sfu/splunk-novd2d
>> >> _______________________________________________
>> >> enlightenment-devel mailing list
>> >> enlightenment-devel@lists.sourceforge.net
>> >> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>> >
>> > ------------------------------------------------------------------------------
>> > All the data continuously generated in your IT infrastructure
>> > contains a definitive record of customers, application performance,
>> > security threats, fraudulent activity, and more. Splunk takes this
>> > data and makes sense of it. IT sense. And common sense.
>> > http://p.sf.net/sfu/splunk-novd2d
>> > _______________________________________________
>> > enlightenment-devel mailing list
>> > enlightenment-devel@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>>
>>
>>
>> --
>> BRs,
>> Kim.
>
>
> --
> ------------- Codito, ergo sum - "I code, therefore I am" --------------
> The Rasterman (Carsten Haitzler)    ras...@rasterman.com
>



-- 
BRs,
Kim.
Index: src/lib/elm_map.c
===================================================================
--- src/lib/elm_map.c	(리비전 66133)
+++ src/lib/elm_map.c	(작업 사본)
@@ -256,6 +256,7 @@ struct _Grid_Item
         int x, y, w, h;
    } src, out;
 
+   Eina_Bool file_have : 1;
    Ecore_File_Download_Job *job;
    int try_num;
 };
@@ -629,7 +630,7 @@ module_list_cb(Eina_Module *m, void *dat
    coord_into_geo = eina_module_symbol_get(m, "map_module_coord_into_geo");
    if ((!source) || (!zoom_min) || (!zoom_max) || (!url) || (!route_source) || (!route_url) || (!name_url) || (!geo_into_coord) || (!coord_into_geo))
      {
-        ERR("could not find map_module_source_get() in module \"%s\": %s", file, eina_error_msg_get(eina_error_get()));
+        WRN("could not find map_module_source_get() in module \"%s\": %s", file, eina_error_msg_get(eina_error_get()));
         eina_module_unload(m);
         return EINA_FALSE;
      }
@@ -1108,11 +1109,13 @@ _tile_update(Grid_Item *gi)
      {
         ERR("Image loading error (%s): %s", gi->file, evas_load_error_str(err));
         ecore_file_remove(gi->file);
+        gi->file_have = EINA_FALSE;
      }
    else
      {
         obj_rotate_zoom(gi->wd->obj, gi->img);
         evas_object_show(gi->img);
+        gi->file_have = EINA_TRUE;
         //evas_object_text_text_set(gi->txt, gi->file);
         //evas_object_show(gi->txt);
      }
@@ -1129,14 +1132,15 @@ _tile_downloaded(void *data, const char
      {
         DBG("Download success from %s to %s", gi->source, gi->file);
         _tile_update(gi);
+        gi->wd->finish_num++;
      }
    else
      {
-        DBG("Download failed from %s to %s (%d) ", gi->source, gi->file, status);
+        WRN("Download failed from %s to %s (%d) ", gi->source, gi->file, status);
         ecore_file_remove(gi->file);
+        gi->file_have = EINA_FALSE;
      }
 
-   gi->wd->finish_num++;
    gi->wd->download_num--;
    evas_object_smart_callback_call(gi->wd->obj, SIG_DOWNLOADED, NULL);
    if (!gi->wd->download_num)
@@ -1272,6 +1276,7 @@ grid_clear_all(Evas_Object *obj)
                   DBG("DOWNLOAD abort %s", gi->file);
                   ecore_file_download_abort(gi->job);
                   ecore_file_remove(gi->file);
+                  gi->file_have = EINA_FALSE;
                   gi->job = NULL;
                   wd->try_num--;
                }
@@ -1306,7 +1311,7 @@ grid_unload(Evas_Object *obj, Grid *g)
      {
         gi = eina_matrixsparse_cell_data_get(cell);
 
-        if (ecore_file_exists(gi->file))
+        if (gi->file_have)
           {
              evas_object_hide(gi->img);
              //evas_object_hide(gi->txt);
@@ -1382,20 +1387,20 @@ grid_load(Evas_Object *obj, Grid *g)
                                  ww, hh,
                                  cvx, cvy, cvw, cvh))
           {
-             if (ecore_file_exists(gi->file))
+             if (gi->file_have)
                {
                   evas_object_hide(gi->img);
+                  //evas_object_hide(gi->txt);
                   evas_object_image_file_set(gi->img, NULL, NULL);
                }
              else if (gi->job)
                {
-                  DBG("DOWNLOAD abort %s", gi->file);
+                  DBG("Download abort %s", gi->file);
                   ecore_file_download_abort(gi->job);
                   ecore_file_remove(gi->file);
                   gi->job = NULL;
                   wd->try_num--;
                }
-             //evas_object_hide(gi->txt);
           }
      }
    eina_iterator_free(it);
@@ -1476,16 +1481,16 @@ grid_load(Evas_Object *obj, Grid *g)
                   eina_stringshare_replace(&gi->file, buf2);
                   eina_stringshare_replace(&gi->source, source);
 
-                  if (ecore_file_exists(gi->file))
+                  if (gi->file_have)
                     {
-                       DBG("file exists: %s", gi->file);
+                       DBG("File exists: %s", gi->file);
                        _tile_update(gi);
                     }
                   else
                     {
-                       DBG("added to download list: %s", gi->file);
+                       DBG("Added to download list: %s", gi->file);
                        _add_download_list(obj, gi);
-                    }      
+                    }
                   if (source) free(source);
                }
           }
@@ -2323,8 +2328,8 @@ _pan_calculate(Evas_Object *obj)
    rect_place(sd->wd->obj, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
    EINA_LIST_FOREACH(sd->wd->grids, l, g)
      {
-        if (sd->wd->zoom == g->zoom)     grid_load(sd->wd->obj, g);
-        else if (sd->wd->zoom-1 != g->zoom && sd->wd->zoom+1 != g->zoom)  grid_unload(sd->wd->obj, g); // remain only adjacent grids
+        if (sd->wd->zoom == g->zoom) grid_load(sd->wd->obj, g);
+        else if (sd->wd->zoom-1 != g->zoom && sd->wd->zoom+1 != g->zoom) grid_unload(sd->wd->obj, g); // remain only adjacent grids
         grid_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
         if (sd->wd->zoom == g->zoom) marker_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
         if (!sd->wd->zoom_animator) route_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
--- src/lib/elm_map.c_01	2011-12-13 13:41:56.452226050 +0900
+++ src/lib/elm_map.c	2011-12-13 15:02:45.808081895 +0900
@@ -21,9 +21,9 @@ typedef struct _Route_Dump Route_Dump;
 typedef struct _Name_Dump Name_Dump;
 typedef struct _Track_Dump Track_Dump;
 
-#define DEST_DIR_ZOOM_PATH "/tmp/elm_map/%d/%d/"
-#define DEST_DIR_PATH DEST_DIR_ZOOM_PATH"%d/"
-#define DEST_FILE_PATH "%s%d.png"
+#define CACHE_ROOT_PATH   "/tmp/elm_map"
+#define CACHE_PATH        CACHE_ROOT_PATH"/%d/%d/%d"
+#define CACHE_FILE_PATH   "%s/%d.png"
 #define DEST_ROUTE_XML_FILE "/tmp/elm_map-route-XXXXXX"
 #define DEST_NAME_XML_FILE "/tmp/elm_map-name-XXXXXX"
 
@@ -1236,6 +1236,7 @@ grid_create_all(Evas_Object *obj)
    for (zoom = wd->src->zoom_min; zoom <= wd->src->zoom_max; zoom++)
      {
         g = calloc(1, sizeof(Grid));
+        EINA_SAFETY_ON_NULL_RETURN(g);
         g->zoom = zoom;
         g->tsize = wd->tsize;
         g->wd = wd;
@@ -1425,7 +1426,19 @@ grid_load(Evas_Object *obj, Grid *g)
 
              if (!gi)
                {
+                  char buf[PATH_MAX];
+                  char buf2[PATH_MAX];
+                  char *source;
+
                   gi = calloc(1, sizeof(Grid_Item));
+                  EINA_SAFETY_ON_NULL_RETURN(gi);
+
+                  gi->wd = wd;
+                  gi->g = g;
+                  gi->zoom = g->zoom;
+                  gi->file_have = EINA_FALSE;
+                  gi->job = NULL;
+
                   gi->src.x = x * g->tsize;
                   gi->src.y = y * g->tsize;
                   gi->src.w = g->tsize;
@@ -1436,12 +1449,8 @@ grid_load(Evas_Object *obj, Grid *g)
                   gi->out.w = gi->src.w;
                   gi->out.h = gi->src.h;
 
-                  gi->wd = wd;
-                  gi->g = g;
-
                   gi->img = evas_object_image_add(evas_object_evas_get(obj));
-                  evas_object_image_scale_hint_set
-                     (gi->img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
+                  evas_object_image_scale_hint_set(gi->img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
                   evas_object_image_filled_set(gi->img, 1);
 
                   evas_object_smart_member_add(gi->img, wd->pan_smart);
@@ -1457,42 +1466,33 @@ grid_load(Evas_Object *obj, Grid *g)
                   elm_widget_sub_object_add(obj, gi->txt);
                   evas_object_pass_events_set(gi->txt, EINA_TRUE);
 */
-                  eina_matrixsparse_data_idx_set(g->grid, y, x, gi);
-
-                  gi->job = NULL;
-                  gi->file = NULL;
-                  gi->source = NULL;
-               }
-
-             if (!gi->job)
-               {
-                  char buf[PATH_MAX], buf2[PATH_MAX];
-                  char *source;
-
-                  snprintf(buf, sizeof(buf), DEST_DIR_PATH, wd->id, g->zoom, x);
-                  if (!ecore_file_exists(buf))
-                    ecore_file_mkpath(buf);
-
-                  snprintf(buf2, sizeof(buf2), DEST_FILE_PATH, buf, y);
-
-                  source = wd->src->url_cb(obj, x, y, g->zoom);
-                  if ((!source) || (strlen(source)==0)) continue;
+                  snprintf(buf, sizeof(buf), CACHE_PATH, wd->id, g->zoom, x);
+                  snprintf(buf2, sizeof(buf2), CACHE_FILE_PATH, buf, y);
+                  if (!ecore_file_exists(buf)) ecore_file_mkpath(buf);
 
                   eina_stringshare_replace(&gi->file, buf2);
-                  eina_stringshare_replace(&gi->source, source);
-
-                  if (gi->file_have)
-                    {
-                       DBG("File exists: %s", gi->file);
-                       _tile_update(gi);
-                    }
-                  else
+                  source = wd->src->url_cb(obj, x, y, g->zoom);
+                  if ((!source) || (strlen(source)==0))
                     {
-                       DBG("Added to download list: %s", gi->file);
-                       _add_download_list(obj, gi);
+                       eina_stringshare_replace(&gi->source, NULL);
+                       WRN("Getting source url failed: %s", gi->file);
                     }
+                  else eina_stringshare_replace(&gi->source, source);
                   if (source) free(source);
+
+                  eina_matrixsparse_data_idx_set(g->grid, y, x, gi);
                }
+
+               if (gi->file_have)
+                 {
+                    DBG("File exists: %s", gi->file);
+                    _tile_update(gi);
+                 }
+               else if (!gi->job)
+                 {
+                    DBG("Added to download list: %s", gi->file);
+                    _add_download_list(obj, gi);
+                 }
           }
      }
 }
--- src/lib/elm_map.c.orig	2011-12-13 14:47:21.000109385 +0900
+++ src/lib/elm_map.c	2011-12-13 15:16:12.864941000 +0900
@@ -1166,7 +1166,7 @@ _process_download_list(Evas_Object *obj)
    gw = wd->size.w;
    gh = wd->size.h;
 
-   EINA_LIST_FOREACH_SAFE(wd->download_list, l, ll, gi)
+   EINA_LIST_REVERSE_FOREACH_SAFE(wd->download_list, l, ll, gi)
      {
         xx = gi->out.x;
         yy = gi->out.y;
@@ -1188,14 +1188,13 @@ _process_download_list(Evas_Object *obj)
         if (!ELM_RECTS_INTERSECT(xx - wd->pan_x + ox,
                                  yy  - wd->pan_y + oy,
                                  ww, hh,
-                                 cvx, cvy, cvw, cvh))
+                                 cvx, cvy, cvw, cvh) ||
+           (gi->zoom != wd->zoom))
           {
              wd->download_list = eina_list_remove(wd->download_list, gi);
+             continue;
           }
-     }
 
-   EINA_LIST_REVERSE_FOREACH_SAFE(wd->download_list, l, ll, gi)
-     {
         if (gi->wd->download_num >= MAX_CONCURRENT_DOWNLOAD) break;
 
         Eina_Bool ret = ecore_file_download_full(gi->source, gi->file, _tile_downloaded, NULL, gi, &(gi->job), wd->ua);
@@ -3003,6 +3002,22 @@ _parse_name(void *data)
      }
 }
 
+Grid *_get_current_grid(Widget_Data *wd)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
+   Eina_List *l;
+   Grid *g = NULL, *ret = NULL;
+   EINA_LIST_FOREACH(wd->grids, l, g)
+     {
+        if (wd->zoom == g->zoom)
+          {
+             ret = g;
+             break;
+          }
+     }
+   return ret;
+}
+
 static Eina_Bool
 _route_complete_cb(void *data, int ev_type __UNUSED__, void *event)
 {
@@ -3020,14 +3035,10 @@ _route_complete_cb(void *data, int ev_ty
 
    if (wd->grids)
      {
-        Eina_List *l;
         Grid *g;
         Evas_Coord ox, oy, ow, oh;
         evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
-        EINA_LIST_FOREACH(wd->grids, l, g)
-          {
-             if (wd->zoom == g->zoom) break;
-          }
+        g = _get_current_grid(wd);
         route_place(wd->obj, g, wd->pan_x, wd->pan_y, ox, oy, ow, oh);
      }
    edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
@@ -3929,14 +3940,10 @@ elm_map_marker_add(Evas_Object *obj, dou
 
    if (wd->grids)
      {
-        Eina_List *l;
         Grid *g;
         Evas_Coord ox, oy, ow, oh;
         evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
-        EINA_LIST_FOREACH(wd->grids, l, g)
-          {
-             if (wd->zoom == g->zoom) break;
-          }
+        g = _get_current_grid(wd);
         marker_place(obj, g, wd->pan_x, wd->pan_y, ox, oy, ow, oh);
      }
 
@@ -4014,14 +4021,10 @@ elm_map_marker_remove(Elm_Map_Marker *ma
 
    if (wd->grids)
      {
-        Eina_List *l;
         Grid *g;
         Evas_Coord ox, oy, ow, oh;
         evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
-        EINA_LIST_FOREACH(wd->grids, l, g)
-          {
-             if (wd->zoom == g->zoom) break;
-          }
+        g = _get_current_grid(wd);
         marker_place(wd->obj, g, wd->pan_x, wd->pan_y, ox, oy, ow, oh);
      }
 #else
@@ -4271,14 +4274,10 @@ elm_map_group_class_hide_set(Evas_Object
    clas->hide = hide;
    if (wd->grids)
      {
-        Eina_List *l;
         Grid *g;
         Evas_Coord ox, oy, ow, oh;
         evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
-        EINA_LIST_FOREACH(wd->grids, l, g)
-          {
-             if (wd->zoom == g->zoom) break;
-          }
+        g = _get_current_grid(wd);
         marker_place(obj, g, wd->pan_x, wd->pan_y, ox, oy, ow, oh);
      }
 #else
------------------------------------------------------------------------------
Systems Optimization Self Assessment
Improve efficiency and utilization of IT resources. Drive out cost and 
improve service delivery. Take 5 minutes to use this Systems Optimization 
Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to