clear all tiles on clearAndRedraw,
cleanups
This commit is contained in:
parent
4cae011d85
commit
331aa6bf68
@ -453,6 +453,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
if (removes > 0)
|
if (removes > 0)
|
||||||
Collections.sort(mTileList, mTileDistanceSort);
|
Collections.sort(mTileList, mTileDistanceSort);
|
||||||
|
|
||||||
|
// pass new tile list to glThread
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
for (int i = 0; i < nextTiles.cnt; i++)
|
for (int i = 0; i < nextTiles.cnt; i++)
|
||||||
nextTiles.tiles[i].isActive = false;
|
nextTiles.tiles[i].isActive = false;
|
||||||
@ -501,7 +502,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public synchronized void redrawTiles(boolean clear) {
|
public void redrawTiles(boolean clear) {
|
||||||
boolean changedPos = false;
|
boolean changedPos = false;
|
||||||
boolean changedZoom = false;
|
boolean changedZoom = false;
|
||||||
mMapPosition = mMapView.getMapPosition().getMapPosition();
|
mMapPosition = mMapView.getMapPosition().getMapPosition();
|
||||||
@ -513,11 +514,18 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
|
|
||||||
if (clear) {
|
if (clear) {
|
||||||
mInitial = true;
|
mInitial = true;
|
||||||
|
synchronized (this) {
|
||||||
for (GLMapTile t : mTileList) {
|
for (GLMapTile t : mTileList) {
|
||||||
t.isDrawn = false;
|
if (t.lineVBO != null) {
|
||||||
t.isLoading = false;
|
mVBOs.add(t.lineVBO);
|
||||||
t.newData = false;
|
}
|
||||||
|
if (t.polygonVBO != null)
|
||||||
|
mVBOs.add(t.polygonVBO);
|
||||||
|
}
|
||||||
|
mTileList.clear();
|
||||||
|
mTiles.clear();
|
||||||
|
nextTiles.cnt = 0;
|
||||||
|
mBufferMemoryUsage = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -546,6 +554,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
if (changedZoom)
|
if (changedZoom)
|
||||||
updateVisibleList(x, y);
|
updateVisibleList(x, y);
|
||||||
|
|
||||||
|
// pass new position to glThread
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
// do not change position while drawing
|
// do not change position while drawing
|
||||||
mCurX = x;
|
mCurX = x;
|
||||||
@ -862,12 +871,12 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
dy = tile.pixelY - mDrawY * div;
|
dy = tile.pixelY - mDrawY * div;
|
||||||
scale = mDrawScale / div;
|
scale = mDrawScale / div;
|
||||||
}
|
}
|
||||||
|
int size = Tile.TILE_SIZE;
|
||||||
int sx = (int) (dx * scale);
|
int sx = (int) (dx * scale);
|
||||||
int sy = (int) (dy * scale);
|
int sy = (int) (dy * scale);
|
||||||
|
|
||||||
int sw = (int) ((dx + Tile.TILE_SIZE) * scale) - sx;
|
int sw = (int) ((dx + size) * scale) - sx;
|
||||||
int sh = (int) ((dy + Tile.TILE_SIZE) * scale) - sy;
|
int sh = (int) ((dy + size) * scale) - sy;
|
||||||
|
|
||||||
sx = (mWidth >> 1) + sx;
|
sx = (mWidth >> 1) + sx;
|
||||||
sy = (mHeight >> 1) - (sy + sh);
|
sy = (mHeight >> 1) - (sy + sh);
|
||||||
@ -904,101 +913,6 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawProxyLines(GLMapTile tile) {
|
|
||||||
if (tile.parent != null && tile.parent.isDrawn) {
|
|
||||||
tile.parent.sx = tile.sx;
|
|
||||||
tile.parent.sy = tile.sy;
|
|
||||||
tile.parent.sw = tile.sw;
|
|
||||||
tile.parent.sh = tile.sh;
|
|
||||||
drawLines(tile.parent, -1);
|
|
||||||
} else {
|
|
||||||
int drawn = 0;
|
|
||||||
// scissor coordinates already set for polygons
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
GLMapTile c = tile.child[i];
|
|
||||||
if (c != null && c.isDrawn && c.isVisible) {
|
|
||||||
drawLines(c, 1);
|
|
||||||
drawn++;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if (drawn < 4 && tile.parent != null) {
|
|
||||||
GLMapTile p = tile.parent.parent;
|
|
||||||
if (p != null && p.isDrawn) {
|
|
||||||
p.sx = tile.sx;
|
|
||||||
p.sy = tile.sy;
|
|
||||||
p.sw = tile.sw;
|
|
||||||
p.sh = tile.sh;
|
|
||||||
drawLines(p, -2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawProxyPolygons(GLMapTile tile) {
|
|
||||||
if (tile.parent != null && tile.parent.isDrawn) {
|
|
||||||
tile.parent.sx = tile.sx;
|
|
||||||
tile.parent.sy = tile.sy;
|
|
||||||
tile.parent.sw = tile.sw;
|
|
||||||
tile.parent.sh = tile.sh;
|
|
||||||
drawPolygons(tile.parent, -1);
|
|
||||||
} else {
|
|
||||||
int drawn = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
GLMapTile c = tile.child[i];
|
|
||||||
|
|
||||||
if (c != null && c.isDrawn && setTileScissor(c, 2)) {
|
|
||||||
drawPolygons(c, 1);
|
|
||||||
drawn++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (drawn < 4 && tile.parent != null) {
|
|
||||||
GLMapTile p = tile.parent.parent;
|
|
||||||
if (p != null && p.isDrawn) {
|
|
||||||
p.sx = tile.sx;
|
|
||||||
p.sy = tile.sy;
|
|
||||||
p.sw = tile.sw;
|
|
||||||
p.sh = tile.sh;
|
|
||||||
drawPolygons(p, -2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// private void drawProxyTriangles(GLMapTile tile) {
|
|
||||||
// if (tile.parent != null && tile.parent.isDrawn) {
|
|
||||||
// tile.parent.sx = tile.sx;
|
|
||||||
// tile.parent.sy = tile.sy;
|
|
||||||
// tile.parent.sw = tile.sw;
|
|
||||||
// tile.parent.sh = tile.sh;
|
|
||||||
// drawTriangles(tile.parent, -1);
|
|
||||||
// } else {
|
|
||||||
// int drawn = 0;
|
|
||||||
//
|
|
||||||
// for (int i = 0; i < 4; i++) {
|
|
||||||
// GLMapTile c = tile.child[i];
|
|
||||||
//
|
|
||||||
// if (c != null && c.isDrawn && setTileScissor(c, 2)) {
|
|
||||||
// drawTriangles(c, 1);
|
|
||||||
// drawn++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (drawn < 4 && tile.parent != null) {
|
|
||||||
// GLMapTile p = tile.parent.parent;
|
|
||||||
// if (p != null && p.isDrawn) {
|
|
||||||
// p.sx = tile.sx;
|
|
||||||
// p.sy = tile.sy;
|
|
||||||
// p.sw = tile.sw;
|
|
||||||
// p.sh = tile.sh;
|
|
||||||
// drawTriangles(p, -2);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
private int uploadCnt = 0;
|
private int uploadCnt = 0;
|
||||||
|
|
||||||
private boolean uploadTileData(GLMapTile tile) {
|
private boolean uploadTileData(GLMapTile tile) {
|
||||||
@ -1420,6 +1334,101 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
|
|||||||
glClearStencil(0);
|
glClearStencil(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void drawProxyLines(GLMapTile tile) {
|
||||||
|
if (tile.parent != null && tile.parent.isDrawn) {
|
||||||
|
tile.parent.sx = tile.sx;
|
||||||
|
tile.parent.sy = tile.sy;
|
||||||
|
tile.parent.sw = tile.sw;
|
||||||
|
tile.parent.sh = tile.sh;
|
||||||
|
drawLines(tile.parent, -1);
|
||||||
|
} else {
|
||||||
|
int drawn = 0;
|
||||||
|
// scissor coordinates already set for polygons
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
GLMapTile c = tile.child[i];
|
||||||
|
if (c != null && c.isDrawn && c.isVisible) {
|
||||||
|
drawLines(c, 1);
|
||||||
|
drawn++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (drawn < 4 && tile.parent != null) {
|
||||||
|
GLMapTile p = tile.parent.parent;
|
||||||
|
if (p != null && p.isDrawn) {
|
||||||
|
p.sx = tile.sx;
|
||||||
|
p.sy = tile.sy;
|
||||||
|
p.sw = tile.sw;
|
||||||
|
p.sh = tile.sh;
|
||||||
|
drawLines(p, -2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawProxyPolygons(GLMapTile tile) {
|
||||||
|
if (tile.parent != null && tile.parent.isDrawn) {
|
||||||
|
tile.parent.sx = tile.sx;
|
||||||
|
tile.parent.sy = tile.sy;
|
||||||
|
tile.parent.sw = tile.sw;
|
||||||
|
tile.parent.sh = tile.sh;
|
||||||
|
drawPolygons(tile.parent, -1);
|
||||||
|
} else {
|
||||||
|
int drawn = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
GLMapTile c = tile.child[i];
|
||||||
|
|
||||||
|
if (c != null && c.isDrawn && setTileScissor(c, 2)) {
|
||||||
|
drawPolygons(c, 1);
|
||||||
|
drawn++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (drawn < 4 && tile.parent != null) {
|
||||||
|
GLMapTile p = tile.parent.parent;
|
||||||
|
if (p != null && p.isDrawn) {
|
||||||
|
p.sx = tile.sx;
|
||||||
|
p.sy = tile.sy;
|
||||||
|
p.sw = tile.sw;
|
||||||
|
p.sh = tile.sh;
|
||||||
|
drawPolygons(p, -2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// private void drawProxyTriangles(GLMapTile tile) {
|
||||||
|
// if (tile.parent != null && tile.parent.isDrawn) {
|
||||||
|
// tile.parent.sx = tile.sx;
|
||||||
|
// tile.parent.sy = tile.sy;
|
||||||
|
// tile.parent.sw = tile.sw;
|
||||||
|
// tile.parent.sh = tile.sh;
|
||||||
|
// drawTriangles(tile.parent, -1);
|
||||||
|
// } else {
|
||||||
|
// int drawn = 0;
|
||||||
|
//
|
||||||
|
// for (int i = 0; i < 4; i++) {
|
||||||
|
// GLMapTile c = tile.child[i];
|
||||||
|
//
|
||||||
|
// if (c != null && c.isDrawn && setTileScissor(c, 2)) {
|
||||||
|
// drawTriangles(c, 1);
|
||||||
|
// drawn++;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (drawn < 4 && tile.parent != null) {
|
||||||
|
// GLMapTile p = tile.parent.parent;
|
||||||
|
// if (p != null && p.isDrawn) {
|
||||||
|
// p.sx = tile.sx;
|
||||||
|
// p.sy = tile.sy;
|
||||||
|
// p.sw = tile.sw;
|
||||||
|
// p.sh = tile.sh;
|
||||||
|
// drawTriangles(p, -2);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean processedTile() {
|
public boolean processedTile() {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user