summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/ui/RawTexture.java
blob: aecea9d9e8e1b03c7192d0fb20bfca98799eb06f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package com.android.camera.ui;

import android.graphics.Bitmap;

import javax.microedition.khronos.opengles.GL11;

public class RawTexture extends Texture {

    private RawTexture(GL11 gl, int id) {
        super(gl, id, STATE_LOADED);
    }

    public GL11 getBoundGL() {
        return mGL;
    }

    public static RawTexture newInstance(GL11 gl) {
        int[] textureId = new int[1];
        gl.glGenTextures(1, textureId, 0);
        int glError = gl.glGetError();
        if (glError != GL11.GL_NO_ERROR) {
            throw new RuntimeException("GL_ERROR: " + glError);
        }
        return new RawTexture(gl, textureId[0]);
    }

    @Override
    protected void freeBitmap(Bitmap bitmap) {
        throw new UnsupportedOperationException();
    }

    @Override
    protected Bitmap getBitmap() {
        throw new UnsupportedOperationException();
    }

    @Override
    protected boolean bind(GLRootView glRootView, GL11 gl) {
        if (mGL == gl) {
            gl.glBindTexture(GL11.GL_TEXTURE_2D, getId());
            return true;
        }
        return false;
    }
}