refactoring: MapTile -> JobTile, GLMapTile -> MapTile, TreeTile -> QuadTree
This commit is contained in:
parent
d2a2dfb2f2
commit
2d90a4dea4
@ -15,7 +15,7 @@
|
|||||||
package org.mapsforge.android;
|
package org.mapsforge.android;
|
||||||
|
|
||||||
import org.mapsforge.android.mapgenerator.IMapGenerator;
|
import org.mapsforge.android.mapgenerator.IMapGenerator;
|
||||||
import org.mapsforge.android.mapgenerator.MapTile;
|
import org.mapsforge.android.mapgenerator.JobTile;
|
||||||
import org.mapsforge.android.rendertheme.RenderTheme;
|
import org.mapsforge.android.rendertheme.RenderTheme;
|
||||||
|
|
||||||
import android.opengl.GLSurfaceView;
|
import android.opengl.GLSurfaceView;
|
||||||
@ -30,7 +30,7 @@ public interface IMapRenderer extends GLSurfaceView.Renderer {
|
|||||||
* the mapGeneratorJob holding Tile data
|
* the mapGeneratorJob holding Tile data
|
||||||
* @return true if the tile was processed
|
* @return true if the tile was processed
|
||||||
*/
|
*/
|
||||||
public boolean passTile(MapTile tile);
|
public boolean passTile(JobTile tile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true when tile passed to renderer is processed false otherwise. used to lock overwriting resources passed
|
* @return true when tile passed to renderer is processed false otherwise. used to lock overwriting resources passed
|
||||||
|
|||||||
@ -28,7 +28,7 @@ import org.mapsforge.android.mapgenerator.MapDatabaseFactory;
|
|||||||
import org.mapsforge.android.mapgenerator.MapDatabases;
|
import org.mapsforge.android.mapgenerator.MapDatabases;
|
||||||
import org.mapsforge.android.mapgenerator.MapRendererFactory;
|
import org.mapsforge.android.mapgenerator.MapRendererFactory;
|
||||||
import org.mapsforge.android.mapgenerator.MapRenderers;
|
import org.mapsforge.android.mapgenerator.MapRenderers;
|
||||||
import org.mapsforge.android.mapgenerator.MapTile;
|
import org.mapsforge.android.mapgenerator.JobTile;
|
||||||
import org.mapsforge.android.mapgenerator.MapWorker;
|
import org.mapsforge.android.mapgenerator.MapWorker;
|
||||||
import org.mapsforge.android.mapgenerator.Theme;
|
import org.mapsforge.android.mapgenerator.Theme;
|
||||||
import org.mapsforge.android.rendertheme.ExternalRenderTheme;
|
import org.mapsforge.android.rendertheme.ExternalRenderTheme;
|
||||||
@ -651,7 +651,7 @@ public class MapView extends GLSurfaceView {
|
|||||||
* @param jobs
|
* @param jobs
|
||||||
* tile jobs
|
* tile jobs
|
||||||
*/
|
*/
|
||||||
public void addJobs(ArrayList<MapTile> jobs) {
|
public void addJobs(ArrayList<JobTile> jobs) {
|
||||||
if (jobs == null) {
|
if (jobs == null) {
|
||||||
mJobQueue.clear();
|
mJobQueue.clear();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -69,7 +69,7 @@ class LineLayers {
|
|||||||
|
|
||||||
static final boolean mFast = true;
|
static final boolean mFast = true;
|
||||||
|
|
||||||
static LineLayer drawLines(GLMapTile tile, LineLayer layer, int next, float[] matrix,
|
static LineLayer drawLines(MapTile tile, LineLayer layer, int next, float[] matrix,
|
||||||
float div, double zoom, float scale) {
|
float div, double zoom, float scale) {
|
||||||
|
|
||||||
float z = 1 / div;
|
float z = 1 / div;
|
||||||
|
|||||||
@ -17,7 +17,7 @@ package org.mapsforge.android.glrenderer;
|
|||||||
import org.mapsforge.android.DebugSettings;
|
import org.mapsforge.android.DebugSettings;
|
||||||
import org.mapsforge.android.MapView;
|
import org.mapsforge.android.MapView;
|
||||||
import org.mapsforge.android.mapgenerator.IMapGenerator;
|
import org.mapsforge.android.mapgenerator.IMapGenerator;
|
||||||
import org.mapsforge.android.mapgenerator.MapTile;
|
import org.mapsforge.android.mapgenerator.JobTile;
|
||||||
import org.mapsforge.android.rendertheme.IRenderCallback;
|
import org.mapsforge.android.rendertheme.IRenderCallback;
|
||||||
import org.mapsforge.android.rendertheme.RenderTheme;
|
import org.mapsforge.android.rendertheme.RenderTheme;
|
||||||
import org.mapsforge.android.rendertheme.renderinstruction.Area;
|
import org.mapsforge.android.rendertheme.renderinstruction.Area;
|
||||||
@ -57,7 +57,7 @@ public class MapGenerator implements IMapGenerator, IRenderCallback, IMapDatabas
|
|||||||
|
|
||||||
private IMapDatabase mMapDatabase;
|
private IMapDatabase mMapDatabase;
|
||||||
|
|
||||||
private GLMapTile mCurrentTile;
|
private MapTile mCurrentTile;
|
||||||
|
|
||||||
private float[] mWayNodes;
|
private float[] mWayNodes;
|
||||||
private short[] mWays;
|
private short[] mWays;
|
||||||
@ -415,13 +415,13 @@ public class MapGenerator implements IMapGenerator, IRenderCallback, IMapDatabas
|
|||||||
boolean mDebugDrawUnmatched;
|
boolean mDebugDrawUnmatched;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeJob(MapTile mapTile) {
|
public boolean executeJob(JobTile jobTile) {
|
||||||
GLMapTile tile;
|
MapTile tile;
|
||||||
|
|
||||||
if (mMapDatabase == null)
|
if (mMapDatabase == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
tile = mCurrentTile = (GLMapTile) mapTile;
|
tile = mCurrentTile = (MapTile) jobTile;
|
||||||
DebugSettings debugSettings = mMapView.getDebugSettings();
|
DebugSettings debugSettings = mMapView.getDebugSettings();
|
||||||
|
|
||||||
mDebugDrawPolygons = !debugSettings.mDisablePolygons;
|
mDebugDrawPolygons = !debugSettings.mDisablePolygons;
|
||||||
|
|||||||
@ -43,7 +43,7 @@ import javax.microedition.khronos.opengles.GL10;
|
|||||||
|
|
||||||
import org.mapsforge.android.MapView;
|
import org.mapsforge.android.MapView;
|
||||||
import org.mapsforge.android.mapgenerator.IMapGenerator;
|
import org.mapsforge.android.mapgenerator.IMapGenerator;
|
||||||
import org.mapsforge.android.mapgenerator.MapTile;
|
import org.mapsforge.android.mapgenerator.JobTile;
|
||||||
import org.mapsforge.android.rendertheme.RenderTheme;
|
import org.mapsforge.android.rendertheme.RenderTheme;
|
||||||
import org.mapsforge.android.utils.GlUtils;
|
import org.mapsforge.android.utils.GlUtils;
|
||||||
import org.mapsforge.core.MapPosition;
|
import org.mapsforge.core.MapPosition;
|
||||||
@ -70,14 +70,14 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
private static int CACHE_TILES = CACHE_TILES_MAX;
|
private static int CACHE_TILES = CACHE_TILES_MAX;
|
||||||
|
|
||||||
private final MapView mMapView;
|
private final MapView mMapView;
|
||||||
private static ArrayList<MapTile> mJobList;
|
private static ArrayList<JobTile> mJobList;
|
||||||
private static ArrayList<VertexBufferObject> mVBOs;
|
private static ArrayList<VertexBufferObject> mVBOs;
|
||||||
|
|
||||||
// all tiles currently referenced
|
// all tiles currently referenced
|
||||||
private static ArrayList<GLMapTile> mTiles;
|
private static ArrayList<MapTile> mTiles;
|
||||||
|
|
||||||
// tiles that have new data to upload, see passTile()
|
// tiles that have new data to upload, see passTile()
|
||||||
private static ArrayList<GLMapTile> mTilesLoaded;
|
private static ArrayList<MapTile> mTilesLoaded;
|
||||||
|
|
||||||
private static int mWidth, mHeight;
|
private static int mWidth, mHeight;
|
||||||
private static float mAspect;
|
private static float mAspect;
|
||||||
@ -97,10 +97,10 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
|
|
||||||
class TilesData {
|
class TilesData {
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
final GLMapTile[] tiles;
|
final MapTile[] tiles;
|
||||||
|
|
||||||
TilesData(int numTiles) {
|
TilesData(int numTiles) {
|
||||||
tiles = new GLMapTile[numTiles];
|
tiles = new MapTile[numTiles];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,16 +142,16 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
if (mInitial)
|
if (mInitial)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mJobList = new ArrayList<MapTile>();
|
mJobList = new ArrayList<JobTile>();
|
||||||
mTiles = new ArrayList<GLMapTile>();
|
mTiles = new ArrayList<MapTile>();
|
||||||
mTilesLoaded = new ArrayList<GLMapTile>(30);
|
mTilesLoaded = new ArrayList<MapTile>(30);
|
||||||
|
|
||||||
Matrix.setIdentityM(mMVPMatrix, 0);
|
Matrix.setIdentityM(mMVPMatrix, 0);
|
||||||
|
|
||||||
mInitial = true;
|
mInitial = true;
|
||||||
mUpdateTiles = false;
|
mUpdateTiles = false;
|
||||||
|
|
||||||
TreeTile.init();
|
QuadTree.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int updateTileDistances(ArrayList<?> tiles,
|
private static int updateTileDistances(ArrayList<?> tiles,
|
||||||
@ -169,7 +169,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
// to consider move/zoom direction
|
// to consider move/zoom direction
|
||||||
|
|
||||||
for (int i = 0, n = tiles.size(); i < n; i++) {
|
for (int i = 0, n = tiles.size(); i < n; i++) {
|
||||||
MapTile t = (MapTile) tiles.get(i);
|
JobTile t = (JobTile) tiles.get(i);
|
||||||
diff = (t.zoomLevel - zoom);
|
diff = (t.zoomLevel - zoom);
|
||||||
if (t.isActive)
|
if (t.isActive)
|
||||||
cnt++;
|
cnt++;
|
||||||
@ -205,8 +205,8 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean childIsActive(GLMapTile t) {
|
private static boolean childIsActive(MapTile t) {
|
||||||
GLMapTile c = null;
|
MapTile c = null;
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
if (t.rel.child[i] == null)
|
if (t.rel.child[i] == null)
|
||||||
@ -222,20 +222,20 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
|
|
||||||
// FIXME still the chance that one jumped two zoomlevels between
|
// FIXME still the chance that one jumped two zoomlevels between
|
||||||
// cur and draw. should use reference counter instead
|
// cur and draw. should use reference counter instead
|
||||||
private static boolean tileInUse(GLMapTile t) {
|
private static boolean tileInUse(MapTile t) {
|
||||||
byte z = mPrevZoom;
|
byte z = mPrevZoom;
|
||||||
|
|
||||||
if (t.isActive) {
|
if (t.isActive) {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if (t.zoomLevel == z + 1) {
|
} else if (t.zoomLevel == z + 1) {
|
||||||
GLMapTile p = t.rel.parent.tile;
|
MapTile p = t.rel.parent.tile;
|
||||||
|
|
||||||
if (p != null && p.isActive && !(p.isReady || p.newData))
|
if (p != null && p.isActive && !(p.isReady || p.newData))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if (t.zoomLevel == z + 2) {
|
} else if (t.zoomLevel == z + 2) {
|
||||||
GLMapTile p = t.rel.parent.parent.tile;
|
MapTile p = t.rel.parent.parent.tile;
|
||||||
|
|
||||||
if (p != null && p.isActive && !(p.isReady || p.newData))
|
if (p != null && p.isActive && !(p.isReady || p.newData))
|
||||||
return true;
|
return true;
|
||||||
@ -245,7 +245,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if (t.zoomLevel == z - 2) {
|
} else if (t.zoomLevel == z - 2) {
|
||||||
for (TreeTile c : t.rel.child) {
|
for (QuadTree c : t.rel.child) {
|
||||||
if (c == null)
|
if (c == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -253,11 +253,11 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (t.zoomLevel == z - 3) {
|
} else if (t.zoomLevel == z - 3) {
|
||||||
for (TreeTile c : t.rel.child) {
|
for (QuadTree c : t.rel.child) {
|
||||||
if (c == null)
|
if (c == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (TreeTile c2 : c.child) {
|
for (QuadTree c2 : c.child) {
|
||||||
if (c2 == null)
|
if (c2 == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
|
|
||||||
// remove orphaned tiles
|
// remove orphaned tiles
|
||||||
for (int i = 0; i < size;) {
|
for (int i = 0; i < size;) {
|
||||||
GLMapTile cur = mTiles.get(i);
|
MapTile cur = mTiles.get(i);
|
||||||
// make sure tile cannot be used by GL or MapWorker Thread
|
// make sure tile cannot be used by GL or MapWorker Thread
|
||||||
if ((!cur.isActive) && (!cur.isLoading) && (!cur.newData)
|
if ((!cur.isActive) && (!cur.isLoading) && (!cur.newData)
|
||||||
&& (!cur.isReady) && (!tileInUse(cur))) {
|
&& (!cur.isReady) && (!tileInUse(cur))) {
|
||||||
@ -302,11 +302,11 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
|
|
||||||
for (int i = 1; i <= removes; i++) {
|
for (int i = 1; i <= removes; i++) {
|
||||||
|
|
||||||
GLMapTile t = mTiles.get(0);
|
MapTile t = mTiles.get(0);
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
for (int j = 1; j < size; j++) {
|
for (int j = 1; j < size; j++) {
|
||||||
GLMapTile t2 = mTiles.get(j);
|
MapTile t2 = mTiles.get(j);
|
||||||
if (t2.distance > t.distance) {
|
if (t2.distance > t.distance) {
|
||||||
t = t2;
|
t = t2;
|
||||||
pos = j;
|
pos = j;
|
||||||
@ -347,7 +347,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
|
|
||||||
// remove uploaded tiles
|
// remove uploaded tiles
|
||||||
for (int i = 0; i < size;) {
|
for (int i = 0; i < size;) {
|
||||||
GLMapTile t = mTilesLoaded.get(i);
|
MapTile t = mTilesLoaded.get(i);
|
||||||
// rel == null means tile is already removed by limitCache
|
// rel == null means tile is already removed by limitCache
|
||||||
if (!t.newData || t.rel == null) {
|
if (!t.newData || t.rel == null) {
|
||||||
mTilesLoaded.remove(i);
|
mTilesLoaded.remove(i);
|
||||||
@ -362,7 +362,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
while (size-- > MAX_TILES_IN_QUEUE - 20) {
|
while (size-- > MAX_TILES_IN_QUEUE - 20) {
|
||||||
GLMapTile t = mTilesLoaded.get(size);
|
MapTile t = mTilesLoaded.get(size);
|
||||||
|
|
||||||
synchronized (t) {
|
synchronized (t) {
|
||||||
if (t.rel == null) {
|
if (t.rel == null) {
|
||||||
@ -419,12 +419,12 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
if (tiles == max)
|
if (tiles == max)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
GLMapTile tile = TreeTile.getTile(xx, yy, zoomLevel);
|
MapTile tile = QuadTree.getTile(xx, yy, zoomLevel);
|
||||||
|
|
||||||
if (tile == null) {
|
if (tile == null) {
|
||||||
tile = new GLMapTile(xx, yy, zoomLevel);
|
tile = new MapTile(xx, yy, zoomLevel);
|
||||||
|
|
||||||
TreeTile.add(tile);
|
QuadTree.add(tile);
|
||||||
mTiles.add(tile);
|
mTiles.add(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,12 +436,12 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
|
|
||||||
if (zdir > 0 && zoomLevel > 0) {
|
if (zdir > 0 && zoomLevel > 0) {
|
||||||
// prefetch parent
|
// prefetch parent
|
||||||
GLMapTile parent = tile.rel.parent.tile;
|
MapTile parent = tile.rel.parent.tile;
|
||||||
|
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
parent = new GLMapTile(xx >> 1, yy >> 1, (byte) (zoomLevel - 1));
|
parent = new MapTile(xx >> 1, yy >> 1, (byte) (zoomLevel - 1));
|
||||||
|
|
||||||
TreeTile.add(parent);
|
QuadTree.add(parent);
|
||||||
mTiles.add(parent);
|
mTiles.add(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -494,7 +494,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void clearTile(GLMapTile t) {
|
private static void clearTile(MapTile t) {
|
||||||
t.newData = false;
|
t.newData = false;
|
||||||
t.isLoading = false;
|
t.isLoading = false;
|
||||||
t.isReady = false;
|
t.isReady = false;
|
||||||
@ -513,7 +513,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
t.vbo = null;
|
t.vbo = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeTile.remove(t);
|
QuadTree.remove(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -534,12 +534,12 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
mInitial = true;
|
mInitial = true;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
|
||||||
for (GLMapTile t : mTiles)
|
for (MapTile t : mTiles)
|
||||||
clearTile(t);
|
clearTile(t);
|
||||||
|
|
||||||
mTiles.clear();
|
mTiles.clear();
|
||||||
mTilesLoaded.clear();
|
mTilesLoaded.clear();
|
||||||
TreeTile.init();
|
QuadTree.init();
|
||||||
curTiles.cnt = 0;
|
curTiles.cnt = 0;
|
||||||
mBufferMemoryUsage = 0;
|
mBufferMemoryUsage = 0;
|
||||||
}
|
}
|
||||||
@ -613,8 +613,8 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
* called by MapWorkers when tile is loaded
|
* called by MapWorkers when tile is loaded
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean passTile(MapTile mapTile) {
|
public synchronized boolean passTile(JobTile jobTile) {
|
||||||
GLMapTile tile = (GLMapTile) mapTile;
|
MapTile tile = (MapTile) jobTile;
|
||||||
|
|
||||||
if (tile.isCanceled) {
|
if (tile.isCanceled) {
|
||||||
// no one should be able to use this tile now, mapgenerator passed it,
|
// no one should be able to use this tile now, mapgenerator passed it,
|
||||||
@ -655,7 +655,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
// ... asus has just 16 bit?!
|
// ... asus has just 16 bit?!
|
||||||
// private static final float depthStep = 0.00000011920928955078125f;
|
// private static final float depthStep = 0.00000011920928955078125f;
|
||||||
|
|
||||||
private static void setMatrix(GLMapTile tile, float div, int offset) {
|
private static void setMatrix(MapTile tile, float div, int offset) {
|
||||||
float x, y, scale;
|
float x, y, scale;
|
||||||
|
|
||||||
scale = (float) (2.0 * mDrawPosition.scale / (mHeight * div));
|
scale = (float) (2.0 * mDrawPosition.scale / (mHeight * div));
|
||||||
@ -685,7 +685,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean setTileScissor(GLMapTile tile, float div) {
|
private static boolean setTileScissor(MapTile tile, float div) {
|
||||||
double dx, dy, scale;
|
double dx, dy, scale;
|
||||||
|
|
||||||
if (div == 0) {
|
if (div == 0) {
|
||||||
@ -715,7 +715,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
|
|
||||||
private int uploadCnt = 0;
|
private int uploadCnt = 0;
|
||||||
|
|
||||||
private boolean uploadTileData(GLMapTile tile) {
|
private boolean uploadTileData(MapTile tile) {
|
||||||
ShortBuffer sbuf = null;
|
ShortBuffer sbuf = null;
|
||||||
|
|
||||||
// use multiple buffers to avoid overwriting buffer while current
|
// use multiple buffers to avoid overwriting buffer while current
|
||||||
@ -895,14 +895,14 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int tileCnt = drawTiles.cnt;
|
int tileCnt = drawTiles.cnt;
|
||||||
GLMapTile[] tiles = drawTiles.tiles;
|
MapTile[] tiles = drawTiles.tiles;
|
||||||
|
|
||||||
uploadCnt = 0;
|
uploadCnt = 0;
|
||||||
int updateTextures = 0;
|
int updateTextures = 0;
|
||||||
|
|
||||||
// check visible tiles, upload new vertex data
|
// check visible tiles, upload new vertex data
|
||||||
for (int i = 0; i < tileCnt; i++) {
|
for (int i = 0; i < tileCnt; i++) {
|
||||||
GLMapTile tile = tiles[i];
|
MapTile tile = tiles[i];
|
||||||
|
|
||||||
if (!setTileScissor(tile, 1))
|
if (!setTileScissor(tile, 1))
|
||||||
continue;
|
continue;
|
||||||
@ -917,7 +917,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
|
|
||||||
if (!tile.isReady) {
|
if (!tile.isReady) {
|
||||||
// check near relatives if they can serve as proxy
|
// check near relatives if they can serve as proxy
|
||||||
GLMapTile rel = tile.rel.parent.tile;
|
MapTile rel = tile.rel.parent.tile;
|
||||||
if (rel != null && rel.newData) {
|
if (rel != null && rel.newData) {
|
||||||
uploadTileData(rel);
|
uploadTileData(rel);
|
||||||
} else {
|
} else {
|
||||||
@ -993,7 +993,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
// used to not draw a tile twice per frame...
|
// used to not draw a tile twice per frame...
|
||||||
private static byte mDrawSerial = 0;
|
private static byte mDrawSerial = 0;
|
||||||
|
|
||||||
private static void drawTile(GLMapTile tile, float div) {
|
private static void drawTile(MapTile tile, float div) {
|
||||||
// draw parents only once
|
// draw parents only once
|
||||||
if (tile.lastDraw == mDrawSerial)
|
if (tile.lastDraw == mDrawSerial)
|
||||||
return;
|
return;
|
||||||
@ -1045,13 +1045,13 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean drawProxyChild(GLMapTile tile) {
|
private static boolean drawProxyChild(MapTile tile) {
|
||||||
int drawn = 0;
|
int drawn = 0;
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
if (tile.rel.child[i] == null)
|
if (tile.rel.child[i] == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
GLMapTile c = tile.rel.child[i].tile;
|
MapTile c = tile.rel.child[i].tile;
|
||||||
if (c == null)
|
if (c == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -1068,17 +1068,17 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
return drawn == 4;
|
return drawn == 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void drawProxyTile(GLMapTile tile) {
|
private static void drawProxyTile(MapTile tile) {
|
||||||
|
|
||||||
if (mDrawPosition.scale > 1.5f) {
|
if (mDrawPosition.scale > 1.5f) {
|
||||||
// prefer drawing children
|
// prefer drawing children
|
||||||
if (!drawProxyChild(tile)) {
|
if (!drawProxyChild(tile)) {
|
||||||
GLMapTile t = tile.rel.parent.tile;
|
MapTile t = tile.rel.parent.tile;
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
if (t.isReady) {
|
if (t.isReady) {
|
||||||
drawTile(t, 0.5f);
|
drawTile(t, 0.5f);
|
||||||
} else {
|
} else {
|
||||||
GLMapTile p = t.rel.parent.tile;
|
MapTile p = t.rel.parent.tile;
|
||||||
if (p != null && p.isReady)
|
if (p != null && p.isReady)
|
||||||
drawTile(p, 0.25f);
|
drawTile(p, 0.25f);
|
||||||
}
|
}
|
||||||
@ -1086,7 +1086,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// prefer drawing parent
|
// prefer drawing parent
|
||||||
GLMapTile t = tile.rel.parent.tile;
|
MapTile t = tile.rel.parent.tile;
|
||||||
|
|
||||||
if (t != null && t.isReady) {
|
if (t != null && t.isReady) {
|
||||||
drawTile(t, 0.5f);
|
drawTile(t, 0.5f);
|
||||||
@ -1111,7 +1111,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
mTiles.clear();
|
mTiles.clear();
|
||||||
|
|
||||||
ShortPool.init();
|
ShortPool.init();
|
||||||
TreeTile.init();
|
QuadTree.init();
|
||||||
// LineLayers.finish();
|
// LineLayers.finish();
|
||||||
|
|
||||||
drawTiles = newTiles = curTiles = null;
|
drawTiles = newTiles = curTiles = null;
|
||||||
|
|||||||
@ -14,9 +14,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapsforge.android.glrenderer;
|
package org.mapsforge.android.glrenderer;
|
||||||
|
|
||||||
import org.mapsforge.android.mapgenerator.MapTile;
|
import org.mapsforge.android.mapgenerator.JobTile;
|
||||||
|
|
||||||
class GLMapTile extends MapTile {
|
class MapTile extends JobTile {
|
||||||
byte lastDraw = 0;
|
byte lastDraw = 0;
|
||||||
|
|
||||||
// VBO layout:
|
// VBO layout:
|
||||||
@ -38,9 +38,9 @@ class GLMapTile extends MapTile {
|
|||||||
boolean newData;
|
boolean newData;
|
||||||
|
|
||||||
// pointer to access relatives in TileTree
|
// pointer to access relatives in TileTree
|
||||||
TreeTile rel;
|
QuadTree rel;
|
||||||
|
|
||||||
GLMapTile(int tileX, int tileY, byte zoomLevel) {
|
MapTile(int tileX, int tileY, byte zoomLevel) {
|
||||||
super(tileX, tileY, zoomLevel);
|
super(tileX, tileY, zoomLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,43 +16,43 @@ package org.mapsforge.android.glrenderer;
|
|||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
class TreeTile {
|
class QuadTree {
|
||||||
private static String TAG = "TreeTile";
|
private static String TAG = "QuadTree";
|
||||||
|
|
||||||
private static TreeTile root;
|
private static QuadTree root;
|
||||||
|
|
||||||
// parent pointer is used to link pool items
|
// parent pointer is used to link pool items
|
||||||
private static TreeTile pool;
|
private static QuadTree pool;
|
||||||
|
|
||||||
// TreeTile members
|
// TreeTile members
|
||||||
TreeTile parent;
|
QuadTree parent;
|
||||||
final TreeTile[] child = new TreeTile[4];
|
final QuadTree[] child = new QuadTree[4];
|
||||||
int refs = 0;
|
int refs = 0;
|
||||||
byte id;
|
byte id;
|
||||||
GLMapTile tile;
|
MapTile tile;
|
||||||
|
|
||||||
static void init() {
|
static void init() {
|
||||||
|
|
||||||
pool = null;
|
pool = null;
|
||||||
root = new TreeTile();
|
root = new QuadTree();
|
||||||
root.parent = root;
|
root.parent = root;
|
||||||
|
|
||||||
TreeTile t;
|
QuadTree t;
|
||||||
for (int i = 0; i < 200; i++) {
|
for (int i = 0; i < 200; i++) {
|
||||||
t = new TreeTile();
|
t = new QuadTree();
|
||||||
t.parent = pool;
|
t.parent = pool;
|
||||||
pool = t;
|
pool = t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean remove(GLMapTile t) {
|
static boolean remove(MapTile t) {
|
||||||
if (t.rel == null) {
|
if (t.rel == null) {
|
||||||
Log.d(TAG, "already removed " + t);
|
Log.d(TAG, "already removed " + t);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeTile cur = t.rel;
|
QuadTree cur = t.rel;
|
||||||
TreeTile next;
|
QuadTree next;
|
||||||
|
|
||||||
for (; cur != root;) {
|
for (; cur != root;) {
|
||||||
// keep pointer to parent
|
// keep pointer to parent
|
||||||
@ -79,13 +79,13 @@ class TreeTile {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TreeTile add(GLMapTile tile) {
|
static QuadTree add(MapTile tile) {
|
||||||
|
|
||||||
int x = tile.tileX;
|
int x = tile.tileX;
|
||||||
int y = tile.tileY;
|
int y = tile.tileY;
|
||||||
int z = tile.zoomLevel;
|
int z = tile.zoomLevel;
|
||||||
|
|
||||||
TreeTile cur;
|
QuadTree cur;
|
||||||
|
|
||||||
// if (x < 0 || x >= 1 << z) {
|
// if (x < 0 || x >= 1 << z) {
|
||||||
// Log.d(TAG, "invalid position");
|
// Log.d(TAG, "invalid position");
|
||||||
@ -96,7 +96,7 @@ class TreeTile {
|
|||||||
// return null;
|
// return null;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
TreeTile leaf = root;
|
QuadTree leaf = root;
|
||||||
|
|
||||||
for (int level = z - 1; level >= 0; level--) {
|
for (int level = z - 1; level >= 0; level--) {
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ class TreeTile {
|
|||||||
cur = pool;
|
cur = pool;
|
||||||
pool = pool.parent;
|
pool = pool.parent;
|
||||||
} else {
|
} else {
|
||||||
cur = new TreeTile();
|
cur = new QuadTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
cur.refs = 0;
|
cur.refs = 0;
|
||||||
@ -133,8 +133,8 @@ class TreeTile {
|
|||||||
return leaf;
|
return leaf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLMapTile getTile(int x, int y, int z) {
|
static MapTile getTile(int x, int y, int z) {
|
||||||
TreeTile leaf = root;
|
QuadTree leaf = root;
|
||||||
|
|
||||||
for (int level = z - 1; level >= 0; level--) {
|
for (int level = z - 1; level >= 0; level--) {
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ public class TextRenderer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean drawToTexture(GLMapTile tile) {
|
static boolean drawToTexture(MapTile tile) {
|
||||||
TextTexture tex = null;
|
TextTexture tex = null;
|
||||||
|
|
||||||
if (tile.labels == null)
|
if (tile.labels == null)
|
||||||
@ -427,7 +427,7 @@ public class TextRenderer {
|
|||||||
GLES20.glDisableVertexAttribArray(hTextVertex);
|
GLES20.glDisableVertexAttribArray(hTextVertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawTile(GLMapTile tile, float[] matrix) {
|
static void drawTile(MapTile tile, float[] matrix) {
|
||||||
|
|
||||||
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tile.texture.id);
|
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tile.texture.id);
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@ public class TextTexture {
|
|||||||
final int id;
|
final int id;
|
||||||
int length;
|
int length;
|
||||||
int offset;
|
int offset;
|
||||||
GLMapTile tile;
|
MapTile tile;
|
||||||
|
|
||||||
String[] text;
|
String[] text;
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,7 @@ public interface IMapGenerator {
|
|||||||
* the job that should be executed.
|
* the job that should be executed.
|
||||||
* @return true if the job was executed successfully, false otherwise.
|
* @return true if the job was executed successfully, false otherwise.
|
||||||
*/
|
*/
|
||||||
boolean executeJob(MapTile tile);
|
boolean executeJob(JobTile tile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mapDatabase
|
* @param mapDatabase
|
||||||
|
|||||||
@ -23,29 +23,36 @@ import java.util.PriorityQueue;
|
|||||||
public class JobQueue {
|
public class JobQueue {
|
||||||
private static final int INITIAL_CAPACITY = 64;
|
private static final int INITIAL_CAPACITY = 64;
|
||||||
|
|
||||||
private PriorityQueue<MapTile> mPriorityQueue;
|
private PriorityQueue<JobTile> mPriorityQueue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public JobQueue() {
|
public JobQueue() {
|
||||||
mPriorityQueue = new PriorityQueue<MapTile>(INITIAL_CAPACITY);
|
mPriorityQueue = new PriorityQueue<JobTile>(INITIAL_CAPACITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param tiles
|
* @param tiles
|
||||||
* the job to be added to this queue.
|
* the job to be added to this queue.
|
||||||
*/
|
*/
|
||||||
public synchronized void setJobs(ArrayList<MapTile> tiles) {
|
public synchronized void setJobs(ArrayList<JobTile> tiles) {
|
||||||
mPriorityQueue.clear();
|
mPriorityQueue.clear();
|
||||||
mPriorityQueue.addAll(tiles);
|
// mPriorityQueue.addAll(tiles);
|
||||||
// for (int i = 0, n = tiles.size(); i < n; i++)
|
for (int i = 0, n = tiles.size(); i < n; i++) {
|
||||||
// mPriorityQueue.offer(tiles.get(i));
|
JobTile tile = tiles.get(i);
|
||||||
|
tile.isLoading = true;
|
||||||
|
mPriorityQueue.offer(tile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all jobs from this queue.
|
* Removes all jobs from this queue.
|
||||||
*/
|
*/
|
||||||
public synchronized void clear() {
|
public synchronized void clear() {
|
||||||
|
for (int i = 0, n = mPriorityQueue.size(); i < n; i++) {
|
||||||
|
JobTile tile = mPriorityQueue.poll();
|
||||||
|
tile.isLoading = false;
|
||||||
|
}
|
||||||
mPriorityQueue.clear();
|
mPriorityQueue.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,10 +66,8 @@ public class JobQueue {
|
|||||||
/**
|
/**
|
||||||
* @return the most important job from this queue or null, if empty.
|
* @return the most important job from this queue or null, if empty.
|
||||||
*/
|
*/
|
||||||
public synchronized MapTile poll() {
|
public synchronized JobTile poll() {
|
||||||
MapTile tile = mPriorityQueue.poll();
|
JobTile tile = mPriorityQueue.poll();
|
||||||
if (tile != null)
|
|
||||||
tile.isLoading = true;
|
|
||||||
|
|
||||||
return tile;
|
return tile;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import org.mapsforge.core.Tile;
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class MapTile extends Tile implements Comparable<MapTile> {
|
public class JobTile extends Tile implements Comparable<JobTile> {
|
||||||
/**
|
/**
|
||||||
* tile is loaded and ready for drawing. (set and used by render thread after uploading data to gl).
|
* tile is loaded and ready for drawing. (set and used by render thread after uploading data to gl).
|
||||||
*/
|
*/
|
||||||
@ -53,12 +53,12 @@ public class MapTile extends Tile implements Comparable<MapTile> {
|
|||||||
* @param zoomLevel
|
* @param zoomLevel
|
||||||
* ..
|
* ..
|
||||||
*/
|
*/
|
||||||
public MapTile(int tileX, int tileY, byte zoomLevel) {
|
public JobTile(int tileX, int tileY, byte zoomLevel) {
|
||||||
super(tileX, tileY, zoomLevel);
|
super(tileX, tileY, zoomLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(MapTile o) {
|
public int compareTo(JobTile o) {
|
||||||
if (this.distance < o.distance) {
|
if (this.distance < o.distance) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (this.distance > o.distance) {
|
} else if (this.distance > o.distance) {
|
||||||
@ -62,7 +62,7 @@ public class MapWorker extends PausableThread {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doWork() {
|
protected void doWork() {
|
||||||
MapTile tile = mJobQueue.poll();
|
JobTile tile = mJobQueue.poll();
|
||||||
|
|
||||||
if (mMapGenerator == null || tile == null)
|
if (mMapGenerator == null || tile == null)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -20,10 +20,10 @@ import java.util.Comparator;
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TileDistanceSort implements Comparator<MapTile> {
|
public class TileDistanceSort implements Comparator<JobTile> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(MapTile tile1, MapTile tile2) {
|
public int compare(JobTile tile1, JobTile tile2) {
|
||||||
if (tile1.distance == tile2.distance)
|
if (tile1.distance == tile2.distance)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import java.util.List;
|
|||||||
import org.mapsforge.android.DebugSettings;
|
import org.mapsforge.android.DebugSettings;
|
||||||
import org.mapsforge.android.MapView;
|
import org.mapsforge.android.MapView;
|
||||||
import org.mapsforge.android.mapgenerator.IMapGenerator;
|
import org.mapsforge.android.mapgenerator.IMapGenerator;
|
||||||
import org.mapsforge.android.mapgenerator.MapTile;
|
import org.mapsforge.android.mapgenerator.JobTile;
|
||||||
import org.mapsforge.android.rendertheme.IRenderCallback;
|
import org.mapsforge.android.rendertheme.IRenderCallback;
|
||||||
import org.mapsforge.android.rendertheme.RenderTheme;
|
import org.mapsforge.android.rendertheme.RenderTheme;
|
||||||
import org.mapsforge.android.rendertheme.renderinstruction.Area;
|
import org.mapsforge.android.rendertheme.renderinstruction.Area;
|
||||||
@ -138,13 +138,13 @@ public class MapGenerator implements IMapGenerator, IRenderCallback,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeJob(MapTile mapTile) {
|
public boolean executeJob(JobTile jobTile) {
|
||||||
long time_load = System.currentTimeMillis();
|
long time_load = System.currentTimeMillis();
|
||||||
_nodes = 0;
|
_nodes = 0;
|
||||||
_nodesDropped = 0;
|
_nodesDropped = 0;
|
||||||
// _renderTime = 0;
|
// _renderTime = 0;
|
||||||
|
|
||||||
mCurrentTile = mapTile;
|
mCurrentTile = jobTile;
|
||||||
mCurrentTileZoom = ((long) Tile.TILE_SIZE << mCurrentTile.zoomLevel);
|
mCurrentTileZoom = ((long) Tile.TILE_SIZE << mCurrentTile.zoomLevel);
|
||||||
mCurrentTileX = mCurrentTile.pixelX;
|
mCurrentTileX = mCurrentTile.pixelX;
|
||||||
mCurrentTileY = mCurrentTile.pixelY;
|
mCurrentTileY = mCurrentTile.pixelY;
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import javax.microedition.khronos.opengles.GL10;
|
|||||||
|
|
||||||
import org.mapsforge.android.MapView;
|
import org.mapsforge.android.MapView;
|
||||||
import org.mapsforge.android.mapgenerator.IMapGenerator;
|
import org.mapsforge.android.mapgenerator.IMapGenerator;
|
||||||
import org.mapsforge.android.mapgenerator.MapTile;
|
import org.mapsforge.android.mapgenerator.JobTile;
|
||||||
import org.mapsforge.android.mapgenerator.TileDistanceSort;
|
import org.mapsforge.android.mapgenerator.TileDistanceSort;
|
||||||
import org.mapsforge.android.rendertheme.RenderTheme;
|
import org.mapsforge.android.rendertheme.RenderTheme;
|
||||||
import org.mapsforge.android.utils.GlUtils;
|
import org.mapsforge.android.utils.GlUtils;
|
||||||
@ -64,18 +64,18 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
// private JobParameters mJobParameter;
|
// private JobParameters mJobParameter;
|
||||||
private MapPosition mMapPosition, mPrevMapPosition;
|
private MapPosition mMapPosition, mPrevMapPosition;
|
||||||
|
|
||||||
private ArrayList<MapTile> mJobList;
|
private ArrayList<JobTile> mJobList;
|
||||||
|
|
||||||
ArrayList<Integer> mTextures;
|
ArrayList<Integer> mTextures;
|
||||||
MapView mMapView;
|
MapView mMapView;
|
||||||
|
|
||||||
GLMapTile[] currentTiles;
|
MapTile[] currentTiles;
|
||||||
GLMapTile[] newTiles;
|
MapTile[] newTiles;
|
||||||
int currentTileCnt = 0;
|
int currentTileCnt = 0;
|
||||||
|
|
||||||
// private TileCacheKey mTileCacheKey;
|
// private TileCacheKey mTileCacheKey;
|
||||||
// private LinkedHashMap<TileCacheKey, GLMapTile> mTiles;
|
// private LinkedHashMap<TileCacheKey, GLMapTile> mTiles;
|
||||||
private ArrayList<GLMapTile> mTileList;
|
private ArrayList<MapTile> mTileList;
|
||||||
|
|
||||||
private boolean processedTile = true;
|
private boolean processedTile = true;
|
||||||
|
|
||||||
@ -105,10 +105,10 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
mVertices.put(vertices);
|
mVertices.put(vertices);
|
||||||
|
|
||||||
mTextures = new ArrayList<Integer>();
|
mTextures = new ArrayList<Integer>();
|
||||||
mJobList = new ArrayList<MapTile>();
|
mJobList = new ArrayList<JobTile>();
|
||||||
|
|
||||||
// mTiles = new LinkedHashMap<TileCacheKey, GLMapTile>(100);
|
// mTiles = new LinkedHashMap<TileCacheKey, GLMapTile>(100);
|
||||||
mTileList = new ArrayList<GLMapTile>();
|
mTileList = new ArrayList<MapTile>();
|
||||||
|
|
||||||
// mTileCacheKey = new TileCacheKey();
|
// mTileCacheKey = new TileCacheKey();
|
||||||
mInitial = true;
|
mInitial = true;
|
||||||
@ -119,7 +119,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
long y = mTileY;
|
long y = mTileY;
|
||||||
int diff;
|
int diff;
|
||||||
|
|
||||||
for (GLMapTile t : mTileList) {
|
for (MapTile t : mTileList) {
|
||||||
|
|
||||||
diff = (t.zoomLevel - zoom);
|
diff = (t.zoomLevel - zoom);
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
Collections.sort(mTileList, tileDistanceSort);
|
Collections.sort(mTileList, tileDistanceSort);
|
||||||
|
|
||||||
for (int j = mTileList.size() - 1, cnt = 0; cnt < remove; j--, cnt++) {
|
for (int j = mTileList.size() - 1, cnt = 0; cnt < remove; j--, cnt++) {
|
||||||
GLMapTile t = mTileList.remove(j);
|
MapTile t = mTileList.remove(j);
|
||||||
|
|
||||||
// mTileCacheKey.set(t.tileX, t.tileY, t.zoomLevel);
|
// mTileCacheKey.set(t.tileX, t.tileY, t.zoomLevel);
|
||||||
// mTiles.remove(mTileCacheKey);
|
// mTiles.remove(mTileCacheKey);
|
||||||
@ -298,7 +298,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
// private MapGeneratorJob mMapGeneratorJob = null;
|
// private MapGeneratorJob mMapGeneratorJob = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean passTile(MapTile mapTile) {
|
public boolean passTile(JobTile jobTile) {
|
||||||
|
|
||||||
// mMapGeneratorJob = mapGeneratorJob;
|
// mMapGeneratorJob = mapGeneratorJob;
|
||||||
processedTile = false;
|
processedTile = false;
|
||||||
@ -307,7 +307,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean drawTile(GLMapTile tile, int level, float height) {
|
private boolean drawTile(MapTile tile, int level, float height) {
|
||||||
|
|
||||||
// do not recurse more than two parents
|
// do not recurse more than two parents
|
||||||
if (level > 2)
|
if (level > 2)
|
||||||
@ -416,7 +416,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
|
|
||||||
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
|
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
|
||||||
|
|
||||||
GLMapTile tile, child, child2;
|
MapTile tile, child, child2;
|
||||||
|
|
||||||
GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
|
GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
|
||||||
|
|
||||||
@ -494,8 +494,8 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
mHeight = height;
|
mHeight = height;
|
||||||
|
|
||||||
int tiles = (mWidth / Tile.TILE_SIZE + 4) * (mHeight / Tile.TILE_SIZE + 4);
|
int tiles = (mWidth / Tile.TILE_SIZE + 4) * (mHeight / Tile.TILE_SIZE + 4);
|
||||||
currentTiles = new GLMapTile[tiles];
|
currentTiles = new MapTile[tiles];
|
||||||
newTiles = new GLMapTile[tiles];
|
newTiles = new MapTile[tiles];
|
||||||
|
|
||||||
GLES20.glViewport(0, 0, width, height);
|
GLES20.glViewport(0, 0, width, height);
|
||||||
|
|
||||||
|
|||||||
@ -14,16 +14,16 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapsforge.android.swrenderer;
|
package org.mapsforge.android.swrenderer;
|
||||||
|
|
||||||
import org.mapsforge.android.mapgenerator.MapTile;
|
import org.mapsforge.android.mapgenerator.JobTile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class GLMapTile extends MapTile {
|
public class MapTile extends JobTile {
|
||||||
private float mScale;
|
private float mScale;
|
||||||
|
|
||||||
final GLMapTile[] child = { null, null, null, null };
|
final MapTile[] child = { null, null, null, null };
|
||||||
GLMapTile parent;
|
MapTile parent;
|
||||||
|
|
||||||
// private long mLoadTime;
|
// private long mLoadTime;
|
||||||
private int mTextureID;
|
private int mTextureID;
|
||||||
@ -36,7 +36,7 @@ public class GLMapTile extends MapTile {
|
|||||||
* @param zoomLevel
|
* @param zoomLevel
|
||||||
* ..
|
* ..
|
||||||
*/
|
*/
|
||||||
public GLMapTile(int tileX, int tileY, byte zoomLevel) {
|
public MapTile(int tileX, int tileY, byte zoomLevel) {
|
||||||
super(tileX, tileY, zoomLevel);
|
super(tileX, tileY, zoomLevel);
|
||||||
mScale = 1;
|
mScale = 1;
|
||||||
mTextureID = -1;
|
mTextureID = -1;
|
||||||
Loading…
x
Reference in New Issue
Block a user