VertexData: docs

- remove superfluous static get()
This commit is contained in:
Hannes Janetzek 2014-08-24 14:46:45 +02:00
parent 123b0aa098
commit a835d44187
2 changed files with 24 additions and 17 deletions

View File

@ -81,7 +81,7 @@ public class ExtrusionLayer extends RenderElement {
mIndices = new VertexData[5];
for (int i = 0; i <= IND_MESH; i++)
mIndices[i] = VertexData.get();
mIndices[i] = new VertexData();
mClipper = new LineClipper(0, 0, Tile.SIZE, Tile.SIZE);
}
@ -104,7 +104,7 @@ public class ExtrusionLayer extends RenderElement {
mGroundResolution = groundResolution;
mIndices = new VertexData[5];
mIndices[4] = VertexData.get();
mIndices[4] = new VertexData();
synchronized (vertexPool) {
mVertexMap = vertexMapPool.get();

View File

@ -25,11 +25,26 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A linked list of array chunks to hold temporary vertex data.
*
* TODO override append() etc to update internal (cur) state.
*/
public class VertexData extends Inlist.List<Chunk> {
static final Logger log = LoggerFactory.getLogger(VertexData.class);
/**
* Size of array chunks. Must be multiple of:
* 4 (LineLayer/PolygonLayer),
* 24 (TexLineLayer - one block, i.e. two segments)
* 24 (TextureLayer)
*/
public static final int SIZE = 360;
/**
* Shared chunk pool size.
*/
private static final int MAX_POOL = 500;
public static class Chunk extends Inlist<Chunk> {
public final short[] vertices = new short[SIZE];
public int used;
@ -78,16 +93,8 @@ public class VertexData extends Inlist.List<Chunk> {
return super.clear();
}
private static final int MAX_POOL = 500;
private final static Pool pool = new Pool();
/* Must be multiple of
* 4 (LineLayer/PolygonLayer),
* 24 (TexLineLayer - one block, i.e. two segments)
* 24 (TextureLayer) */
public static final int SIZE = 360;
public void dispose() {
pool.releaseAll(super.clear());
used = SIZE; /* set SIZE to get new item on add */
@ -184,11 +191,11 @@ public class VertexData extends Inlist.List<Chunk> {
used += 6;
}
public static VertexData get() {
return new VertexData();
}
/** When changing the position releaseChunk to update internal state */
/**
* Direct access to the current chunk of VertexData. Use with care!
*
* When changing the position use releaseChunk to update internal state
*/
public Chunk obtainChunk() {
if (used == SIZE)
getNext();
@ -201,16 +208,16 @@ public class VertexData extends Inlist.List<Chunk> {
used = cur.used;
}
/* Do not use! */
public void seek(int offset) {
used += offset;
cur.used = used;
if (used > SIZE || used < 0)
throw new IllegalStateException("seekkeed: " + offset + ":" + used);
throw new IllegalStateException("seeked too far: " + offset + "/" + used);
}
public boolean empty() {
return cur == null;
}
}