package com.tencent.mm.plugin.appbrand.widget.desktop.dynamicbackground;

import android.util.Log;
import com.tencent.magicbrush.a.c.c;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.appbrand.widget.desktop.dynamicbackground.GameGLSurfaceView.i;
import com.tencent.mm.plugin.appbrand.widget.desktop.dynamicbackground.GameGLSurfaceView.j;

class GameGLSurfaceView$k {
    private static String TAG = "GLThreadManager";

    private GameGLSurfaceView$k() {
    }

    /* synthetic */ GameGLSurfaceView$k(byte b) {
        this();
    }

    public final synchronized void f(j jVar) {
        AppMethodBeat.i(134088);
        c.i("MicroMsg.GLThread", "exiting tid=" + jVar.getId(), new Object[0]);
        GameGLSurfaceView gameGLSurfaceView = (GameGLSurfaceView) j.a(jVar).get();
        if (gameGLSurfaceView != null) {
            GameGLSurfaceView.g(gameGLSurfaceView).onDestroy();
        } else {
            c.i("MicroMsg.GLThread", "onFinalize:view = null", new Object[0]);
        }
        i b = j.b(jVar);
        c.w("MicroMsg.GLThread", "destroySurface()  tid=" + Thread.currentThread().getId(), new Object[0]);
        b.destroySurfaceImp();
        j.c(jVar);
        j.d(jVar);
        try {
            i b2 = j.b(jVar);
            c.w("MicroMsg.GLThread", "finish() tid=" + Thread.currentThread().getId(), new Object[0]);
            if (b2.mEglContext != null) {
                GameGLSurfaceView gameGLSurfaceView2 = (GameGLSurfaceView) b2.mGLSurfaceViewWeakRef.get();
                if (gameGLSurfaceView2 != null) {
                    GameGLSurfaceView.c(gameGLSurfaceView2).destroyContext(b2.mEgl, b2.mEglDisplay, b2.mEglContext);
                }
                b2.mEglContext = null;
            }
            if (b2.mEglDisplay != null) {
                b2.mEgl.eglTerminate(b2.mEglDisplay);
                b2.mEglDisplay = null;
            }
        } catch (Throwable th) {
            c.e(TAG, "alvinluo GLThread#threadExiting finish stack = [%s]", new Object[]{Log.getStackTraceString(th)});
            if (gameGLSurfaceView != null) {
                GameGLSurfaceView.g(gameGLSurfaceView).aPF();
            }
        }
        j.e(jVar);
        notifyAll();
        AppMethodBeat.o(134088);
    }
}
