fix: one more missing sync

This commit is contained in:
Hannes Janetzek 2014-10-03 07:06:32 +02:00
parent 8f6f1bf238
commit 1a4ec3f7ad

View File

@ -130,12 +130,14 @@ public abstract class TileRenderer extends LayerRenderer {
} }
public void clearTiles() { public void clearTiles() {
synchronized (tilelock) {
/* Clear all references to MapTiles as all current /* Clear all references to MapTiles as all current
* tiles will also be removed from TileManager. */ * tiles will also be removed from TileManager. */
mDrawTiles.releaseTiles(); mDrawTiles.releaseTiles();
mDrawTiles.tiles = new MapTile[1]; mDrawTiles.tiles = new MapTile[1];
mDrawTiles.cnt = 0; mDrawTiles.cnt = 0;
} }
}
/** compile tile layer data and upload to VBOs */ /** compile tile layer data and upload to VBOs */
private static int compileTileLayers(MapTile[] tiles, int tileCnt) { private static int compileTileLayers(MapTile[] tiles, int tileCnt) {
@ -222,9 +224,6 @@ public abstract class TileRenderer extends LayerRenderer {
MapTile[] newTiles = mDrawTiles.tiles; MapTile[] newTiles = mDrawTiles.tiles;
int cnt = mDrawTiles.cnt; int cnt = mDrawTiles.cnt;
/* unlock previous tiles */
tileSet.releaseTiles();
/* ensure same size */ /* ensure same size */
if (tileSet.tiles.length != newTiles.length) { if (tileSet.tiles.length != newTiles.length) {
tileSet.tiles = new MapTile[newTiles.length]; tileSet.tiles = new MapTile[newTiles.length];
@ -234,10 +233,17 @@ public abstract class TileRenderer extends LayerRenderer {
tileSet.cnt = 0; tileSet.cnt = 0;
for (int i = 0; i < cnt; i++) { for (int i = 0; i < cnt; i++) {
MapTile t = newTiles[i]; MapTile t = newTiles[i];
if (t.isVisible && t.state(READY)) { if (t.isVisible && t.state(READY))
t.lock(); t.lock();
tileSet.tiles[tileSet.cnt++] = t;
} }
/* unlock previous tiles */
tileSet.releaseTiles();
for (int i = 0; i < cnt; i++) {
MapTile t = newTiles[i];
if (t.isVisible && t.state(READY))
tileSet.tiles[tileSet.cnt++] = t;
} }
tileSet.serial = mUploadSerial; tileSet.serial = mUploadSerial;