TileManager: just drop index on re-init
- dont modify index of locked tiles.. - fixes one more bug from monkey test
This commit is contained in:
parent
d1daa92126
commit
ded178be6c
@ -22,7 +22,6 @@ import static org.oscim.layers.tile.MapTile.State.LOADING;
|
||||
import static org.oscim.layers.tile.MapTile.State.NEW_DATA;
|
||||
import static org.oscim.layers.tile.MapTile.State.NONE;
|
||||
import static org.oscim.layers.tile.MapTile.State.READY;
|
||||
import static org.oscim.layers.tile.MapTile.State.TIMEOUT;
|
||||
|
||||
import org.oscim.core.Tile;
|
||||
import org.oscim.layers.tile.vector.VectorTileLoader;
|
||||
@ -74,8 +73,6 @@ public class MapTile extends Tile {
|
||||
*/
|
||||
public final static byte CANCEL = (1 << 4);
|
||||
|
||||
public final static byte TIMEOUT = (1 << 5);
|
||||
|
||||
/**
|
||||
* Dont touch if you find some.
|
||||
*/
|
||||
@ -231,12 +228,6 @@ public class MapTile extends Tile {
|
||||
if (--locked > 0)
|
||||
return;
|
||||
|
||||
if (state == DEADBEEF) {
|
||||
log.debug("Unlock dead tile {}", this);
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
|
||||
TileNode parent = node.parent;
|
||||
if ((proxy & PROXY_PARENT) != 0)
|
||||
parent.item.refs--;
|
||||
@ -252,6 +243,11 @@ public class MapTile extends Tile {
|
||||
|
||||
/* removed all proxy references for this tile */
|
||||
proxy = 0;
|
||||
|
||||
if (state == DEADBEEF) {
|
||||
log.debug("Unlock dead tile {}", this);
|
||||
clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -278,10 +274,7 @@ public class MapTile extends Tile {
|
||||
data.dispose();
|
||||
data = data.next;
|
||||
}
|
||||
if (state == DEADBEEF)
|
||||
return;
|
||||
|
||||
state = NONE;
|
||||
setState(NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -402,26 +395,27 @@ public class MapTile extends Tile {
|
||||
return "Ready";
|
||||
case State.CANCEL:
|
||||
return "Cancel";
|
||||
case State.TIMEOUT:
|
||||
return "Timeout";
|
||||
case State.DEADBEEF:
|
||||
return "Dead";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
void setState(byte newState) {
|
||||
public synchronized void setState(byte newState) {
|
||||
if (state == newState)
|
||||
return;
|
||||
|
||||
/* Renderer could have uploaded the tile while the layer
|
||||
* was cleared. This prevents to set tile to READY state. */
|
||||
/* All other state changes are on the main-thread. */
|
||||
if (state == DEADBEEF)
|
||||
return;
|
||||
|
||||
switch (newState) {
|
||||
case NONE:
|
||||
if (state(LOADING | CANCEL)) {
|
||||
state = newState;
|
||||
return;
|
||||
}
|
||||
throw new IllegalStateException("None"
|
||||
+ " <= " + state() + " " + this);
|
||||
|
||||
case LOADING:
|
||||
if (state == NONE) {
|
||||
state = newState;
|
||||
@ -452,12 +446,9 @@ public class MapTile extends Tile {
|
||||
}
|
||||
throw new IllegalStateException("Cancel" +
|
||||
" <= " + state() + " " + this);
|
||||
case TIMEOUT:
|
||||
// TODO
|
||||
break;
|
||||
case DEADBEEF:
|
||||
state = newState;
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -167,20 +167,22 @@ public class TileManager {
|
||||
public void init() {
|
||||
if (mCurrentTiles != null)
|
||||
mCurrentTiles.releaseTiles();
|
||||
/* pass VBOs and VertexItems back to pools */
|
||||
|
||||
mIndex.drop();
|
||||
|
||||
/* Pass VBOs and VertexItems back to pools */
|
||||
for (int i = 0; i < mTilesEnd; i++) {
|
||||
MapTile t = mTiles[i];
|
||||
if (t == null)
|
||||
continue;
|
||||
|
||||
if (!t.isLocked()) {
|
||||
//log.debug("init clear {} {}", t, t.state());
|
||||
/* Check if tile is used by another thread */
|
||||
if (!t.isLocked())
|
||||
t.clear();
|
||||
}
|
||||
mIndex.removeItem(t);
|
||||
|
||||
/* in case the tile is still loading:
|
||||
* clear when returned from loader */
|
||||
/* In case the tile is still loading or used by
|
||||
* another thread: clear when returned from loader
|
||||
* or becomes unlocked */
|
||||
t.setState(DEADBEEF);
|
||||
}
|
||||
|
||||
@ -592,7 +594,6 @@ public class TileManager {
|
||||
mTilesToUpload++;
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO use mMap.update(true) to retry tile loading?
|
||||
log.debug("Load: {} {} state:{}",
|
||||
tile, success ? "success" : "failed",
|
||||
|
@ -195,4 +195,11 @@ public abstract class TileIndex<T extends TreeNode<T, E>, E> {
|
||||
return root.refs;
|
||||
}
|
||||
|
||||
public void drop() {
|
||||
root.item = null;
|
||||
root.child00 = null;
|
||||
root.child01 = null;
|
||||
root.child10 = null;
|
||||
root.child11 = null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user