grow ExtrusionLayer compiler buffer if necessary
This commit is contained in:
parent
e05921efdd
commit
65e4845fef
@ -37,7 +37,6 @@ import android.util.Log;
|
|||||||
public class ExtrusionLayer extends Layer {
|
public class ExtrusionLayer extends Layer {
|
||||||
private final static String TAG = ExtrusionLayer.class.getName();
|
private final static String TAG = ExtrusionLayer.class.getName();
|
||||||
private static final float S = GLRenderer.COORD_SCALE;
|
private static final float S = GLRenderer.COORD_SCALE;
|
||||||
private int mNumVertices = 0;
|
|
||||||
private final VertexPoolItem mVertices;
|
private final VertexPoolItem mVertices;
|
||||||
private VertexPoolItem mCurVertices;
|
private VertexPoolItem mCurVertices;
|
||||||
private final VertexPoolItem mIndices[], mCurIndices[];
|
private final VertexPoolItem mIndices[], mCurIndices[];
|
||||||
@ -47,6 +46,7 @@ public class ExtrusionLayer extends Layer {
|
|||||||
// 0. even sides, 1. odd sides, 2. roof, 3. roof outline
|
// 0. even sides, 1. odd sides, 2. roof, 3. roof outline
|
||||||
public int mIndiceCnt[] = { 0, 0, 0, 0 };
|
public int mIndiceCnt[] = { 0, 0, 0, 0 };
|
||||||
public int mNumIndices = 0;
|
public int mNumIndices = 0;
|
||||||
|
public int mNumVertices = 0;
|
||||||
|
|
||||||
public int mIndicesBufferID;
|
public int mIndicesBufferID;
|
||||||
public int mVertexBufferID;
|
public int mVertexBufferID;
|
||||||
@ -341,7 +341,6 @@ public class ExtrusionLayer extends Layer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mCurVertices.used = v;
|
mCurVertices.used = v;
|
||||||
|
|
||||||
mNumVertices += vertexCnt;
|
mNumVertices += vertexCnt;
|
||||||
return convex;
|
return convex;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,7 +55,7 @@ public class ExtrusionOverlay extends RenderOverlay {
|
|||||||
private boolean initialized = false;
|
private boolean initialized = false;
|
||||||
|
|
||||||
// FIXME sum up size used while filling layer only up to:
|
// FIXME sum up size used while filling layer only up to:
|
||||||
private final int BUFFERSIZE = 65536 * 2;
|
public int mBufferSize = 65536;
|
||||||
private TileSet mTileSet;
|
private TileSet mTileSet;
|
||||||
private ShortBuffer mShortBuffer;
|
private ShortBuffer mShortBuffer;
|
||||||
private MapTile[] mTiles;
|
private MapTile[] mTiles;
|
||||||
@ -86,7 +86,7 @@ public class ExtrusionOverlay extends RenderOverlay {
|
|||||||
hLightPosition[i] = GLES20.glGetAttribLocation(shaderProgram[i], "a_light");
|
hLightPosition[i] = GLES20.glGetAttribLocation(shaderProgram[i], "a_light");
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteBuffer buf = ByteBuffer.allocateDirect(BUFFERSIZE)
|
ByteBuffer buf = ByteBuffer.allocateDirect(mBufferSize)
|
||||||
.order(ByteOrder.nativeOrder());
|
.order(ByteOrder.nativeOrder());
|
||||||
|
|
||||||
mShortBuffer = buf.asShortBuffer();
|
mShortBuffer = buf.asShortBuffer();
|
||||||
@ -116,6 +116,15 @@ public class ExtrusionOverlay extends RenderOverlay {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!el.compiled) {
|
if (!el.compiled) {
|
||||||
|
int verticesBytes = el.mNumVertices * 8 * 2;
|
||||||
|
if (verticesBytes > mBufferSize) {
|
||||||
|
mBufferSize = verticesBytes;
|
||||||
|
Log.d(TAG, "realloc extrusion buffer " + verticesBytes);
|
||||||
|
ByteBuffer buf = ByteBuffer.allocateDirect(verticesBytes)
|
||||||
|
.order(ByteOrder.nativeOrder());
|
||||||
|
|
||||||
|
mShortBuffer = buf.asShortBuffer();
|
||||||
|
}
|
||||||
el.compile(mShortBuffer);
|
el.compile(mShortBuffer);
|
||||||
GlUtils.checkGlError("...");
|
GlUtils.checkGlError("...");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user