sync on ExtrusionLayer.vertexPool instead of each Vertex
This commit is contained in:
parent
037c25153b
commit
a26aa9de15
@ -30,7 +30,7 @@ import org.oscim.utils.KeyMap.HashItem;
|
||||
import org.oscim.utils.Tessellator;
|
||||
import org.oscim.utils.geom.LineClipper;
|
||||
import org.oscim.utils.pool.Inlist;
|
||||
import org.oscim.utils.pool.SyncPool;
|
||||
import org.oscim.utils.pool.Pool;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -111,17 +111,19 @@ public class ExtrusionLayer extends RenderElement {
|
||||
mCurIndices = new VertexItem[5];
|
||||
|
||||
mIndices[4] = mCurIndices[4] = VertexItem.pool.get();
|
||||
synchronized (vertexPool) {
|
||||
mVertexMap = vertexMapPool.get();
|
||||
}
|
||||
}
|
||||
|
||||
static SyncPool<Vertex> vertexPool = new SyncPool<Vertex>(8192, false) {
|
||||
static Pool<Vertex> vertexPool = new Pool<Vertex>() {
|
||||
@Override
|
||||
protected Vertex createItem() {
|
||||
return new Vertex();
|
||||
}
|
||||
};
|
||||
|
||||
static SyncPool<KeyMap<Vertex>> vertexMapPool = new SyncPool<KeyMap<Vertex>>(64, false) {
|
||||
static Pool<KeyMap<Vertex>> vertexMapPool = new Pool<KeyMap<Vertex>>() {
|
||||
@Override
|
||||
protected KeyMap<Vertex> createItem() {
|
||||
return new KeyMap<Vertex>(2048);
|
||||
@ -160,6 +162,7 @@ public class ExtrusionLayer extends RenderElement {
|
||||
float[] points = element.points;
|
||||
|
||||
int vertexCnt = sumVertices;
|
||||
synchronized (vertexPool) {
|
||||
|
||||
Vertex key = vertexPool.get();
|
||||
double scale = S * Tile.SIZE / 4096;
|
||||
@ -267,7 +270,7 @@ public class ExtrusionLayer extends RenderElement {
|
||||
}
|
||||
|
||||
vertexPool.release(key);
|
||||
|
||||
}
|
||||
sumVertices = vertexCnt;
|
||||
}
|
||||
|
||||
@ -649,11 +652,7 @@ public class ExtrusionLayer extends RenderElement {
|
||||
public void compile(ShortBuffer vertexBuffer, ShortBuffer indexBuffer) {
|
||||
mClipper = null;
|
||||
|
||||
if (mVertexMap != null) {
|
||||
vertexPool.releaseAll(mVertexMap.releaseItems());
|
||||
mVertexMap = vertexMapPool.release(mVertexMap);
|
||||
mVertexMap = null;
|
||||
}
|
||||
releaseVertexPool();
|
||||
|
||||
if (sumVertices == 0) {
|
||||
return;
|
||||
@ -682,18 +681,23 @@ public class ExtrusionLayer extends RenderElement {
|
||||
protected void clear() {
|
||||
mClipper = null;
|
||||
|
||||
if (mVertexMap != null) {
|
||||
vertexPool.releaseAll(mVertexMap.releaseItems());
|
||||
mVertexMap = vertexMapPool.release(mVertexMap);
|
||||
mVertexMap = null;
|
||||
}
|
||||
|
||||
if (mIndices != null) {
|
||||
for (int i = 0; i <= IND_MESH; i++)
|
||||
mIndices[i] = VertexItem.pool.releaseAll(mIndices[i]);
|
||||
mIndices = null;
|
||||
mVertices = VertexItem.pool.releaseAll(mVertices);
|
||||
}
|
||||
releaseVertexPool();
|
||||
}
|
||||
|
||||
void releaseVertexPool() {
|
||||
if (mVertexMap == null)
|
||||
return;
|
||||
|
||||
synchronized (vertexPool) {
|
||||
vertexPool.releaseAll(mVertexMap.releaseItems());
|
||||
mVertexMap = vertexMapPool.release(mVertexMap);
|
||||
}
|
||||
}
|
||||
|
||||
public ExtrusionLayer next() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user