// Path: src/com/af/experiments/FxCameraApp/Utils/LogWriter.java
// public final class LogWriter extends Writer {
// 
//     private final StringBuilder mBuilder = new StringBuilder();
//     private final String mTag;
// 
//     public LogWriter(final String tag) {
//         mTag = tag;
//     }
// 
//     @Override
//     public void close() {
//         flushBuilder();
//     }
// 
//     @Override
//     public void flush() {
//         flushBuilder();
//     }
// 
//     @Override
//     public void write(final char[] buf, final int offset, final int count) {
//         for(int i = 0; i < count; i++) {
//             final char c = buf[offset + i];
//             if (c == '\n') {
//                 flushBuilder();
//             } else {
//                 mBuilder.append(c);
//             }
//         }
//     }
// 
//     private void flushBuilder() {
//         if (mBuilder.length() > 0) {
//             Log.v(mTag, mBuilder.toString());
//             mBuilder.delete(0, mBuilder.length());
//         }
//     }
// 
// }


import android.app.ActivityManager;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.opengl.GLDebugHelper;
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.view.TextureView;
import com.af.experiments.FxCameraApp.Utils.LogWriter;
import javax.microedition.khronos.egl.*;
import javax.microedition.khronos.opengles.GL;
import javax.microedition.khronos.opengles.GL10;
import java.io.Writer;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import static android.opengl.GLSurfaceView.DEBUG_CHECK_GL_ERROR;
import static android.opengl.GLSurfaceView.DEBUG_LOG_GL_CALLS;
import static android.opengl.GLSurfaceView.RENDERMODE_CONTINUOUSLY;
import static android.opengl.GLSurfaceView.RENDERMODE_WHEN_DIRTY;
import static javax.microedition.khronos.egl.EGL10.*;
import static javax.microedition.khronos.egl.EGL11.EGL_CONTEXT_LOST;
				 * Could not make the context current, probably because the underlying
				 * SurfaceView surface has been destroyed.
				 */
                logEglErrorAsWarning("EGLHelper", "eglMakeCurrent", mEgl.eglGetError());
                return false;
            }

            return true;
        }

        /**
         * Create a GL object for the current EGL context.
         * @return
         */
        GL createGL() {

            GL gl = mEglContext.getGL();
            final GlTextureView view = mGLSurfaceViewWeakRef.get();
            if (view != null) {
                if (view.mGLWrapper != null) {
                    gl = view.mGLWrapper.wrap(gl);
                }

                if ((view.mDebugFlags & (DEBUG_CHECK_GL_ERROR | DEBUG_LOG_GL_CALLS)) != 0) {
                    int configFlags = 0;
                    Writer log = null;
                    if ((view.mDebugFlags & DEBUG_CHECK_GL_ERROR) != 0) {
                        configFlags |= GLDebugHelper.CONFIG_CHECK_GL_ERROR;
                    }
                    if ((view.mDebugFlags & DEBUG_LOG_GL_CALLS) != 0) {
// Path: src/com/af/experiments/FxCameraApp/Utils/LogWriter.java
// public final class LogWriter extends Writer {
// 
//     private final StringBuilder mBuilder = new StringBuilder();
//     private final String mTag;
// 
//     public LogWriter(final String tag) {
//         mTag = tag;
//     }
// 
//     @Override
//     public void close() {
//         flushBuilder();
//     }
// 
//     @Override
//     public void flush() {
//         flushBuilder();
//     }
// 
//     @Override
//     public void write(final char[] buf, final int offset, final int count) {
//         for(int i = 0; i < count; i++) {
//             final char c = buf[offset + i];
//             if (c == '\n') {
//                 flushBuilder();
//             } else {
//                 mBuilder.append(c);
//             }
//         }
//     }
// 
//     private void flushBuilder() {
//         if (mBuilder.length() > 0) {
//             Log.v(mTag, mBuilder.toString());
//             mBuilder.delete(0, mBuilder.length());
//         }
//     }
// 
// }


// Path: src/com/af/experiments/FxCameraApp/ogles/GlTextureView.java
import android.app.ActivityManager;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.opengl.GLDebugHelper;
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.view.TextureView;
import com.af.experiments.FxCameraApp.Utils.LogWriter;
import javax.microedition.khronos.egl.*;
import javax.microedition.khronos.opengles.GL;
import javax.microedition.khronos.opengles.GL10;
import java.io.Writer;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import static android.opengl.GLSurfaceView.DEBUG_CHECK_GL_ERROR;
import static android.opengl.GLSurfaceView.DEBUG_LOG_GL_CALLS;
import static android.opengl.GLSurfaceView.RENDERMODE_CONTINUOUSLY;
import static android.opengl.GLSurfaceView.RENDERMODE_WHEN_DIRTY;
import static javax.microedition.khronos.egl.EGL10.*;
import static javax.microedition.khronos.egl.EGL11.EGL_CONTEXT_LOST;

				 * Could not make the context current, probably because the underlying
				 * SurfaceView surface has been destroyed.
				 */
                logEglErrorAsWarning("EGLHelper", "eglMakeCurrent", mEgl.eglGetError());
                return false;
            }

            return true;
        }

        /**
         * Create a GL object for the current EGL context.
         * @return
         */
        GL createGL() {

            GL gl = mEglContext.getGL();
            final GlTextureView view = mGLSurfaceViewWeakRef.get();
            if (view != null) {
                if (view.mGLWrapper != null) {
                    gl = view.mGLWrapper.wrap(gl);
                }

                if ((view.mDebugFlags & (DEBUG_CHECK_GL_ERROR | DEBUG_LOG_GL_CALLS)) != 0) {
                    int configFlags = 0;
                    Writer log = null;
                    if ((view.mDebugFlags & DEBUG_CHECK_GL_ERROR) != 0) {
                        configFlags |= GLDebugHelper.CONFIG_CHECK_GL_ERROR;
                    }
                    if ((view.mDebugFlags & DEBUG_LOG_GL_CALLS) != 0) {
                        log = new LogWriter(GlTextureView.TAG);