heifwriter/src/main/java/androidx/heifwriter/EglWindowSurface.java
private void eglSetup() {
        mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
        if (Objects.equals(mEGLDisplay, EGL14.EGL_NO_DISPLAY)) {
            throw new RuntimeException("unable to get EGL14 display");
        }
        int[] version = new int[2];
        if (!EGL14.eglInitialize(mEGLDisplay, version, 0, version, 1)) {
            mEGLDisplay = null;
            throw new RuntimeException("unable to initialize EGL14");
        }

        // Configure EGL for recordable and OpenGL ES 2.0.  We want enough RGB bits
        // to minimize artifacts from possible YUV conversion.
        int[] attribList = {
                EGL14.EGL_RED_SIZE, 8,
                EGL14.EGL_GREEN_SIZE, 8,
                EGL14.EGL_BLUE_SIZE, 8,
                EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
                EGLExt.EGL_RECORDABLE_ANDROID, 1,
                EGL14.EGL_NONE
        };
        int[] numConfigs = new int[1];
        if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, mConfigs, 0, mConfigs.length,
                numConfigs, 0)) {
            throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config");
        }

        // Configure context for OpenGL ES 2.0.
        int[] attrib_list = {
                EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
                EGL14.EGL_NONE
        };
        mEGLContext = EGL14.eglCreateContext(mEGLDisplay, mConfigs[0], EGL14.EGL_NO_CONTEXT,
                attrib_list, 0);
        checkEglError("eglCreateContext");
        if (mEGLContext == null) {
            throw new RuntimeException("null context");
        }

        // Create a window surface, and attach it to the Surface we received.
        createEGLSurface();

        mWidth = getWidth();
        mHeight = getHeight();
    }
/**
     * Prepares EGL. We want a GLES 2.0 context and a surface that supports recording.
     */
Prepares EGL. We want a GLES 2.0 context and a surface that supports recording.
Prepares EGL . We want a GLES 2 . 0 context and a surface that supports recording .
private void eglSetup() {
        mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
        if (Objects.equals(mEGLDisplay, EGL14.EGL_NO_DISPLAY)) {
            throw new RuntimeException("unable to get EGL14 display");
        }
        int[] version = new int[2];
        if (!EGL14.eglInitialize(mEGLDisplay, version, 0, version, 1)) {
            mEGLDisplay = null;
            throw new RuntimeException("unable to initialize EGL14");
        }
        int[] attribList = {
                EGL14.EGL_RED_SIZE, 8,
                EGL14.EGL_GREEN_SIZE, 8,
                EGL14.EGL_BLUE_SIZE, 8,
                EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
                EGLExt.EGL_RECORDABLE_ANDROID, 1,
                EGL14.EGL_NONE
        };
        int[] numConfigs = new int[1];
        if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, mConfigs, 0, mConfigs.length,
                numConfigs, 0)) {
            throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config");
        }
        int[] attrib_list = {
                EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
                EGL14.EGL_NONE
        };
        mEGLContext = EGL14.eglCreateContext(mEGLDisplay, mConfigs[0], EGL14.EGL_NO_CONTEXT,
                attrib_list, 0);
        checkEglError("eglCreateContext");
        if (mEGLContext == null) {
            throw new RuntimeException("null context");
        }
        createEGLSurface();
        mWidth = getWidth();
        mHeight = getHeight();
    }
private void eglSetup ( ) { mEGLDisplay = EGL14 . eglGetDisplay ( EGL14 . EGL_DEFAULT_DISPLAY ) ; if ( Objects . equals ( mEGLDisplay , EGL14 . EGL_NO_DISPLAY ) ) { throw new RuntimeException ( "unable to get EGL14 display" ) ; } int [ ] version = new int [ 2 ] ; if ( ! EGL14 . eglInitialize ( mEGLDisplay , version , 0 , version , 1 ) ) { mEGLDisplay = null ; throw new RuntimeException ( "unable to initialize EGL14" ) ; } int [ ] attribList = { EGL14 . EGL_RED_SIZE , 8 , EGL14 . EGL_GREEN_SIZE , 8 , EGL14 . EGL_BLUE_SIZE , 8 , EGL14 . EGL_RENDERABLE_TYPE , EGL14 . EGL_OPENGL_ES2_BIT , EGLExt . EGL_RECORDABLE_ANDROID , 1 , EGL14 . EGL_NONE } ; int [ ] numConfigs = new int [ 1 ] ; if ( ! EGL14 . eglChooseConfig ( mEGLDisplay , attribList , 0 , mConfigs , 0 , mConfigs . length , numConfigs , 0 ) ) { throw new RuntimeException ( "unable to find RGB888+recordable ES2 EGL config" ) ; } int [ ] attrib_list = { EGL14 . EGL_CONTEXT_CLIENT_VERSION , 2 , EGL14 . EGL_NONE } ; mEGLContext = EGL14 . eglCreateContext ( mEGLDisplay , mConfigs [ 0 ] , EGL14 . EGL_NO_CONTEXT , attrib_list , 0 ) ; checkEglError ( "eglCreateContext" ) ; if ( mEGLContext == null ) { throw new RuntimeException ( "null context" ) ; } createEGLSurface ( ) ; mWidth = getWidth ( ) ; mHeight = getHeight ( ) ; }
Prepares EGL.
Prepares EGL .
// Configure EGL for recordable and OpenGL ES 2.0.  We want enough RGB bits // to minimize artifacts from possible YUV conversion. // Configure context for OpenGL ES 2.0. // Create a window surface, and attach it to the Surface we received.