use vertexMapPool in ExtrusionLayer
This commit is contained in:
parent
2a58f43256
commit
37639f965c
@ -68,7 +68,7 @@ public class ExtrusionLayer extends RenderElement {
|
|||||||
public boolean compiled = false;
|
public boolean compiled = false;
|
||||||
private final float mGroundResolution;
|
private final float mGroundResolution;
|
||||||
|
|
||||||
private KeyMap<Vertex> mVertexMap = new KeyMap<Vertex>();
|
private KeyMap<Vertex> mVertexMap;
|
||||||
|
|
||||||
public int indexOffset;
|
public int indexOffset;
|
||||||
|
|
||||||
@ -116,6 +116,7 @@ public class ExtrusionLayer extends RenderElement {
|
|||||||
mCurIndices = new VertexItem[5];
|
mCurIndices = new VertexItem[5];
|
||||||
|
|
||||||
mIndices[4] = mCurIndices[4] = VertexItem.pool.get();
|
mIndices[4] = mCurIndices[4] = VertexItem.pool.get();
|
||||||
|
mVertexMap = vertexMapPool.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
static SyncPool<Vertex> vertexPool = new SyncPool<Vertex>(8192, false) {
|
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 {
|
static class Vertex extends HashItem {
|
||||||
short x, y, z, n;
|
short x, y, z, n;
|
||||||
int id;
|
int id;
|
||||||
@ -644,14 +652,17 @@ public class ExtrusionLayer extends RenderElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void compile(ShortBuffer vertexBuffer, ShortBuffer indexBuffer) {
|
public void compile(ShortBuffer vertexBuffer, ShortBuffer indexBuffer) {
|
||||||
|
mClipper = null;
|
||||||
|
|
||||||
if (compiled) {
|
if (compiled) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
|
|
||||||
vertexPool.releaseAll(mVertexMap.releaseItems());
|
if (mVertexMap != null) {
|
||||||
|
vertexPool.releaseAll(mVertexMap.releaseItems());
|
||||||
mVertexMap = null;
|
mVertexMap = vertexMapPool.release(mVertexMap);
|
||||||
mClipper = null;
|
mVertexMap = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (sumVertices == 0) {
|
if (sumVertices == 0) {
|
||||||
compiled = true;
|
compiled = true;
|
||||||
@ -680,7 +691,14 @@ public class ExtrusionLayer extends RenderElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void clear() {
|
protected void clear() {
|
||||||
mVertexMap = null;
|
mClipper = null;
|
||||||
|
|
||||||
|
if (mVertexMap != null) {
|
||||||
|
vertexPool.releaseAll(mVertexMap.releaseItems());
|
||||||
|
mVertexMap = vertexMapPool.release(mVertexMap);
|
||||||
|
mVertexMap = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (compiled) {
|
if (compiled) {
|
||||||
vboIndices = BufferObject.release(vboIndices);
|
vboIndices = BufferObject.release(vboIndices);
|
||||||
vboVertices = BufferObject.release(vboVertices);
|
vboVertices = BufferObject.release(vboVertices);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user