[libchamplain] Don't fill tile that is already marked as done
- From: Jiří Techet <jiritechet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain] Don't fill tile that is already marked as done
- Date: Fri, 20 Aug 2010 22:00:51 +0000 (UTC)
commit ced12e90909a77ceedb315c849feabde1cb63aa2
Author: JiÅ?Ã Techet <techet gmail com>
Date: Fri Aug 20 12:38:53 2010 +0200
Don't fill tile that is already marked as done
Signed-off-by: JiÅ?Ã Techet <techet gmail com>
champlain/champlain-file-cache.c | 19 ++++++++------
champlain/champlain-file-tile-source.c | 7 +++-
champlain/champlain-memory-cache.c | 13 ++++++---
champlain/champlain-network-bbox-tile-source.c | 15 ++++++----
champlain/champlain-network-tile-source.c | 16 ++++++-----
champlain/champlain-null-tile-source.c | 11 +++++---
champlain/champlain-view.c | 33 ++++++++++++++++++-----
7 files changed, 75 insertions(+), 39 deletions(-)
---
diff --git a/champlain/champlain-file-cache.c b/champlain/champlain-file-cache.c
index 23cd707..b7af70e 100644
--- a/champlain/champlain-file-cache.c
+++ b/champlain/champlain-file-cache.c
@@ -623,10 +623,10 @@ cleanup:
}
-static void
+static void
file_loaded_cb (GFile *file,
GAsyncResult *res,
- FileLoadedData *user_data)
+ FileLoadedData *user_data)
{
gboolean ok;
gchar *contents;
@@ -635,7 +635,7 @@ file_loaded_cb (GFile *file,
ChamplainTile *tile = user_data->tile;
ChamplainMapSource *map_source = user_data->map_source;
ChamplainRenderer *renderer;
-
+
ok = g_file_load_contents_finish (file, res, &contents, &length, NULL, &error);
if (!ok)
@@ -645,7 +645,7 @@ file_loaded_cb (GFile *file,
length = 0;
g_error_free (error);
}
-
+
g_object_unref (file);
renderer = champlain_map_source_get_renderer (map_source);
@@ -669,19 +669,22 @@ fill_tile (ChamplainMapSource *map_source,
ChamplainMapSource *next_source = champlain_map_source_get_next_source (map_source);
+ if (champlain_tile_get_state (tile) == CHAMPLAIN_STATE_DONE)
+ return;
+
if (champlain_tile_get_state (tile) != CHAMPLAIN_STATE_LOADED)
{
FileLoadedData *user_data;
gchar *filename;
GFile *file;
-
+
filename = get_filename (CHAMPLAIN_FILE_CACHE (map_source), tile);
file = g_file_new_for_path (filename);
user_data = g_slice_new (FileLoadedData);
user_data->tile = tile;
user_data->map_source = map_source;
-
+
g_object_ref (tile);
g_object_ref (map_source);
@@ -728,12 +731,12 @@ refresh_tile_time (ChamplainTileCache *tile_cache,
g_file_info_set_modification_time (info, &now);
g_file_set_attributes_from_info (file, info, G_FILE_QUERY_INFO_NONE, NULL, NULL);
-
+
g_object_unref (info);
}
g_object_unref (file);
-
+
if (CHAMPLAIN_IS_TILE_CACHE (next_source))
champlain_tile_cache_refresh_tile_time (CHAMPLAIN_TILE_CACHE (next_source), tile);
}
diff --git a/champlain/champlain-file-tile-source.c b/champlain/champlain-file-tile-source.c
index b551ff7..db731d9 100644
--- a/champlain/champlain-file-tile-source.c
+++ b/champlain/champlain-file-tile-source.c
@@ -156,7 +156,7 @@ tile_rendered_cb (ChamplainTile *tile,
{
ChamplainTileSource *tile_source = CHAMPLAIN_TILE_SOURCE (map_source);
ChamplainTileCache *tile_cache = champlain_tile_source_get_cache (tile_source);
-
+
if (tile_cache && data->data)
champlain_tile_cache_store_tile (tile_cache, tile, data->data, data->size);
@@ -166,7 +166,7 @@ tile_rendered_cb (ChamplainTile *tile,
}
else if (next_source)
champlain_map_source_fill_tile (next_source, tile);
-
+
g_object_unref (map_source);
g_object_unref (tile);
}
@@ -181,6 +181,9 @@ fill_tile (ChamplainMapSource *map_source,
ChamplainMapSource *next_source = champlain_map_source_get_next_source (map_source);
+ if (champlain_tile_get_state (tile) == CHAMPLAIN_STATE_DONE)
+ return;
+
if (champlain_tile_get_state (tile) != CHAMPLAIN_STATE_LOADED)
{
ChamplainRenderer *renderer;
diff --git a/champlain/champlain-memory-cache.c b/champlain/champlain-memory-cache.c
index 1587268..020da91 100644
--- a/champlain/champlain-memory-cache.c
+++ b/champlain/champlain-memory-cache.c
@@ -262,9 +262,9 @@ tile_rendered_cb (ChamplainTile *tile,
ChamplainMapSource *next_source;
g_signal_handlers_disconnect_by_func (tile, tile_rendered_cb, map_source);
-
+
next_source = champlain_map_source_get_next_source (map_source);
-
+
if (!data->error)
{
if (CHAMPLAIN_IS_TILE_CACHE (next_source))
@@ -278,7 +278,7 @@ tile_rendered_cb (ChamplainTile *tile,
champlain_map_source_fill_tile (next_source, tile);
g_object_unref (map_source);
- g_object_unref (tile);
+ g_object_unref (tile);
}
@@ -291,6 +291,9 @@ fill_tile (ChamplainMapSource *map_source,
ChamplainMapSource *next_source = champlain_map_source_get_next_source (map_source);
+ if (champlain_tile_get_state (tile) == CHAMPLAIN_STATE_DONE)
+ return;
+
if (champlain_tile_get_state (tile) != CHAMPLAIN_STATE_LOADED)
{
ChamplainMemoryCache *memory_cache = CHAMPLAIN_MEMORY_CACHE (map_source);
@@ -315,7 +318,7 @@ fill_tile (ChamplainMapSource *map_source,
g_object_ref (tile);
g_signal_connect (tile, "render-complete", G_CALLBACK (tile_rendered_cb), map_source);
-
+
champlain_renderer_set_data (renderer, member->data, member->size);
champlain_renderer_render (renderer, tile);
@@ -370,7 +373,7 @@ store_tile (ChamplainTileCache *tile_cache,
g_queue_push_head (priv->queue, member);
}
-
+
if (CHAMPLAIN_IS_TILE_CACHE (next_source))
champlain_tile_cache_store_tile (CHAMPLAIN_TILE_CACHE (next_source), tile, contents, size);
}
diff --git a/champlain/champlain-network-bbox-tile-source.c b/champlain/champlain-network-bbox-tile-source.c
index 2119da1..4ed9ffc 100644
--- a/champlain/champlain-network-bbox-tile-source.c
+++ b/champlain/champlain-network-bbox-tile-source.c
@@ -212,7 +212,7 @@ champlain_network_bbox_tile_source_class_init (ChamplainNetworkBboxTileSourceCla
"The proxy URI to use to access network",
"",
G_PARAM_READWRITE));
-
+
/*
* ChamplainMapDataSource:state:
*
@@ -251,7 +251,7 @@ champlain_network_bbox_tile_source_init (ChamplainNetworkBboxTileSource *self)
g_object_set (G_OBJECT (priv->soup_session),
"user-agent", "libchamplain/" CHAMPLAIN_VERSION_S,
"max-conns-per-host", 2, NULL);
-
+
priv->state = CHAMPLAIN_STATE_NONE;
}
@@ -359,7 +359,7 @@ champlain_network_bbox_tile_source_load_map_data (
DEBUG ("Request BBox data: '%s'", url);
g_free (url);
-
+
g_object_set (G_OBJECT (self), "state", CHAMPLAIN_STATE_LOADING, NULL);
soup_session_queue_message (priv->soup_session, msg, load_map_data_cb, self);
@@ -374,14 +374,14 @@ tile_rendered_cb (ChamplainTile *tile,
ChamplainMapSource *next_source;
g_signal_handlers_disconnect_by_func (tile, tile_rendered_cb, map_source);
-
+
next_source = champlain_map_source_get_next_source (map_source);
-
+
if (!data->error)
{
ChamplainTileSource *tile_source = CHAMPLAIN_TILE_SOURCE (map_source);
ChamplainTileCache *tile_cache = champlain_tile_source_get_cache (tile_source);
-
+
if (tile_cache && data->data)
champlain_tile_cache_store_tile (tile_cache, tile, data->data, data->size);
@@ -406,6 +406,9 @@ fill_tile (ChamplainMapSource *map_source,
ChamplainMapSource *next_source = champlain_map_source_get_next_source (map_source);
+ if (champlain_tile_get_state (tile) == CHAMPLAIN_STATE_DONE)
+ return;
+
if (champlain_tile_get_state (tile) != CHAMPLAIN_STATE_LOADED)
{
ChamplainRenderer *renderer;
diff --git a/champlain/champlain-network-tile-source.c b/champlain/champlain-network-tile-source.c
index 178dfb2..033ba06 100644
--- a/champlain/champlain-network-tile-source.c
+++ b/champlain/champlain-network-tile-source.c
@@ -537,12 +537,12 @@ tile_rendered_cb (ChamplainTile *tile,
ChamplainMapSource *map_source = user_data->map_source;
ChamplainMapSource *next_source;
gchar *etag = user_data->etag;
-
+
g_signal_handlers_disconnect_by_func (tile, tile_rendered_cb, user_data);
g_slice_free (TileRenderedData, user_data);
-
+
next_source = champlain_map_source_get_next_source (map_source);
-
+
if (!data->error)
{
ChamplainTileSource *tile_source = CHAMPLAIN_TILE_SOURCE (map_source);
@@ -560,10 +560,10 @@ tile_rendered_cb (ChamplainTile *tile,
}
else if (next_source)
champlain_map_source_fill_tile (next_source, tile);
-
+
g_free (etag);
g_object_unref (map_source);
- g_object_unref (tile);
+ g_object_unref (tile);
}
@@ -652,7 +652,7 @@ destroy_cancelled_data (TileCancelledData *data,
{
if (data->map_source)
g_object_remove_weak_pointer (G_OBJECT (data->map_source), (gpointer *) &data->map_source);
-
+
if (data->msg)
g_object_remove_weak_pointer (G_OBJECT (data->msg), (gpointer *) &data->msg);
@@ -669,7 +669,6 @@ tile_state_notify (ChamplainTile *tile,
{
DEBUG ("Canceling tile download");
ChamplainNetworkTileSourcePrivate *priv = CHAMPLAIN_NETWORK_TILE_SOURCE (data->map_source)->priv;
-
soup_session_cancel_message (priv->soup_session, data->msg, SOUP_STATUS_CANCELLED);
}
}
@@ -710,6 +709,9 @@ fill_tile (ChamplainMapSource *map_source,
ChamplainNetworkTileSource *tile_source = CHAMPLAIN_NETWORK_TILE_SOURCE (map_source);
ChamplainNetworkTileSourcePrivate *priv = tile_source->priv;
+ if (champlain_tile_get_state (tile) == CHAMPLAIN_STATE_DONE)
+ return;
+
if (!priv->offline)
{
TileLoadedData *callback_data;
diff --git a/champlain/champlain-null-tile-source.c b/champlain/champlain-null-tile-source.c
index 174f366..4f1aef2 100644
--- a/champlain/champlain-null-tile-source.c
+++ b/champlain/champlain-null-tile-source.c
@@ -83,14 +83,14 @@ tile_rendered_cb (ChamplainTile *tile,
ChamplainMapSource *next_source;
g_signal_handlers_disconnect_by_func (tile, tile_rendered_cb, map_source);
-
+
next_source = champlain_map_source_get_next_source (map_source);
-
+
if (!data->error)
{
ChamplainTileSource *tile_source = CHAMPLAIN_TILE_SOURCE (map_source);
ChamplainTileCache *tile_cache = champlain_tile_source_get_cache (tile_source);
-
+
if (tile_cache && data->data)
champlain_tile_cache_store_tile (tile_cache, tile, data->data, data->size);
@@ -102,7 +102,7 @@ tile_rendered_cb (ChamplainTile *tile,
champlain_map_source_fill_tile (next_source, tile);
g_object_unref (map_source);
- g_object_unref (tile);
+ g_object_unref (tile);
}
@@ -115,6 +115,9 @@ fill_tile (ChamplainMapSource *map_source,
ChamplainMapSource *next_source = champlain_map_source_get_next_source (map_source);
+ if (champlain_tile_get_state (tile) == CHAMPLAIN_STATE_DONE)
+ return;
+
if (champlain_tile_get_state (tile) != CHAMPLAIN_STATE_LOADED)
{
ChamplainRenderer *renderer;
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index b88fb4b..c077677 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -1745,7 +1745,7 @@ finger_scroll_button_press_cb (G_GNUC_UNUSED ClutterActor *actor,
event->button == 1 && event->click_count == 2)
{
gdouble lon, lat;
-
+
champlain_view_get_coords_from_event (view, (ClutterEvent *) event, &lat, &lon);
champlain_view_stop_go_to (view);
@@ -1753,7 +1753,7 @@ finger_scroll_button_press_cb (G_GNUC_UNUSED ClutterActor *actor,
priv->zoom_level = zoom_level;
resize_viewport (view);
-
+
champlain_view_center_on (view, lat, lon);
g_object_notify (G_OBJECT (view), "zoom-level");
@@ -2552,8 +2552,7 @@ view_load_visible_tiles (ChamplainView *view)
zoom_level != priv->zoom_level)
{
// inform map source to terminate loading the tile
- if (champlain_tile_get_state (tile) != CHAMPLAIN_STATE_DONE)
- champlain_tile_set_state (tile, CHAMPLAIN_STATE_DONE);
+ champlain_tile_set_state (tile, CHAMPLAIN_STATE_DONE);
clutter_container_remove_actor (CLUTTER_CONTAINER (priv->map_layer), CLUTTER_ACTOR (tile));
}
else
@@ -2660,12 +2659,32 @@ view_position_tile (ChamplainView *view,
}
+static void
+remove_all_tiles (ChamplainView *view)
+{
+ DEBUG_LOG ()
+
+ ChamplainViewPrivate *priv = view->priv;
+ GList *children;
+
+ children = clutter_container_get_children (CLUTTER_CONTAINER (priv->map_layer));
+ for (; children != NULL; children = g_list_next (children))
+ {
+ ChamplainTile *tile = CHAMPLAIN_TILE (children->data);
+
+ champlain_tile_set_state (tile, CHAMPLAIN_STATE_DONE);
+ clutter_container_remove_actor (CLUTTER_CONTAINER (priv->map_layer), CLUTTER_ACTOR (tile));
+ }
+ g_list_free (children);
+}
+
+
void
champlain_view_reload_tiles (ChamplainView *view)
{
DEBUG_LOG ()
- clutter_group_remove_all (CLUTTER_GROUP (view->priv->map_layer));
+ remove_all_tiles (view);
view_load_visible_tiles (view);
}
@@ -2677,7 +2696,7 @@ tile_state_notify (ChamplainTile *tile,
ChamplainView *view)
{
DEBUG_LOG ()
-
+
ChamplainState tile_state = champlain_tile_get_state (tile);
ChamplainViewPrivate *priv = view->priv;
@@ -2744,7 +2763,7 @@ champlain_view_set_map_source (ChamplainView *view,
g_object_notify (G_OBJECT (view), "zoom-level");
}
- clutter_group_remove_all (CLUTTER_GROUP (priv->map_layer));
+ remove_all_tiles (view);
update_license (view);
champlain_view_center_on (view, priv->latitude, priv->longitude);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]