prefetch parent tiles
This commit is contained in:
parent
d376d07c12
commit
123284a1a5
@ -314,6 +314,12 @@ public class TileManager {
|
|||||||
* @return true if new tiles were loaded
|
* @return true if new tiles were loaded
|
||||||
*/
|
*/
|
||||||
private static boolean updateVisibleList(MapPosition mapPosition, int zdir) {
|
private static boolean updateVisibleList(MapPosition mapPosition, int zdir) {
|
||||||
|
// clear JobQueue and set tiles to state == NONE.
|
||||||
|
// one could also append new tiles and sort in JobQueue
|
||||||
|
// but this has the nice side-effect that MapWorkers dont
|
||||||
|
// start with old jobs while new jobs are calculated, which
|
||||||
|
// should increase the chance that they are free when new
|
||||||
|
// jobs come in.
|
||||||
mMapView.addJobs(null);
|
mMapView.addJobs(null);
|
||||||
|
|
||||||
mNewTiles.cnt = 0;
|
mNewTiles.cnt = 0;
|
||||||
@ -360,7 +366,7 @@ public class TileManager {
|
|||||||
jobs = mJobs.toArray(jobs);
|
jobs = mJobs.toArray(jobs);
|
||||||
updateTileDistances(jobs, jobs.length, mapPosition);
|
updateTileDistances(jobs, jobs.length, mapPosition);
|
||||||
|
|
||||||
// sets tiles to isLoading = true
|
// sets tiles to state == LOADING
|
||||||
mMapView.addJobs(jobs);
|
mMapView.addJobs(jobs);
|
||||||
mJobs.clear();
|
mJobs.clear();
|
||||||
return true;
|
return true;
|
||||||
@ -385,13 +391,7 @@ public class TileManager {
|
|||||||
|
|
||||||
tile = QuadTree.getTile(x, y, zoomLevel);
|
tile = QuadTree.getTile(x, y, zoomLevel);
|
||||||
|
|
||||||
if (tile != null) {
|
if (tile == null) {
|
||||||
if (!tile.isActive())
|
|
||||||
mJobs.add(tile);
|
|
||||||
|
|
||||||
return tile;
|
|
||||||
}
|
|
||||||
|
|
||||||
tile = new MapTile(x, y, zoomLevel);
|
tile = new MapTile(x, y, zoomLevel);
|
||||||
QuadTree.add(tile);
|
QuadTree.add(tile);
|
||||||
|
|
||||||
@ -401,56 +401,34 @@ public class TileManager {
|
|||||||
mTiles = tmp;
|
mTiles = tmp;
|
||||||
Log.d(TAG, "increase tiles: " + mTiles.length);
|
Log.d(TAG, "increase tiles: " + mTiles.length);
|
||||||
}
|
}
|
||||||
mTiles[mTilesSize++] = tile;
|
|
||||||
|
|
||||||
|
mTiles[mTilesSize++] = tile;
|
||||||
mJobs.add(tile);
|
mJobs.add(tile);
|
||||||
mTilesCount++;
|
mTilesCount++;
|
||||||
|
|
||||||
return tile;
|
} else if (!tile.isActive()) {
|
||||||
|
mJobs.add(tile);
|
||||||
|
}
|
||||||
|
|
||||||
// mNewTiles.tiles[tiles++] = tile;
|
if (zoomLevel > 0) {
|
||||||
// boolean fetchParent = false;
|
// prefetch parent
|
||||||
// boolean fetchProxy = false;
|
MapTile p = tile.rel.parent.tile;
|
||||||
// boolean fetchChildren = false;
|
|
||||||
// if (fetchChildren) {
|
if (p == null) {
|
||||||
// byte z = (byte) (zoomLevel + 1);
|
p = new MapTile(x >> 1, y >> 1, (byte) (zoomLevel - 1));
|
||||||
// for (int i = 0; i < 4; i++) {
|
QuadTree.add(p);
|
||||||
// int cx = (x << 1) + (i % 2);
|
|
||||||
// int cy = (y << 1) + (i >> 1);
|
p.state = STATE_LOADING;
|
||||||
//
|
mJobs.add(p);
|
||||||
// MapTile c = QuadTree.getTile(cx, cy, z);
|
|
||||||
//
|
} else if (!p.isActive()) {
|
||||||
// if (c == null) {
|
//Log.d(TAG, "prefetch parent " + p);
|
||||||
// c = new MapTile(cx, cy, z);
|
p.state = STATE_LOADING;
|
||||||
//
|
mJobs.add(p);
|
||||||
// QuadTree.add(c);
|
}
|
||||||
// mTiles.add(c);
|
}
|
||||||
// }
|
|
||||||
//
|
return tile;
|
||||||
// if (!c.isActive()) {
|
|
||||||
// mJobs.add(c);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (fetchParent || (!fetchProxy && zdir > 0 && zoomLevel > 0)) {
|
|
||||||
// if (zdir > 0 && zoomLevel > 0) {
|
|
||||||
// // prefetch parent
|
|
||||||
// MapTile p = tile.rel.parent.tile;
|
|
||||||
//
|
|
||||||
// if (p == null) {
|
|
||||||
// p = new MapTile(x >> 1, y >> 1, (byte) (zoomLevel - 1));
|
|
||||||
//
|
|
||||||
// QuadTree.add(p);
|
|
||||||
// mTiles.add(p);
|
|
||||||
// mJobs.add(p);
|
|
||||||
//
|
|
||||||
// } else if (!p.isActive()) {
|
|
||||||
// if (!mJobs.contains(p))
|
|
||||||
// mJobs.add(p);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void clearTile(MapTile t) {
|
private static void clearTile(MapTile t) {
|
||||||
@ -648,6 +626,7 @@ public class TileManager {
|
|||||||
MapTile tile = (MapTile) jobTile;
|
MapTile tile = (MapTile) jobTile;
|
||||||
|
|
||||||
if (tile.state != STATE_LOADING) {
|
if (tile.state != STATE_LOADING) {
|
||||||
|
// - should rather be STATE_FAILED
|
||||||
// no one should be able to use this tile now, TileGenerator passed
|
// no one should be able to use this tile now, TileGenerator passed
|
||||||
// it, GL-Thread does nothing until newdata is set.
|
// it, GL-Thread does nothing until newdata is set.
|
||||||
//Log.d(TAG, "passTile: failed loading " + tile);
|
//Log.d(TAG, "passTile: failed loading " + tile);
|
||||||
@ -660,20 +639,12 @@ public class TileManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// tile.vbo = BufferObject.get(false);
|
|
||||||
//
|
|
||||||
// if (tile.vbo == null) {
|
|
||||||
// Log.d(TAG, "no VBOs left for " + tile);
|
|
||||||
// //clearTile(tile);
|
|
||||||
// //return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
tile.state = STATE_NEW_DATA;
|
tile.state = STATE_NEW_DATA;
|
||||||
|
|
||||||
mMapView.render();
|
mMapView.render();
|
||||||
|
|
||||||
synchronized (mTilesLoaded) {
|
synchronized (mTilesLoaded) {
|
||||||
if (!mTilesLoaded.contains(tile))
|
//if (!mTilesLoaded.contains(tile))
|
||||||
mTilesLoaded.add(tile);
|
mTilesLoaded.add(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user