tiles are already locked when in use by GLRenderer
This commit is contained in:
parent
53e6b6537f
commit
6466a65545
@ -512,33 +512,32 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
|||||||
return ((t.tileX % 4) + (t.tileY % 4 * 4) + 1);
|
return ((t.tileX % 4) + (t.tileY % 4 * 4) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get a TileSet of currently visible tiles
|
||||||
public static TileSet getVisibleTiles(TileSet td) {
|
public static TileSet getVisibleTiles(TileSet td) {
|
||||||
if (mDrawTiles == null)
|
if (mDrawTiles == null)
|
||||||
return td;
|
return td;
|
||||||
|
|
||||||
MapTile[] newTiles = mDrawTiles.tiles;
|
|
||||||
int cnt = mDrawTiles.cnt;
|
|
||||||
|
|
||||||
// ensure tiles keep visible state
|
// ensure tiles keep visible state
|
||||||
synchronized (GLRenderer.tilelock) {
|
synchronized (GLRenderer.tilelock) {
|
||||||
|
MapTile[] newTiles = mDrawTiles.tiles;
|
||||||
// lock tiles (and their proxies) to not be removed from cache
|
int cnt = mDrawTiles.cnt;
|
||||||
for (int i = 0; i < cnt; i++)
|
|
||||||
if (newTiles[i].isVisible)
|
|
||||||
newTiles[i].lock();
|
|
||||||
|
|
||||||
if (td == null)
|
if (td == null)
|
||||||
td = new TileSet(newTiles.length);
|
td = new TileSet(newTiles.length);
|
||||||
|
|
||||||
// unlock previously active tiles
|
// unlock previous tiles
|
||||||
for (int i = 0, n = td.cnt; i < n; i++)
|
for (int i = 0; i < td.cnt; i++)
|
||||||
td.tiles[i].unlock();
|
td.tiles[i].unlock();
|
||||||
|
|
||||||
// copy newTiles to nextTiles
|
// lock tiles to not be removed from cache
|
||||||
td.cnt = 0;
|
td.cnt = 0;
|
||||||
for (int i = 0; i < cnt; i++)
|
for (int i = 0; i < cnt; i++) {
|
||||||
if (newTiles[i].isVisible)
|
MapTile t = newTiles[i];
|
||||||
td.tiles[td.cnt++] = newTiles[i];
|
if (t.isVisible) {
|
||||||
|
t.lock();
|
||||||
|
td.tiles[td.cnt++] = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return td;
|
return td;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user