Esempio n. 1
0
  /** 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;
  }
Esempio n. 2
0
  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);
  }
Esempio n. 3
0
  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);
    }
  }
Esempio n. 4
0
  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;
  }
Esempio n. 5
0
  /** Set new ExtrusionLayers and clear previous. */
  public void setExtrusionLayers(ExtrusionLayer el) {
    for (RenderElement l = extrusionLayers; l != null; l = l.next) l.clear();

    extrusionLayers = el;
  }
Esempio n. 6
0
  /** Set new TextureLayers and clear previous. */
  public void setTextureLayers(TextureLayer tl) {
    for (RenderElement l = textureLayers; l != null; l = l.next) l.clear();

    textureLayers = tl;
  }
Esempio n. 7
0
  /** 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;
  }