add MapView.clearMap() -> clear all previous map state in Layers on next onUpate
- now labels are cleared properly when the or mapdb changes. - getTileSet now requires a TileSet instance as input
This commit is contained in:
@@ -41,6 +41,7 @@ public class ExtrusionRenderLayer extends RenderLayer {
|
||||
public ExtrusionRenderLayer(MapView mapView, org.oscim.layers.tile.TileRenderLayer tileRenderLayer) {
|
||||
super(mapView);
|
||||
mTileLayer = tileRenderLayer;
|
||||
mTileSet = new TileSet();
|
||||
}
|
||||
|
||||
private static int[] shaderProgram = new int[2];
|
||||
@@ -56,7 +57,7 @@ public class ExtrusionRenderLayer extends RenderLayer {
|
||||
// FIXME sum up size used while filling layer only up to:
|
||||
//public int mBufferSize = 65536;
|
||||
|
||||
private TileSet mTileSet;
|
||||
private final TileSet mTileSet;
|
||||
private MapTile[] mTiles;
|
||||
private int mTileCnt;
|
||||
|
||||
@@ -85,18 +86,15 @@ public class ExtrusionRenderLayer extends RenderLayer {
|
||||
}
|
||||
}
|
||||
|
||||
int ready = 0;
|
||||
mTileSet = mTileLayer.getVisibleTiles(mTileSet);
|
||||
if (mTileSet == null)
|
||||
return;
|
||||
|
||||
MapTile[] tiles = mTileSet.tiles;
|
||||
// FIXME just release tiles in this case
|
||||
if (mAlpha == 0 || pos.zoomLevel < 16) {
|
||||
isReady = false;
|
||||
return;
|
||||
}
|
||||
|
||||
int ready = 0;
|
||||
mTileLayer.getVisibleTiles(mTileSet);
|
||||
MapTile[] tiles = mTileSet.tiles;
|
||||
|
||||
// keep a list of tiles available for rendering
|
||||
if (mTiles == null || mTiles.length < mTileSet.cnt * 4)
|
||||
mTiles = new MapTile[mTileSet.cnt * 4];
|
||||
@@ -104,9 +102,6 @@ public class ExtrusionRenderLayer extends RenderLayer {
|
||||
ExtrusionLayer el;
|
||||
if (pos.zoomLevel >= 17) {
|
||||
for (int i = 0; i < mTileSet.cnt; i++) {
|
||||
if (!tiles[i].isVisible)
|
||||
continue;
|
||||
|
||||
el = getLayer(tiles[i]);
|
||||
if (el == null)
|
||||
continue;
|
||||
@@ -123,12 +118,9 @@ public class ExtrusionRenderLayer extends RenderLayer {
|
||||
mTiles[ready++] = tiles[i];
|
||||
}
|
||||
} else if (pos.zoomLevel == 16) {
|
||||
// check if proxy children are ready
|
||||
for (int i = 0; i < mTileSet.cnt; i++) {
|
||||
if (!tiles[i].isVisible)
|
||||
continue;
|
||||
|
||||
MapTile t = tiles[i];
|
||||
|
||||
for (byte j = 0; j < 4; j++) {
|
||||
if ((t.proxies & (1 << j)) != 0) {
|
||||
MapTile c = t.rel.get(j);
|
||||
|
||||
@@ -57,6 +57,7 @@ import org.oscim.view.MapViewPosition;
|
||||
|
||||
import android.opengl.GLES20;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
|
||||
public class TextRenderLayer extends BasicRenderLayer {
|
||||
private final static String TAG = TextRenderLayer.class.getName();
|
||||
@@ -64,7 +65,7 @@ public class TextRenderLayer extends BasicRenderLayer {
|
||||
private final static float MIN_WAY_DIST = 3;
|
||||
|
||||
private final MapViewPosition mMapViewPosition;
|
||||
private TileSet mTileSet;
|
||||
private final TileSet mTileSet;
|
||||
private final LabelThread mThread;
|
||||
|
||||
private MapPosition mTmpPos;
|
||||
@@ -170,15 +171,18 @@ public class TextRenderLayer extends BasicRenderLayer {
|
||||
@Override
|
||||
protected void doWork() {
|
||||
SystemClock.sleep(250);
|
||||
|
||||
if (!mRun)
|
||||
return;
|
||||
|
||||
mRun = false;
|
||||
synchronized (this) {
|
||||
|
||||
if (updateLabels()) {
|
||||
mMapView.render();
|
||||
} else {
|
||||
mRun = true;
|
||||
if (updateLabels()) {
|
||||
mRun = false;
|
||||
mMapView.render();
|
||||
} else {
|
||||
mRun = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,8 +206,10 @@ public class TextRenderLayer extends BasicRenderLayer {
|
||||
|
||||
mMapViewPosition = mapView.getMapViewPosition();
|
||||
mTileLayer = baseLayer;
|
||||
mTileSet = new TileSet();
|
||||
layers.textureLayers = new TextLayer();
|
||||
mTmpLayer = new TextLayer();
|
||||
|
||||
//mActiveTiles = new HashMap<MapTile, LabelTile>();
|
||||
mTmpPos = new MapPosition();
|
||||
mThread = new LabelThread();
|
||||
@@ -348,9 +354,7 @@ public class TextRenderLayer extends BasicRenderLayer {
|
||||
return false;
|
||||
|
||||
// get current tiles
|
||||
mTileSet = mTileLayer.getVisibleTiles(mTileSet);
|
||||
if (mTileSet == null)
|
||||
return false;
|
||||
mTileLayer.getVisibleTiles(mTileSet);
|
||||
|
||||
if (mTileSet.cnt == 0)
|
||||
return false;
|
||||
@@ -613,10 +617,10 @@ public class TextRenderLayer extends BasicRenderLayer {
|
||||
mTileLayer.releaseTiles(mTileSet);
|
||||
|
||||
// pass new labels for rendering
|
||||
synchronized (this) {
|
||||
//synchronized (this) {
|
||||
mNextLayer = tl;
|
||||
mDebugLayer = dbg;
|
||||
}
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -774,4 +778,14 @@ public class TextRenderLayer extends BasicRenderLayer {
|
||||
// mRun = false;
|
||||
// }
|
||||
}
|
||||
|
||||
public void clearLabels() {
|
||||
Log.d(TAG, "clearLabels");
|
||||
synchronized (mThread) {
|
||||
mRun = false;
|
||||
mPool.releaseAll(mPrevLabels);
|
||||
mPrevLabels = null;
|
||||
mTileSet.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user