package com.tencent.liteav.renderer;

import com.tencent.liteav.renderer.TXCGLSurfaceViewBase.e;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLDisplay;

abstract class TXCGLSurfaceViewBase$a implements e {
    protected int[] a;
    final /* synthetic */ TXCGLSurfaceViewBase b;

    public abstract EGLConfig a(EGL10 egl10, EGLDisplay eGLDisplay, EGLConfig[] eGLConfigArr);

    public TXCGLSurfaceViewBase$a(TXCGLSurfaceViewBase tXCGLSurfaceViewBase, int[] iArr) {
        this.b = tXCGLSurfaceViewBase;
        this.a = a(iArr);
    }

    public EGLConfig a(EGL10 egl10, EGLDisplay eGLDisplay) {
        int[] iArr = new int[1];
        if (egl10.eglChooseConfig(eGLDisplay, this.a, null, 0, iArr)) {
            int i = iArr[0];
            if (i <= 0) {
                throw new IllegalArgumentException("No configs match configSpec");
            }
            EGLConfig[] eGLConfigArr = new EGLConfig[i];
            if (egl10.eglChooseConfig(eGLDisplay, this.a, eGLConfigArr, i, iArr)) {
                EGLConfig a = a(egl10, eGLDisplay, eGLConfigArr);
                if (a != null) {
                    return a;
                }
                throw new IllegalArgumentException("No config chosen");
            }
            throw new IllegalArgumentException("eglChooseConfig#2 failed");
        }
        throw new IllegalArgumentException("eglChooseConfig failed");
    }

    private int[] a(int[] iArr) {
        if (TXCGLSurfaceViewBase.h(this.b) != 2) {
            return iArr;
        }
        int length = iArr.length;
        int[] iArr2 = new int[(length + 2)];
        System.arraycopy(iArr, 0, iArr2, 0, length - 1);
        iArr2[length - 1] = 12352;
        iArr2[length] = 4;
        iArr2[length + 1] = 12344;
        return iArr2;
    }
}
