Exemplo n.º 1
0
  static void init(int num) {
    pool = null;

    TextureObject to;

    int[] textureIds = new int[num];
    GLES20.glGenTextures(num, textureIds, 0);

    for (int i = 1; i < num; i++) {
      initTexture(textureIds[i]);
      to = new TextureObject(textureIds[i]);

      to.next = pool;
      pool = to;
    }

    mBitmaps = new ArrayList<Bitmap>(10);

    for (int i = 0; i < 4; i++) {
      Bitmap bitmap = Bitmap.createBitmap(TEXTURE_WIDTH, TEXTURE_HEIGHT, Bitmap.Config.ARGB_8888);

      mBitmaps.add(bitmap);
    }

    mBitmapFormat = GLUtils.getInternalFormat(mBitmaps.get(0));
    mBitmapType = GLUtils.getType(mBitmaps.get(0));
  }
Exemplo n.º 2
0
  public static synchronized void release(TextureObject to) {
    while (to != null) {
      if (TextureRenderer.debug) Log.d("...", "release texture " + to.id);

      TextureObject next = to.next;

      if (to.bitmap != null) {
        mBitmaps.add(to.bitmap);
        to.bitmap = null;
      }

      to.next = pool;
      pool = to;

      to = next;
    }
  }
Exemplo n.º 3
0
  public static synchronized TextureObject get() {
    TextureObject to;

    if (pool == null) {
      objectCount += 1;
      if (TextureRenderer.debug) Log.d("...", "textures: " + objectCount);
      pool = new TextureObject(-1);
    }

    to = pool;
    pool = pool.next;

    to.next = null;

    to.bitmap = getBitmap();
    to.bitmap.eraseColor(Color.TRANSPARENT);

    if (TextureRenderer.debug) Log.d("...", "get texture " + to.id + " " + to.bitmap);

    return to;
  }