use vertexMapPool in ExtrusionLayer

This commit is contained in:
Hannes Janetzek 2014-03-23 02:42:11 +01:00
parent 2a58f43256
commit 37639f965c

View File

@ -68,7 +68,7 @@ public class ExtrusionLayer extends RenderElement {
public boolean compiled = false;
private final float mGroundResolution;
private KeyMap<Vertex> mVertexMap = new KeyMap<Vertex>();
private KeyMap<Vertex> mVertexMap;
public int indexOffset;
@ -116,6 +116,7 @@ public class ExtrusionLayer extends RenderElement {
mCurIndices = new VertexItem[5];
mIndices[4] = mCurIndices[4] = VertexItem.pool.get();
mVertexMap = vertexMapPool.get();
}
static SyncPool<Vertex> vertexPool = new SyncPool<Vertex>(8192, false) {
@ -125,6 +126,13 @@ public class ExtrusionLayer extends RenderElement {
}
};
static SyncPool<KeyMap<Vertex>> vertexMapPool = new SyncPool<KeyMap<Vertex>>(64, false) {
@Override
protected KeyMap<Vertex> createItem() {
return new KeyMap<Vertex>(2048);
}
};
static class Vertex extends HashItem {
short x, y, z, n;
int id;
@ -644,14 +652,17 @@ public class ExtrusionLayer extends RenderElement {
@Override
public void compile(ShortBuffer vertexBuffer, ShortBuffer indexBuffer) {
mClipper = null;
if (compiled) {
throw new IllegalStateException();
}
if (mVertexMap != null) {
vertexPool.releaseAll(mVertexMap.releaseItems());
mVertexMap = vertexMapPool.release(mVertexMap);
mVertexMap = null;
mClipper = null;
}
if (sumVertices == 0) {
compiled = true;
@ -680,7 +691,14 @@ public class ExtrusionLayer extends RenderElement {
@Override
protected void clear() {
mClipper = null;
if (mVertexMap != null) {
vertexPool.releaseAll(mVertexMap.releaseItems());
mVertexMap = vertexMapPool.release(mVertexMap);
mVertexMap = null;
}
if (compiled) {
vboIndices = BufferObject.release(vboIndices);
vboVertices = BufferObject.release(vboVertices);