From 25c95da80cd208106c4ab068d2aaffb819f80118 Mon Sep 17 00:00:00 2001 From: Hannes Janetzek Date: Sun, 19 Jan 2014 17:15:42 +0100 Subject: [PATCH] set MapTile.STATE_CANCEL when tile is cleared in TileManager.jobCompleted clear tile when tile state is CANCEL --- vtm/src/org/oscim/tiling/MapTile.java | 5 +++-- vtm/src/org/oscim/tiling/TileManager.java | 19 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/vtm/src/org/oscim/tiling/MapTile.java b/vtm/src/org/oscim/tiling/MapTile.java index 1a811dcf..316309f9 100644 --- a/vtm/src/org/oscim/tiling/MapTile.java +++ b/vtm/src/org/oscim/tiling/MapTile.java @@ -61,6 +61,8 @@ public class MapTile extends Tile { */ public final static byte STATE_ERROR = 1 << 3; + public final static byte STATE_CANCEL = 1 << 4; + /** * absolute tile coordinates: tileX,Y / Math.pow(2, zoomLevel) */ @@ -89,7 +91,7 @@ public class MapTile extends Tile { } /** - * Tile is in view region. Set by GLRenderer. + * Tile is in view region. Set by TileRenderer. */ public boolean isVisible; @@ -100,7 +102,6 @@ public class MapTile extends Tile { /** * to avoid drawing a tile twice per frame - * FIXME what if multiple layers use the same tile? */ int lastDraw = 0; diff --git a/vtm/src/org/oscim/tiling/TileManager.java b/vtm/src/org/oscim/tiling/TileManager.java index 29e452a6..ec559420 100644 --- a/vtm/src/org/oscim/tiling/TileManager.java +++ b/vtm/src/org/oscim/tiling/TileManager.java @@ -17,9 +17,9 @@ package org.oscim.tiling; +import static org.oscim.tiling.MapTile.STATE_CANCEL; import static org.oscim.tiling.MapTile.STATE_LOADING; import static org.oscim.tiling.MapTile.STATE_NEW_DATA; -import static org.oscim.tiling.MapTile.STATE_NONE; import java.util.ArrayList; import java.util.Arrays; @@ -29,7 +29,6 @@ import org.oscim.core.Tile; import org.oscim.map.Map; import org.oscim.map.Viewport; import org.oscim.renderer.BufferObject; -import org.oscim.renderer.MapRenderer; import org.oscim.utils.FastMath; import org.oscim.utils.ScanBox; import org.oscim.utils.quadtree.QuadTree; @@ -383,13 +382,14 @@ public class TileManager { if (t == null) return; - t.clear(); - - mIndex.remove(t); - - // QuadTree.remove(t); - t.state = STATE_NONE; + synchronized (t) { + // still belongs to TileLoader thread + if (t.state != STATE_LOADING) + t.clear(); + t.state = STATE_CANCEL; + mIndex.remove(t); + } mTilesCount--; } @@ -527,8 +527,7 @@ public class TileManager { * @return caller does not care */ public void jobCompleted(MapTile tile, boolean success) { - - if (!success) { + if (!success || tile.state == STATE_CANCEL) { tile.clear(); return; }