package com.unity3d.player;

import android.content.Context;
import android.opengl.GLSurfaceView;
import android.util.Log;
import android.view.MotionEvent;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;

/* loaded from: /storage/emulated/0/Documents/jadec/sources/com.UBI.A90.WW/dex-files/2.dex */
class w extends GLSurfaceView implements UnityGL {
    private static boolean a = false;
    private static boolean b;
    private v c;
    private boolean d;

    /* loaded from: /storage/emulated/0/Documents/jadec/sources/com.UBI.A90.WW/dex-files/2.dex */
    static class a implements GLSurfaceView.EGLContextFactory {
        private a() {
        }

        /* synthetic */ a(byte b) {
            this();
        }

        @Override // android.opengl.GLSurfaceView.EGLContextFactory
        public final EGLContext createContext(EGL10 egl10, EGLDisplay eGLDisplay, EGLConfig eGLConfig) {
            w.b("Creating OpenGL ES " + (w.b ? "2.0" : "1.x") + " context (" + new u(egl10, eGLDisplay, eGLConfig).a() + ")");
            w.b("Before eglCreateContext", egl10);
            int[] iArr = new int[3];
            iArr[0] = 12440;
            iArr[1] = w.b ? 2 : 1;
            iArr[2] = 12344;
            EGLContext eglCreateContext = egl10.eglCreateContext(eGLDisplay, eGLConfig, EGL10.EGL_NO_CONTEXT, iArr);
            w.b("After eglCreateContext", egl10);
            return eglCreateContext;
        }

        @Override // android.opengl.GLSurfaceView.EGLContextFactory
        public final void destroyContext(EGL10 egl10, EGLDisplay eGLDisplay, EGLContext eGLContext) {
            egl10.eglDestroyContext(eGLDisplay, eGLContext);
        }
    }

    public w(Context context, int i, boolean z, boolean z2, boolean z3, int i2, int i3, int i4) {
        super(context);
        this.c = null;
        this.d = false;
        a = z2;
        b = i == 2;
        this.d = z;
        setEGLContextFactory(new a((byte) 0));
        this.c = new v(z3, i2, 0, i4, i);
        setEGLConfigChooser(this.c.a);
        b();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static void b(String str) {
        if (a) {
            return;
        }
        Log.d("Unity", str);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static void b(String str, EGL10 egl10) {
        for (int i = 0; i < 2; i++) {
            int eglGetError = egl10.eglGetError();
            if (eglGetError == 12288) {
                return;
            }
            Log.e("Unity", String.format("%s: EGL error: 0x%x", str, Integer.valueOf(eglGetError)));
        }
    }

    @Override // com.unity3d.player.UnityGL
    public final void a() {
        super.onDetachedFromWindow();
    }

    public final boolean a(boolean z, int i) {
        return this.c.a(z) | false | this.c.a(i);
    }

    public final void b() {
        int i = this.d ? -3 : -1;
        if (this.c.a()) {
            i = this.d ? 1 : 2;
        }
        getHolder().setFormat(i);
    }

    @Override // android.opengl.GLSurfaceView, android.view.SurfaceView, android.view.View
    protected void onDetachedFromWindow() {
        b("onDetachedFromWindow");
    }

    @Override // android.view.View
    public boolean onGenericMotionEvent(MotionEvent motionEvent) {
        return false;
    }
}
