Code example for AtomicInteger

Methods: get

0
        return program;
    } 
 
    AtomicInteger mReportedFrameCount = new AtomicInteger();
    AtomicBoolean mCameraEnabled = new AtomicBoolean();
    AtomicInteger mCameraFrameCount = new AtomicInteger();
 
    /** 
     * @param context 
     */ 
    public SurfaceTextureView(Context context) {
        super(context);
        init(); 
    } 
 
    public SurfaceTextureView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(); 
    } 
 
    private void init() { 
        setEGLContextClientVersion(2);
        setRenderer(new Renderer());
    } 
 
    public void setCameraEnabled(boolean enabled) {
        mCameraEnabled.set(enabled);
    } 
 
    public void resetFrameCounter() { 
        mReportedFrameCount.set(0);
    } 
 
    public int getFrameCounter() { 
        return mReportedFrameCount.get();
    } 
 
    class Renderer implements GLSurfaceView.Renderer {
        private final static String VERTEX_SHADER =
            "attribute vec4 vPosition;\n" + 
            "attribute vec2 a_texCoord;\n" + 
            "varying vec2 v_texCoord;\n" + 
            "uniform mat4 u_xform;\n" + 
            "void main() {\n" + 
            "  gl_Position = vPosition;\n" + 
            "  v_texCoord = vec2(u_xform * vec4(a_texCoord, 1.0, 1.0));\n" + 
            "}\n"; 
 
        private final static String FRAGMENT_SHADER =
            "#extension GL_OES_EGL_image_external : require\n" + 
            "precision mediump float;\n" + 
            "uniform samplerExternalOES s_texture;\n" + 
            "varying vec2 v_texCoord;\n" + 
            "void main() {\n" + 
            "  gl_FragColor = texture2D(s_texture, v_texCoord);\n" + 
            "}\n"; 
 
        private final float[] TEXTURE_VERTICES =
            { 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f }; 
 
        private final float[] QUAD_VERTICES =
            { 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f }; 
 
        private final static int FLOAT_SIZE_BYTES = 4;
 
        private final FloatBuffer mTextureVertices;
        private final FloatBuffer mQuadVertices;
 
 
        private int mGLProgram;
        private int mTexHandle;
        private int mTexCoordHandle;
        private int mTriangleVerticesHandle;
        private int mTransformHandle;
        private int mViewWidth;
        private int mViewHeight;
        private float[] mTransformMatrix;
        private int mLastCameraFrameCount;
        public Renderer() { 
            mTextureVertices = ByteBuffer.allocateDirect(TEXTURE_VERTICES.length *
                    FLOAT_SIZE_BYTES).order(ByteOrder.nativeOrder()).asFloatBuffer();
            mTextureVertices.put(TEXTURE_VERTICES).position(0);
            mQuadVertices = ByteBuffer.allocateDirect(QUAD_VERTICES.length *
                    FLOAT_SIZE_BYTES).order(ByteOrder.nativeOrder()).asFloatBuffer();
            mQuadVertices.put(QUAD_VERTICES).position(0);
            mTransformMatrix = new float[16];
            mLastCameraFrameCount = mCameraFrameCount.get();
        } 
 
        @Override 
        public void onSurfaceCreated(GL10 gl, EGLConfig config) {
            mGLProgram = createProgram(VERTEX_SHADER, FRAGMENT_SHADER);