/** optimization for Line- and PolygonLayer: collect all pool items and add back in one go. */ private static int addLayerItems(ShortBuffer sbuf, RenderElement l, int type, int pos) { VertexItem last = null, items = null; int size = 0; for (; l != null; l = l.next) { if (l.type != type) continue; for (VertexItem it = l.vertexItems; it != null; it = it.next) { if (it.next == null) { size += it.used; sbuf.put(it.vertices, 0, it.used); } else { size += VertexItem.SIZE; sbuf.put(it.vertices, 0, VertexItem.SIZE); } last = it; } if (last == null) continue; l.offset = pos; pos += l.numVertices; last.next = items; items = l.vertexItems; last = null; l.vertexItems = null; } items = VertexItem.pool.releaseAll(items); return size; }
static void addPoolItems(RenderElement l, ShortBuffer sbuf) { /* keep offset of layer data in vbo */ l.offset = sbuf.position() * SHORT_BYTES; for (VertexItem it = l.vertexItems; it != null; it = it.next) { if (it.next == null) sbuf.put(it.vertices, 0, it.used); else sbuf.put(it.vertices, 0, VertexItem.SIZE); } l.vertexItems = VertexItem.pool.releaseAll(l.vertexItems); }
public void compile(ShortBuffer sbuf, boolean addFill) { addLayerItems(sbuf, baseLayers, POLYGON, addFill ? 4 : 0); offset[LINE] = sbuf.position() * SHORT_BYTES; addLayerItems(sbuf, baseLayers, LINE, 0); // offset[TEXLINE] = size * SHORT_BYTES; for (RenderElement l = baseLayers; l != null; l = l.next) { if (l.type == TEXLINE || l.type == MESH) { l.compile(sbuf); } } for (RenderElement l = textureLayers; l != null; l = l.next) { l.compile(sbuf); } }
private RenderElement getLayer(int level, int type) { RenderElement layer = null; if (mCurLayer != null && mCurLayer.level == level) { layer = mCurLayer; if (layer.type != type) { log.error( "BUG wrong layer {} {} on layer {}", Integer.valueOf(layer.type), Integer.valueOf(type), Integer.valueOf(level)); throw new IllegalArgumentException(); } return layer; } RenderElement l = baseLayers; if (l == null || l.level > level) { /* insert new layer at start */ l = null; } else { while (true) { /* found layer */ if (l.level == level) { layer = l; break; } /* insert layer between current and next layer */ if (l.next == null || l.next.level > level) break; l = l.next; } } if (layer == null) { /* add a new RenderElement */ if (type == LINE) layer = new LineLayer(level); else if (type == POLYGON) layer = new PolygonLayer(level); else if (type == TEXLINE) layer = new LineTexLayer(level); else if (type == MESH) layer = new MeshLayer(level); if (layer == null) throw new IllegalArgumentException(); if (l == null) { /** insert at start */ layer.next = baseLayers; baseLayers = layer; } else { layer.next = l.next; l.next = layer; } } /* check if found layer matches requested type */ if (layer.type != type) { log.error( "BUG wrong layer {} {} on layer {}", Integer.valueOf(layer.type), Integer.valueOf(type), Integer.valueOf(level)); throw new IllegalArgumentException(); } mCurLayer = layer; return layer; }
/** Set new ExtrusionLayers and clear previous. */ public void setExtrusionLayers(ExtrusionLayer el) { for (RenderElement l = extrusionLayers; l != null; l = l.next) l.clear(); extrusionLayers = el; }
/** Set new TextureLayers and clear previous. */ public void setTextureLayers(TextureLayer tl) { for (RenderElement l = textureLayers; l != null; l = l.next) l.clear(); textureLayers = tl; }
/** Set new Base-Layers and clear previous. */ public void setBaseLayers(RenderElement layers) { for (RenderElement l = baseLayers; l != null; l = l.next) l.clear(); baseLayers = layers; }