红果免费短剧 v6.2.3.32版本的 MD5 值为:a6b05492607eab2c8a25f26d2f238ae0

以下内容为反编译后的 b.java 源代码,内容仅作参考


package com.ss.texturerender.effect.vr;

import android.content.Context;
import android.opengl.GLES20;
import android.opengl.Matrix;
import android.os.Build;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.OrientationEventListener;
import android.view.WindowManager;
import com.ss.texturerender.d;
import com.ss.texturerender.effect.EffectTexture;
import com.ss.texturerender.effect.k;
import com.ss.texturerender.effect.m;
import com.ss.texturerender.effect.vr.director.TouchDirector;
import com.ss.texturerender.o;
import com.ss.texturerender.u;
import com.ss.texturerender.v;
import java.lang.reflect.Array;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
import java.util.Arrays;

public class b extends m implements com.ss.texturerender.effect.vr.director.b {
    public float V;
    protected int W;
    protected int X;
    protected int Y;
    protected float[] Z;
    protected a aA;
    private final String aB;
    private final String aC;
    private final String aD;
    private final String aE;
    private int aQ;
    private int aR;
    private int aS;
    private float aT;
    private boolean aU;
    private int aV;
    private int aW;
    private int aX;
    private float aY;
    private float[] aZ;
    protected float[] aa;
    protected float[] ab;
    protected float[] ac;
    protected boolean ad;
    protected boolean ae;
    protected float[] af;
    protected float[] ag;
    protected TouchDirector ah;
    protected com.ss.texturerender.effect.vr.director.a ai;
    protected boolean aj;
    protected c ak;
    protected int al;
    protected int am;
    protected int an;
    protected int ao;
    protected int ap;
    protected float aq;
    public float ar;
    protected boolean as;
    protected FloatBuffer[] at;
    protected FloatBuffer[] au;
    protected ShortBuffer[] av;
    protected float aw;
    protected int ax;
    protected int ay;
    protected int az;
    private float[][] ba;
    private float bb;
    private float bc;
    private float[] bd;
    private float[][] be;
    private float[][] bf;
    private short[][] bg;
    private float bh;
    private com.ss.texturerender.effect.vr.a.a bi;
    private float[] bj;
    private int bk;
    private int bl;
    private float bm;
    private Display bn;
    private FloatBuffer bo;
    private float[] bp;
    private float[] bq;
    private float br;
    private int bs;
    private com.ss.texturerender.b.c bt;
    private int bu;
    private static float[] aF = {0.5f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f};
    private static float[] aG = {0.5f, 0.0f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f};
    private static float[] aH = {1.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f};
    private static float[] aI = {1.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.5f, 0.0f, 0.0f, 0.0f};
    protected static float[] U = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f};
    private static float aJ = 1.0f;
    private static float aK = 0.0254f;
    private static int aL = 0;
    private static int aM = 1;
    private static float aN = 0.1f;
    private static float aO = 100.0f;
    private static int aP = 40;

    @Override
    public EffectTexture a(EffectTexture effectTexture, k kVar) {
        EffectTexture effectTexture2;
        EffectTexture effectTexture3;
        com.ss.texturerender.b.c cVar;
        float[] fArr;
        if (!this.as) {
            this.as = true;
            a aVar = this.aA;
            if (aVar != null) {
                aVar.enable();
            }
            k();
            n();
        }
        if (effectTexture.e != this.f107883b) {
            u.f(this.j, getClass().getSimpleName(), "error, texture miss match, accept:" + this.f107883b + ",in:" + effectTexture.e);
            if (this.e != null) {
                this.e.notifyError(12, this.f107882a, "error, texture miss match, accept:" + this.f107883b + ",in:" + effectTexture.e);
            }
            return effectTexture;
        }
        if (this.s == 0) {
            u.f(this.j, "TR_GLPanoramaFilter", "program error,don't process,filter:" + this.f107882a);
            if (this.e != null) {
                this.e.notifyError(13, this.f107882a, "program error,don't process,filter:" + this.f107882a);
            }
            return effectTexture;
        }
        if (this.e != null) {
            this.e.currentEffectProcessBegin(this.f107882a);
        }
        GLES20.glUseProgram(this.s);
        this.y = this.e.getViewportWidth();
        this.z = this.e.getViewportHeight();
        if (this.al == 1) {
            c(effectTexture, kVar);
        }
        GLES20.glBindBuffer(34962, this.az);
        GLES20.glVertexAttribPointer(this.t, 3, 5126, false, this.l, 0);
        GLES20.glEnableVertexAttribArray(this.t);
        GLES20.glBindBuffer(34962, 0);
        GLES20.glBindBuffer(34962, this.ay);
        GLES20.glVertexAttribPointer(this.u, 2, 5126, false, this.m, 0);
        GLES20.glEnableVertexAttribArray(this.u);
        GLES20.glBindBuffer(34962, 0);
        if (!this.aj && (fArr = this.ab) != null) {
            this.aa = fArr;
            if (!this.ad) {
                com.ss.texturerender.effect.vr.director.a aVar2 = this.ai;
                if (aVar2 != null && this.ap != 2) {
                    aVar2.a(fArr, 0);
                }
                Matrix.invertM(this.ac, 0, this.aa, 0);
                float[] fArr2 = this.aa;
                Matrix.multiplyMM(fArr2, 0, fArr2, 0, this.ac, 0);
                this.ab = this.aa;
                this.ad = true;
            }
        } else {
            com.ss.texturerender.effect.vr.director.a aVar3 = this.ai;
            if (aVar3 != null && this.ap != 2) {
                aVar3.a(this.aa, 0);
            }
            if (!this.ad) {
                Matrix.invertM(this.ac, 0, this.aa, 0);
                this.ad = true;
            }
            if (this.ap != 2 && this.ae) {
                float[] fArr3 = this.aa;
                Matrix.multiplyMM(fArr3, 0, fArr3, 0, this.ac, 0);
            }
        }
        Matrix.setIdentityM(this.ag, 0);
        if (!d.a() || this.W != 0 || this.X != 0) {
            Matrix.rotateM(this.ag, 0, this.X + this.ah.f107913b, 1.0f, 0.0f, 0.0f);
            Matrix.rotateM(this.ag, 0, this.ah.f107914c - this.W, 0.0f, 1.0f, 0.0f);
        }
        Matrix.rotateM(this.ag, 0, this.Y, 1.0f, 0.0f, 0.0f);
        float[] fArr4 = new float[16];
        Matrix.multiplyMM(fArr4, 0, this.aa, 0, this.ag, 0);
        Matrix.invertM(fArr4, 0, fArr4, 0);
        com.ss.texturerender.b.c cVar2 = new com.ss.texturerender.b.c(fArr4);
        this.e.setHeadPose(cVar2);
        this.bs++;
        int intOption = this.bs % (this.e != null ? this.e.getIntOption(135) : 1);
        this.bs = intOption;
        if (intOption == 0 && ((cVar = this.bt) == null || Math.abs(cVar.f107849a - cVar2.f107849a) + Math.abs(this.bt.f107850b - cVar2.f107850b) + Math.abs(this.bt.f107851c - cVar2.f107851c) + Math.abs(this.bt.d - cVar2.d) > 0.001d)) {
            if (this.e != null) {
                this.e.onHeadposeChanged(cVar2);
            }
            this.bt = cVar2;
        }
        float c2 = this.ak.c();
        GLES20.glUniformMatrix4fv(GLES20.glGetUniformLocation(this.s, "rotateMatrix"), 1, false, this.ag, 0);
        if (this.aW == 3) {
            GLES20.glUniform2fv(GLES20.glGetUniformLocation(this.s, "texOffset"), 6, this.bp, 0);
            GLES20.glUniformMatrix2fv(GLES20.glGetUniformLocation(this.s, "rotates"), 6, false, this.bq, 0);
            GLES20.glUniform3f(this.aS, 0.0f, 0.0f, this.aT);
        }
        GLES20.glUniform1f(this.aR, this.V);
        float viewportWidth = (this.e.getViewportWidth() * 1.0f) / this.e.getViewportHeight();
        this.ar = viewportWidth > 1.0f ? viewportWidth : 1.0f;
        if (kVar != null) {
            a(viewportWidth);
            effectTexture2 = d();
            if (effectTexture2 == null) {
                return effectTexture;
            }
            kVar.a(effectTexture2.f107878a);
            this.y = this.E;
            this.z = this.F;
        } else {
            effectTexture2 = null;
        }
        if (this.C) {
            GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            GLES20.glClear(16384);
        }
        GLES20.glActiveTexture(33984);
        GLES20.glBindTexture(this.f107883b, effectTexture.f107878a);
        GLES20.glUniform1i(this.D, 0);
        if (this.aV == 1) {
            GLES20.glUniformMatrix3fv(GLES20.glGetUniformLocation(this.s, "texScale"), 1, false, U, 0);
            Matrix.perspectiveM(this.Z, 0, this.aq / this.ar, viewportWidth, 0.1f, 100.0f);
            Matrix.scaleM(this.Z, 0, c2, c2, 1.0f);
            GLES20.glViewport(this.A, this.B, this.y, this.z);
            Matrix.setLookAtM(this.af, 0, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f);
            a(this.x);
            effectTexture.a();
        } else {
            if (!d.a()) {
                a(false);
                float[] fArr5 = this.Z;
                float[][] fArr6 = this.ba;
                int i = aL;
                float f = -fArr6[i][0];
                float f2 = aN;
                Matrix.frustumM(fArr5, 0, f * f2, fArr6[i][1] * f2, (-fArr6[i][2]) * f2, fArr6[i][3] * f2, f2, aO);
            } else {
                Matrix.perspectiveM(this.Z, 0, this.aq, viewportWidth / 2.0f, 0.1f, 100.0f);
            }
            if (this.al == 4) {
                GLES20.glUniformMatrix3fv(GLES20.glGetUniformLocation(this.s, "texScale"), 1, false, aF, 0);
            } else {
                GLES20.glUniformMatrix3fv(GLES20.glGetUniformLocation(this.s, "texScale"), 1, false, aH, 0);
            }
            GLES20.glViewport(0, 0, this.y / 2, this.z);
            Matrix.setLookAtM(this.af, 0, d.a() ? 0.0f : -this.bb, 0.0f, 0.0f, d.a() ? 0.0f : -this.bb, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f);
            a(this.x);
            FloatBuffer floatBuffer = this.bo;
            if (floatBuffer != null) {
                floatBuffer.position(0);
                GLES20.glVertexAttribPointer(this.u, 2, 5126, false, this.m, (Buffer) this.bo);
                GLES20.glEnableVertexAttribArray(this.u);
            }
            if (!d.a()) {
                float[] fArr7 = this.Z;
                float[][] fArr8 = this.ba;
                int i2 = aM;
                float f3 = -fArr8[i2][0];
                float f4 = aN;
                Matrix.frustumM(fArr7, 0, f3 * f4, fArr8[i2][1] * f4, (-fArr8[i2][2]) * f4, fArr8[i2][3] * f4, f4, aO);
            }
            if (this.al == 4) {
                GLES20.glUniformMatrix3fv(GLES20.glGetUniformLocation(this.s, "texScale"), 1, false, aG, 0);
            } else {
                GLES20.glUniformMatrix3fv(GLES20.glGetUniformLocation(this.s, "texScale"), 1, false, aI, 0);
            }
            GLES20.glViewport(this.y / 2, 0, this.y / 2, this.z);
            Matrix.setLookAtM(this.af, 0, d.a() ? 0.0f : this.bb, 0.0f, 0.0f, d.a() ? 0.0f : this.bb, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f);
            a(this.x);
            effectTexture.a();
            if (!d.a()) {
                if (kVar != null) {
                    effectTexture3 = d();
                    if (effectTexture3 != null) {
                        kVar.a(effectTexture3.f107878a);
                    }
                } else {
                    effectTexture3 = null;
                }
                GLES20.glUseProgram(this.s);
                GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
                GLES20.glClear(16384);
                GLES20.glViewport(this.A, this.B, this.y, this.z);
                GLES20.glActiveTexture(33984);
                GLES20.glBindTexture(this.f107883b, effectTexture2.f107878a);
                GLES20.glUniform1i(this.D, 0);
                GLES20.glUniformMatrix4fv(this.aQ, 1, false, this.bj, 0);
                GLES20.glEnable(3089);
                GLES20.glScissor(this.A, this.B, this.y / 2, this.z);
                d(aL);
                GLES20.glScissor((this.y / 2) + this.A, this.B, this.y / 2, this.z);
                d(aM);
                GLES20.glDisable(3089);
                effectTexture2.a();
                effectTexture2 = effectTexture3;
            }
        }
        GLES20.glBindTexture(this.f107883b, 0);
        GLES20.glDisableVertexAttribArray(this.t);
        GLES20.glDisableVertexAttribArray(this.u);
        this.e.setOption(19, this.f107882a, 1);
        GLES20.glFinish();
        if (this.e != null) {
            this.e.currentEffectProcessEnd(this.f107882a);
        }
        int a2 = o.a(this.j, "error pano draw");
        if (a2 != 0 && this.e != null) {
            this.e.notifyError(a2, this.f107882a, "error pano draw");
        }
        if (kVar == null) {
            return null;
        }
        kVar.c();
        return effectTexture2;
    }

    public void a(float f) {
        if (this.aX == 2 && this.am == 180) {
            this.F = (int) Math.ceil(((this.aq / this.ar) / 90.0f) * this.e.getTexHeight() * this.aw);
        } else {
            this.F = (int) Math.ceil(((this.aq / this.ar) / 180.0f) * this.e.getTexHeight() * this.aw);
        }
        this.F = ((4 - (this.F % 4)) % 4) + this.F;
        this.E = (int) Math.ceil(this.F * 1.0f * f);
        u.a(this.j, "TR_GLPanoramaFilter", "pano OutTex h:" + this.F + " w:" + this.E + ",viewPortRatio:" + f + ", this:" + this);
    }

    public void a(ShortBuffer shortBuffer) {
        float[] fArr = new float[16];
        Matrix.multiplyMM(fArr, 0, this.af, 0, this.aa, 0);
        Matrix.multiplyMM(fArr, 0, this.Z, 0, fArr, 0);
        GLES20.glUniformMatrix4fv(this.aQ, 1, false, fArr, 0);
        shortBuffer.position(0);
        GLES20.glBindBuffer(34963, this.ax);
        GLES20.glDrawElements(4, shortBuffer.remaining(), 5123, 0);
        GLES20.glBindBuffer(34963, 0);
    }

    @Override
    public void a(int i, int i2) {
        TouchDirector touchDirector;
        if (i != 1) {
            if (i == 101) {
                this.aV = i2;
                return;
            }
            if (i == 102) {
                this.al = i2;
                c(null, null);
                return;
            }
            if (i == 105) {
                this.ap = i2;
                k();
                return;
            }
            if (i != 106) {
                if (i == 108) {
                    this.W = i2;
                } else if (i == 109) {
                    this.X = i2;
                } else {
                    if (i == 128) {
                        this.ad = false;
                        if (i2 == 0 || (touchDirector = this.ah) == null) {
                            return;
                        }
                        touchDirector.c();
                        return;
                    }
                    if (i == 129) {
                        boolean z = i2 != 0;
                        this.aj = z;
                        if (z) {
                            return;
                        }
                        this.ab = this.aa;
                        return;
                    }
                    switch (i) {
                        case 137:
                            this.bu = i2;
                            if (i2 == 0) {
                                k();
                                return;
                            }
                            if (i2 == 1 || i2 == 2) {
                                com.ss.texturerender.effect.vr.director.a aVar = this.ai;
                                if (aVar != null) {
                                    aVar.b();
                                }
                                if (i2 != 2 || this.e == null) {
                                    return;
                                }
                                this.e.unRegisterTouchListener(this.ah);
                                return;
                            }
                            return;
                        case 138:
                            this.Y = i2;
                            break;
                        case 139:
                            c cVar = this.ak;
                            if (cVar == null || !this.aU) {
                                return;
                            }
                            cVar.b();
                            this.ak.a();
                            return;
                    }
                }
            } else if (this.ai != null) {
                if (i2 == 1) {
                    a aVar2 = this.aA;
                    if (aVar2 != null) {
                        aVar2.disable();
                    }
                    this.ai.b();
                } else {
                    a aVar3 = this.aA;
                    if (aVar3 != null) {
                        aVar3.enable();
                    }
                    l();
                }
            }
        } else if (this.ai != null) {
            if (i2 == 3) {
                a aVar4 = this.aA;
                if (aVar4 != null) {
                    aVar4.disable();
                }
                this.ai.b();
                this.ai.c();
                this.ah.b();
                this.ah.c();
                this.ak.b();
                this.bu = 0;
            } else if (i2 == 1) {
                a aVar5 = this.aA;
                if (aVar5 != null) {
                    aVar5.enable();
                }
                l();
                this.ah.a();
                this.ak.a();
            }
        }
        u.b(this.j, "TR_GLPanoramaFilter", "setOption key:" + i + " value:" + i2 + ", this:" + this);
        super.a(i, i2);
    }

    @Override
    public com.ss.texturerender.effect.a b() {
        com.ss.texturerender.effect.vr.director.a aVar = this.ai;
        if (aVar != null) {
            aVar.b();
            this.ai = null;
        }
        a aVar2 = this.aA;
        if (aVar2 != null) {
            aVar2.disable();
            this.aA = null;
        }
        this.as = false;
        return super.b();
    }

    protected void l() {
        com.ss.texturerender.effect.vr.director.a aVar = this.ai;
        if (aVar != null) {
            if (this.bu == 0) {
                aVar.a();
                return;
            }
            u.b(this.j, "TR_GLPanoramaFilter", "freezing,don't start,this:" + this);
        }
    }

    protected void m() {
        if (this.e != null && this.ah != null) {
            if (this.bu == 2) {
                u.b(this.j, "TR_GLPanoramaFilter", "freezing touch,don't regist,this:" + this);
                return;
            }
            this.e.registerTouchListener(this.ah);
        }
    }

    public int o() {
        int i = this.am;
        int i2 = 2;
        if (i == 90) {
            i2 = 1;
        } else if (i != 180 || this.aW != 1 || this.aX != 2) {
            i2 = 0;
        }
        u.b(this.j, "TR_GLPanoramaFilter", "pano_eac:" + i2);
        return i2;
    }

    public void k() {
        u.b(this.j, "TR_GLPanoramaFilter", "handleDirectModeChange mDirectMode:" + this.ap + ", this:" + this);
        int i = this.ap;
        if (i == 1) {
            l();
            if (this.e != null) {
                this.e.unRegisterTouchListener(this.ah);
                return;
            }
            return;
        }
        if (i == 2) {
            com.ss.texturerender.effect.vr.director.a aVar = this.ai;
            if (aVar != null) {
                aVar.b();
            }
            m();
            return;
        }
        l();
        m();
    }

    public void n() {
        if (this.e == null) {
            u.b(this.j, "TR_GLPanoramaFilter", "Error: handleTouchScalerChange mSurfaceTexture is null");
            return;
        }
        u.b(this.j, "TR_GLPanoramaFilter", "handleTouchScalerChange mEnableTouchScaler:" + this.aU + ", this:" + this);
        if (this.aU) {
            this.ak.a();
            this.e.registerTouchListener(this.ak);
        } else {
            this.e.unRegisterTouchListener(this.ak);
            this.ak.b();
        }
    }

    private void i() {
        if (this.ax <= 0) {
            int[] iArr = new int[1];
            GLES20.glGenBuffers(1, iArr, 0);
            if (iArr[0] == 0) {
                u.b(this.j, "TR_GLPanoramaFilter", "glGenBuffers bufferID: 0");
                return;
            }
            this.ax = iArr[0];
        }
        GLES20.glBindBuffer(34963, this.ax);
        this.x.position(0);
        GLES20.glBufferData(34963, this.x.capacity() * 2, this.x, 35044);
        GLES20.glBindBuffer(34963, 0);
        if (this.az <= 0) {
            int[] iArr2 = new int[1];
            GLES20.glGenBuffers(1, iArr2, 0);
            if (iArr2[0] == 0) {
                u.b(this.j, "TR_GLPanoramaFilter", "glGenBuffers bufferID: 0");
                return;
            }
            this.az = iArr2[0];
        }
        GLES20.glBindBuffer(34962, this.az);
        this.v.position(0);
        GLES20.glBufferData(34962, this.v.capacity() * 4, this.v, 35044);
        GLES20.glBindBuffer(34962, 0);
        if (this.ay <= 0) {
            int[] iArr3 = new int[1];
            GLES20.glGenBuffers(1, iArr3, 0);
            if (iArr3[0] == 0) {
                u.b(this.j, "TR_GLPanoramaFilter", "glGenBuffers bufferID: 0");
                return;
            }
            this.ay = iArr3[0];
        }
        GLES20.glBindBuffer(34962, this.ay);
        this.w.position(0);
        GLES20.glBufferData(34962, this.w.capacity() * 4, this.w, 35044);
        GLES20.glBindBuffer(34962, 0);
    }

    public void j() {
        this.d = 90;
        this.aU = true;
        this.ak = new c(this.j);
        this.bi = new com.ss.texturerender.effect.vr.a.a(this.bd, this.j);
        int i = aP;
        this.be = (float[][]) Array.newInstance((Class<?>) float.class, 2, i * i * 2);
        int i2 = aP;
        this.bf = (float[][]) Array.newInstance((Class<?>) float.class, 2, i2 * i2 * 2);
        int i3 = aP;
        this.bg = (short[][]) Array.newInstance((Class<?>) short.class, 2, ((i3 - 1) * 2 * i3) + (i3 - 2));
        this.at = new FloatBuffer[2];
        this.au = new FloatBuffer[2];
        this.av = new ShortBuffer[2];
        this.ba = (float[][]) Array.newInstance((Class<?>) float.class, 2, 4);
        float[] fArr = new float[16];
        this.bj = fArr;
        Matrix.setIdentityM(fArr, 0);
        u.b(this.j, "TR_GLPanoramaFilter", "new GLPanoramaFilter,this:" + this);
    }

    protected class a extends OrientationEventListener {
        @Override
        public void onOrientationChanged(int i) {
            boolean z;
            if (b.this.ah != null) {
                TouchDirector touchDirector = b.this.ah;
                if (b.this.ap != 2 && b.this.aj) {
                    z = true;
                } else {
                    z = false;
                }
                touchDirector.a(i, z);
            }
        }

        public a(Context context) {
            super(context);
        }
    }

    @Override
    public int a(int i) {
        if (i == 10004 && d.a()) {
            if (Build.VERSION.SDK_INT >= 15) {
                return 36197;
            }
            return super.a(i);
        }
        if (i == 10012) {
            return this.aV;
        }
        return super.a(i);
    }

    @Override
    public String c(int i) {
        if (i != 11000) {
            if (i != 11001) {
                return super.c(i);
            }
            int i2 = this.aW;
            if (i2 == 2) {
                if (this.am == 180) {
                    return "#define PI 3.14159265359\nprecision mediump float;\nvarying vec2 vTextureCoord;\nvarying vec3 verPosition;\nuniform sampler2D sTexture;\nuniform float expandCoef;\nuniform vec3 zOffset;\nuniform mat3 texScale;//one eye and two eye scale\nvec2 EACTransFunc(vec2 oriCoord, float expand) {\n    vec2 resultCoord;\n    float xStep = -1.0 / 6.0 + step(1.0 / 6.0, oriCoord.x) / 3.0 + step(3.0 / 6.0, oriCoord.x) / 3.0 + step(2.0 / 3.0, oriCoord.x) / 6.0;\n    float yStep = 0.0;\n    resultCoord.x = (atan(((oriCoord.x - xStep) * 6.0 - 1.0) / expand) / PI * 4.0 + 1.0) / 6.0 + xStep;\n    resultCoord.y = (atan(((oriCoord.y - yStep) * 2.0 - 1.0) / expand) / PI * 4.0 + 1.0) / 2.0 + yStep;\n    return resultCoord;\n}\nvoid main() {\n    vec3 eacResult = vec3(EACTransFunc(vTextureCoord, expandCoef), 1.0) * texScale;\n    gl_FragColor = step(0.0, -verPosition.z) * texture2D(sTexture, eacResult.xy);\n}";
                }
                return "#define PI 3.14159265359\nprecision mediump float;\nvarying vec2 vTextureCoord;\nuniform sampler2D sTexture;\nuniform float expandCoef;\nuniform vec3 zOffset;\nuniform mat3 texScale;//one eye and two eye scale\nvec2 EACTransFunc(vec2 oriCoord, float expand) {\n    vec2 resultCoord;\n    float xStep = 1.0 / 3.0 * clamp(floor(oriCoord.x * 3.0), 0.0, 2.0);\n    float yStep = 0.5 * step(0.5, oriCoord.y);\n    resultCoord.x = (atan(((oriCoord.x - xStep) * 6.0 - 1.0) / expand) / PI * 4.0 + 1.0) / 6.0 + xStep;\n    resultCoord.y = (atan(((oriCoord.y - yStep) * 4.0 - 1.0) / expand) / PI * 4.0 + 1.0) / 4.0 + yStep;\n    return resultCoord;\n}\nvoid main() {\n    vec3 eacResult = vec3(EACTransFunc(vTextureCoord, expandCoef), 1.0) * texScale;\n    gl_FragColor = texture2D(sTexture,  eacResult.xy);\n}";
            }
            if (i2 == 3) {
                return "precision mediump float;\nvarying vec2 vTextureCoord;\nuniform sampler2D sTexture;\nuniform float expandCoef;\nvarying vec3 verPosition;\nuniform vec3 zOffset;\nuniform int cubemapMode;\nuniform vec2 texOffset[6];\nuniform mat2 rotates[6];\nuniform mat3 texScale;//one eye and two eye scale\nvec2 cubeToTexture(vec3 cubeCoord, float expand) {\n    vec2 result;\n    float absX = abs(cubeCoord.x);\n    float absY = abs(cubeCoord.y);\n    float absZ = abs(cubeCoord.z);\n    int index;//0:left 1:front 2:right 3:top 4:back 5:bottom\n    if (-cubeCoord.z >= absX && -cubeCoord.z >= absY) {\n        result = vec2(cubeCoord.x, cubeCoord.y);\n        index = 1;\n    } else if (cubeCoord.z >= absX && cubeCoord.z >= absY) {\n        result = vec2(-cubeCoord.x, cubeCoord.y);\n        index = 4;\n    } else if (cubeCoord.y >= absX && cubeCoord.y >= absZ) {\n        result = vec2(cubeCoord.x, cubeCoord.z);\n        index = 3;\n    } else if (-cubeCoord.y >= absX && -cubeCoord.y >= absZ) {\n        result = vec2(cubeCoord.x, -cubeCoord.z);\n        index = 5;\n    } else if (cubeCoord.x >= absY && cubeCoord.x >= absZ) {\n        result = vec2(cubeCoord.z, cubeCoord.y);\n        index = 2;\n    } else {\n        result = vec2(-cubeCoord.z, cubeCoord.y);\n        index = 0;\n    }\n    result = result * rotates[index] / expand;\n    result = vec2((result.x + 1.0) / 6.0, (result.y + 1.0) / 4.0) + texOffset[index];\n    return result;\n}\nvec2 offsetCubicTransFunc(vec3 inCubePosition) {\n    inCubePosition = inCubePosition - zOffset;\n    inCubePosition = inCubePosition / max(max(abs(inCubePosition.x),abs(inCubePosition.y)),abs(inCubePosition.z));\n    return cubeToTexture(inCubePosition, expandCoef);\n}\nvoid main() {\n    vec3 result = vec3(offsetCubicTransFunc(verPosition),1.0) * texScale;\n    gl_FragColor = texture2D(sTexture, result.xy);\n}";
            }
            if (i2 != 4 && i2 != 5) {
                return super.c(i);
            }
            return "precision mediump float;\nvarying vec2 vTextureCoord;\nuniform sampler2D sTexture;\nuniform float expandCoef;\nuniform vec3 zOffset;\nuniform mat3 texScale;//one eye and two eye scale\nvoid main() {\n    vec3 result = vec3((vTextureCoord - 0.5) / expandCoef + 0.5, 1.0) * texScale;\n    gl_FragColor = texture2D(sTexture, result.xy);\n}";
        }
        return "attribute vec4 aPosition;\nuniform mat4 u_MVPMatrix;\nuniform mat4 rotateMatrix;attribute vec4 aTextureCoord;\nvarying vec2 vTextureCoord;\nvarying vec3 verPosition;void main() {\n  gl_Position =  u_MVPMatrix * rotateMatrix * aPosition;\n  vTextureCoord = aTextureCoord.xy;\n  verPosition = aPosition.xyz;}\n";
    }

    private void d(int i) {
        this.at[i].position(0);
        GLES20.glVertexAttribPointer(this.t, 2, 5126, false, 8, (Buffer) this.at[i]);
        GLES20.glEnableVertexAttribArray(this.t);
        this.au[i].position(0);
        GLES20.glVertexAttribPointer(this.u, 2, 5126, false, 8, (Buffer) this.au[i]);
        GLES20.glEnableVertexAttribArray(this.u);
        this.av[i].position(0);
        GLES20.glDrawElements(5, this.av[i].remaining(), 5123, this.av[i]);
    }

    @Override
    public void b(Bundle bundle) {
        if (bundle != null && this.f107882a == bundle.getInt("effect_type")) {
            u.b(this.j, "TR_GLPanoramaFilter", " setOption:" + bundle.toString() + ",this:" + this);
            if (bundle.getInt("action") == 134) {
                com.ss.texturerender.effect.vr.director.a aVar = this.ai;
                if (aVar != null) {
                    aVar.b();
                    this.ai.c();
                    l();
                }
                TouchDirector touchDirector = this.ah;
                if (touchDirector != null) {
                    touchDirector.b();
                    this.ah.c();
                    this.ah.a();
                }
                c cVar = this.ak;
                if (cVar != null && this.aU) {
                    cVar.b();
                    this.ak.a();
                    return;
                }
                return;
            }
            return;
        }
        super.b(bundle);
    }

    public b(int i) {
        super(i, 8);
        this.aB = "attribute vec4 aPosition;\nuniform mat4 u_MVPMatrix;\nuniform mat4 rotateMatrix;attribute vec4 aTextureCoord;\nvarying vec2 vTextureCoord;\nvarying vec3 verPosition;void main() {\n  gl_Position =  u_MVPMatrix * rotateMatrix * aPosition;\n  vTextureCoord = aTextureCoord.xy;\n  verPosition = aPosition.xyz;}\n";
        this.aC = "#define PI 3.14159265359\nprecision mediump float;\nvarying vec2 vTextureCoord;\nuniform sampler2D sTexture;\nuniform float expandCoef;\nuniform vec3 zOffset;\nuniform mat3 texScale;//one eye and two eye scale\nvec2 EACTransFunc(vec2 oriCoord, float expand) {\n    vec2 resultCoord;\n    float xStep = 1.0 / 3.0 * clamp(floor(oriCoord.x * 3.0), 0.0, 2.0);\n    float yStep = 0.5 * step(0.5, oriCoord.y);\n    resultCoord.x = (atan(((oriCoord.x - xStep) * 6.0 - 1.0) / expand) / PI * 4.0 + 1.0) / 6.0 + xStep;\n    resultCoord.y = (atan(((oriCoord.y - yStep) * 4.0 - 1.0) / expand) / PI * 4.0 + 1.0) / 4.0 + yStep;\n    return resultCoord;\n}\nvoid main() {\n    vec3 eacResult = vec3(EACTransFunc(vTextureCoord, expandCoef), 1.0) * texScale;\n    gl_FragColor = texture2D(sTexture,  eacResult.xy);\n}";
        this.aD = "#define PI 3.14159265359\nprecision mediump float;\nvarying vec2 vTextureCoord;\nvarying vec3 verPosition;\nuniform sampler2D sTexture;\nuniform float expandCoef;\nuniform vec3 zOffset;\nuniform mat3 texScale;//one eye and two eye scale\nvec2 EACTransFunc(vec2 oriCoord, float expand) {\n    vec2 resultCoord;\n    float xStep = -1.0 / 6.0 + step(1.0 / 6.0, oriCoord.x) / 3.0 + step(3.0 / 6.0, oriCoord.x) / 3.0 + step(2.0 / 3.0, oriCoord.x) / 6.0;\n    float yStep = 0.0;\n    resultCoord.x = (atan(((oriCoord.x - xStep) * 6.0 - 1.0) / expand) / PI * 4.0 + 1.0) / 6.0 + xStep;\n    resultCoord.y = (atan(((oriCoord.y - yStep) * 2.0 - 1.0) / expand) / PI * 4.0 + 1.0) / 2.0 + yStep;\n    return resultCoord;\n}\nvoid main() {\n    vec3 eacResult = vec3(EACTransFunc(vTextureCoord, expandCoef), 1.0) * texScale;\n    gl_FragColor = step(0.0, -verPosition.z) * texture2D(sTexture, eacResult.xy);\n}";
        this.aE = "precision mediump float;\nvarying vec2 vTextureCoord;\nuniform sampler2D sTexture;\nuniform float expandCoef;\nvarying vec3 verPosition;\nuniform vec3 zOffset;\nuniform int cubemapMode;\nuniform vec2 texOffset[6];\nuniform mat2 rotates[6];\nuniform mat3 texScale;//one eye and two eye scale\nvec2 cubeToTexture(vec3 cubeCoord, float expand) {\n    vec2 result;\n    float absX = abs(cubeCoord.x);\n    float absY = abs(cubeCoord.y);\n    float absZ = abs(cubeCoord.z);\n    int index;//0:left 1:front 2:right 3:top 4:back 5:bottom\n    if (-cubeCoord.z >= absX && -cubeCoord.z >= absY) {\n        result = vec2(cubeCoord.x, cubeCoord.y);\n        index = 1;\n    } else if (cubeCoord.z >= absX && cubeCoord.z >= absY) {\n        result = vec2(-cubeCoord.x, cubeCoord.y);\n        index = 4;\n    } else if (cubeCoord.y >= absX && cubeCoord.y >= absZ) {\n        result = vec2(cubeCoord.x, cubeCoord.z);\n        index = 3;\n    } else if (-cubeCoord.y >= absX && -cubeCoord.y >= absZ) {\n        result = vec2(cubeCoord.x, -cubeCoord.z);\n        index = 5;\n    } else if (cubeCoord.x >= absY && cubeCoord.x >= absZ) {\n        result = vec2(cubeCoord.z, cubeCoord.y);\n        index = 2;\n    } else {\n        result = vec2(-cubeCoord.z, cubeCoord.y);\n        index = 0;\n    }\n    result = result * rotates[index] / expand;\n    result = vec2((result.x + 1.0) / 6.0, (result.y + 1.0) / 4.0) + texOffset[index];\n    return result;\n}\nvec2 offsetCubicTransFunc(vec3 inCubePosition) {\n    inCubePosition = inCubePosition - zOffset;\n    inCubePosition = inCubePosition / max(max(abs(inCubePosition.x),abs(inCubePosition.y)),abs(inCubePosition.z));\n    return cubeToTexture(inCubePosition, expandCoef);\n}\nvoid main() {\n    vec3 result = vec3(offsetCubicTransFunc(verPosition),1.0) * texScale;\n    gl_FragColor = texture2D(sTexture, result.xy);\n}";
        this.V = 1.0f;
        this.W = 0;
        this.X = 0;
        this.Y = 0;
        this.Z = new float[16];
        this.aa = new float[16];
        this.ab = new float[16];
        this.ac = new float[16];
        this.ad = false;
        this.ae = false;
        this.af = new float[16];
        this.ag = new float[16];
        this.aj = true;
        this.aV = 2;
        this.al = 1;
        this.aW = 1;
        this.aX = 1;
        this.am = 360;
        this.an = 360;
        this.ao = 180;
        this.ap = 1;
        this.aY = 100.0f;
        this.aq = 100.0f;
        this.ar = 1.0f;
        this.aZ = new float[]{100.0f / 2.0f, 100.0f / 2.0f, 100.0f / 2.0f, 100.0f / 2.0f};
        this.bb = 0.03f;
        this.as = false;
        this.bc = 0.042f;
        this.bd = new float[]{0.441f, 0.156f};
        this.bh = 0.035f;
        this.bk = -1;
        this.bl = -1;
        this.bm = 1.1f;
        this.aw = 1.1f;
        this.bo = null;
        this.ax = -1;
        this.ay = -1;
        this.az = -1;
        this.br = 0.0f;
        this.bs = 0;
        this.bt = null;
        this.bu = 0;
        this.aA = null;
        j();
    }

    private void a(boolean z) {
        if (this.aV == 2 && !d.a()) {
            DisplayMetrics displayMetrics = new DisplayMetrics();
            Context context = v.a().getContext();
            if (context != null) {
                ((WindowManager) context.getSystemService("window")).getDefaultDisplay().getMetrics(displayMetrics);
            }
            if (displayMetrics.widthPixels == this.bk && displayMetrics.heightPixels == this.bl && !z) {
                return;
            }
            this.bk = displayMetrics.widthPixels;
            this.bl = displayMetrics.heightPixels;
            float f = (displayMetrics.widthPixels / displayMetrics.xdpi) * aK;
            float f2 = (displayMetrics.heightPixels / displayMetrics.ydpi) * aK;
            float[] a2 = a(f, f2);
            this.ba[aL][0] = (float) Math.tan(a2[0]);
            this.ba[aL][1] = (float) Math.tan(a2[1]);
            this.ba[aL][2] = (float) Math.tan(a2[2]);
            this.ba[aL][3] = (float) Math.tan(a2[3]);
            this.ba[aM][0] = (float) Math.tan(a2[1]);
            this.ba[aM][1] = (float) Math.tan(a2[0]);
            this.ba[aM][2] = (float) Math.tan(a2[2]);
            this.ba[aM][3] = (float) Math.tan(a2[3]);
            u.b(this.j, "TR_GLPanoramaFilter", "realFov:" + Arrays.toString(a2) + "screenWInMeter:" + f + " screenHInMeter:" + f2);
            float f3 = this.bc;
            float f4 = f / f3;
            float f5 = f2 / f3;
            float f6 = f / 2.0f;
            float f7 = this.bb;
            float f8 = (this.bh - 0.003f) / f3;
            float tan = (float) (Math.tan((double) a2[0]) + Math.tan((double) a2[1]));
            float tan2 = (float) (Math.tan(a2[2]) + Math.tan(a2[3]));
            float tan3 = (float) Math.tan(a2[0]);
            float tan4 = (float) Math.tan(a2[1]);
            float tan5 = (float) Math.tan(a2[2]);
            a(aL, f4, f5, (f6 - f7) / f3, f8, tan, tan2, tan3, tan5);
            a(aM, f4, f5, (f6 + f7) / f3, f8, tan, tan2, tan4, tan5);
        }
    }

    @Override
    public int a(Bundle bundle) {
        boolean z;
        boolean z2;
        c cVar;
        Context context;
        if (bundle.containsKey("vr_model")) {
            int i = bundle.getInt("vr_model");
            this.aW = i;
            this.aX = i;
        }
        if (bundle.containsKey("video_projection_model")) {
            this.aX = bundle.getInt("video_projection_model");
        }
        this.am = bundle.getInt("view_size", 360);
        if (super.a(bundle) != 0) {
            if (this.e != null) {
                this.e.notifyError(10, this.f107882a, "super.init(bundle) != TR_OK");
                return -1;
            }
            return -1;
        }
        this.aQ = GLES20.glGetUniformLocation(this.s, "u_MVPMatrix");
        this.aR = GLES20.glGetUniformLocation(this.s, "expandCoef");
        this.aS = GLES20.glGetUniformLocation(this.s, "zOffset");
        Matrix.setIdentityM(this.aa, 0);
        Matrix.setIdentityM(this.af, 0);
        Matrix.setIdentityM(this.Z, 0);
        this.as = false;
        this.bu = 0;
        this.aV = bundle.getInt("pano_mode", 2);
        boolean z3 = true;
        this.al = bundle.getInt("video_style", 1);
        this.ap = bundle.getInt("direct_mode", 1);
        if (bundle.getInt("use_initial_head_pose_as_front", 0) == 0) {
            z = false;
        } else {
            z = true;
        }
        this.ae = z;
        this.aq = bundle.getFloat("perspective_view", this.aY);
        this.an = bundle.getInt("desire_view_size", this.am);
        this.aw = bundle.getFloat("vr_out_texture_scale", this.bm);
        if (bundle.containsKey("vr_background_texture_size")) {
            this.ao = bundle.getInt("vr_background_texture_size");
        }
        if (bundle.containsKey("expand_coef")) {
            this.V = bundle.getFloat("expand_coef");
        }
        this.aT = bundle.getFloat("z_offset", 0.0f);
        this.W = bundle.getInt("yaw");
        this.X = bundle.getInt("pitch");
        if (bundle.containsKey("space_orientation_pitch")) {
            this.Y = bundle.getInt("space_orientation_pitch");
        }
        this.br = bundle.getFloat("cmp_face_inner_padding", 0.0f);
        if (this.bn == null) {
            this.bn = ((WindowManager) v.a().getContext().getSystemService("window")).getDefaultDisplay();
        }
        u.b(this.j, "TR_GLPanoramaFilter", "display rotation:" + this.bn.getRotation() + ",perspec:" + this.aq);
        c(null, null);
        i();
        TouchDirector touchDirector = new TouchDirector(this.bn);
        this.ah = touchDirector;
        touchDirector.a();
        this.ah.f107912a = 800.0f;
        if (this.ai == null) {
            if (d.a()) {
                this.ai = new com.ss.texturerender.effect.vr.director.a.a(this.bn);
            } else {
                Context context2 = v.a().getContext();
                if (context2 != null) {
                    this.ai = new com.ss.texturerender.effect.vr.director.b.c(context2, this.bn, bundle.getInt("sensor_start_pos", 1), bundle.getInt("sensor_reset_pos", 2), this.j, bundle.getInt("sensor_smoother_enabled", 0), bundle.getFloat("sensor_smooth_factor", 1.0f), this);
                }
            }
        }
        com.ss.texturerender.effect.vr.director.a aVar = this.ai;
        if (aVar != null) {
            aVar.a(bundle);
        }
        if (this.aA == null && bundle.getInt("handle_device_orientation_enabled", 0) != 0 && !d.a() && (context = v.a().getContext()) != null) {
            this.aA = new a(context);
        }
        if (bundle.containsKey("fov")) {
            this.aZ = bundle.getFloatArray("fov");
            z2 = true;
        } else {
            z2 = false;
        }
        if (bundle.containsKey("distortion_coeffs")) {
            this.bd = bundle.getFloatArray("distortion_coeffs");
            z2 = true;
        }
        if (bundle.containsKey("screen_to_lens_distance")) {
            this.bc = bundle.getFloat("screen_to_lens_distance");
        } else {
            z3 = z2;
        }
        a(z3);
        if (this.aU && (cVar = this.ak) != null) {
            cVar.a(bundle.getFloat("max_scale", 4.0f));
            this.ak.b(bundle.getFloat("min_scale", 0.2f));
        }
        u.b(this.j, "TR_GLPanoramaFilter", "init, this:" + this + ",manu:" + Build.MANUFACTURER);
        return 0;
    }

    @Override
    public void a(int i, boolean z) {
        if (z) {
            this.e.setOption(128, 1);
        }
    }

    @Override
    public void a(int i, float f) {
        if (i != 103) {
            if (i != 104) {
                if (i != 111) {
                    if (i != 164) {
                        super.a(i, f);
                        return;
                    }
                    this.aw = f;
                    u.b(this.j, "TR_GLPanoramaFilter", "set textureScale:" + f);
                    return;
                }
                this.aT = f;
                u.b(this.j, "TR_GLPanoramaFilter", "set zoffset:" + f);
                return;
            }
            this.bb = f / 2.0f;
            u.b(this.j, "TR_GLPanoramaFilter", "eye disfance:" + f);
            return;
        }
        this.aq = f;
        u.b(this.j, "TR_GLPanoramaFilter", "perspective view:" + f);
    }

    private float[] a(float f, float f2) {
        float f3 = this.bb;
        float f4 = this.bh - 0.003f;
        return new float[]{Math.min((float) Math.atan(this.bi.a(((f / 2.0f) - f3) / this.bc, 0.0f)[0]), (float) Math.toRadians(this.aZ[0])), Math.min((float) Math.atan(this.bi.a(f3 / this.bc, 0.0f)[0]), (float) Math.toRadians(this.aZ[1])), Math.min((float) Math.atan(this.bi.a(0.0f, f4 / this.bc)[1]), (float) Math.toRadians(this.aZ[2])), Math.min((float) Math.atan(this.bi.a(0.0f, (f2 - f4) / this.bc)[1]), (float) Math.toRadians(this.aZ[3]))};
    }

    public b(int i, int i2) {
        super(i, i2);
        this.aB = "attribute vec4 aPosition;\nuniform mat4 u_MVPMatrix;\nuniform mat4 rotateMatrix;attribute vec4 aTextureCoord;\nvarying vec2 vTextureCoord;\nvarying vec3 verPosition;void main() {\n  gl_Position =  u_MVPMatrix * rotateMatrix * aPosition;\n  vTextureCoord = aTextureCoord.xy;\n  verPosition = aPosition.xyz;}\n";
        this.aC = "#define PI 3.14159265359\nprecision mediump float;\nvarying vec2 vTextureCoord;\nuniform sampler2D sTexture;\nuniform float expandCoef;\nuniform vec3 zOffset;\nuniform mat3 texScale;//one eye and two eye scale\nvec2 EACTransFunc(vec2 oriCoord, float expand) {\n    vec2 resultCoord;\n    float xStep = 1.0 / 3.0 * clamp(floor(oriCoord.x * 3.0), 0.0, 2.0);\n    float yStep = 0.5 * step(0.5, oriCoord.y);\n    resultCoord.x = (atan(((oriCoord.x - xStep) * 6.0 - 1.0) / expand) / PI * 4.0 + 1.0) / 6.0 + xStep;\n    resultCoord.y = (atan(((oriCoord.y - yStep) * 4.0 - 1.0) / expand) / PI * 4.0 + 1.0) / 4.0 + yStep;\n    return resultCoord;\n}\nvoid main() {\n    vec3 eacResult = vec3(EACTransFunc(vTextureCoord, expandCoef), 1.0) * texScale;\n    gl_FragColor = texture2D(sTexture,  eacResult.xy);\n}";
        this.aD = "#define PI 3.14159265359\nprecision mediump float;\nvarying vec2 vTextureCoord;\nvarying vec3 verPosition;\nuniform sampler2D sTexture;\nuniform float expandCoef;\nuniform vec3 zOffset;\nuniform mat3 texScale;//one eye and two eye scale\nvec2 EACTransFunc(vec2 oriCoord, float expand) {\n    vec2 resultCoord;\n    float xStep = -1.0 / 6.0 + step(1.0 / 6.0, oriCoord.x) / 3.0 + step(3.0 / 6.0, oriCoord.x) / 3.0 + step(2.0 / 3.0, oriCoord.x) / 6.0;\n    float yStep = 0.0;\n    resultCoord.x = (atan(((oriCoord.x - xStep) * 6.0 - 1.0) / expand) / PI * 4.0 + 1.0) / 6.0 + xStep;\n    resultCoord.y = (atan(((oriCoord.y - yStep) * 2.0 - 1.0) / expand) / PI * 4.0 + 1.0) / 2.0 + yStep;\n    return resultCoord;\n}\nvoid main() {\n    vec3 eacResult = vec3(EACTransFunc(vTextureCoord, expandCoef), 1.0) * texScale;\n    gl_FragColor = step(0.0, -verPosition.z) * texture2D(sTexture, eacResult.xy);\n}";
        this.aE = "precision mediump float;\nvarying vec2 vTextureCoord;\nuniform sampler2D sTexture;\nuniform float expandCoef;\nvarying vec3 verPosition;\nuniform vec3 zOffset;\nuniform int cubemapMode;\nuniform vec2 texOffset[6];\nuniform mat2 rotates[6];\nuniform mat3 texScale;//one eye and two eye scale\nvec2 cubeToTexture(vec3 cubeCoord, float expand) {\n    vec2 result;\n    float absX = abs(cubeCoord.x);\n    float absY = abs(cubeCoord.y);\n    float absZ = abs(cubeCoord.z);\n    int index;//0:left 1:front 2:right 3:top 4:back 5:bottom\n    if (-cubeCoord.z >= absX && -cubeCoord.z >= absY) {\n        result = vec2(cubeCoord.x, cubeCoord.y);\n        index = 1;\n    } else if (cubeCoord.z >= absX && cubeCoord.z >= absY) {\n        result = vec2(-cubeCoord.x, cubeCoord.y);\n        index = 4;\n    } else if (cubeCoord.y >= absX && cubeCoord.y >= absZ) {\n        result = vec2(cubeCoord.x, cubeCoord.z);\n        index = 3;\n    } else if (-cubeCoord.y >= absX && -cubeCoord.y >= absZ) {\n        result = vec2(cubeCoord.x, -cubeCoord.z);\n        index = 5;\n    } else if (cubeCoord.x >= absY && cubeCoord.x >= absZ) {\n        result = vec2(cubeCoord.z, cubeCoord.y);\n        index = 2;\n    } else {\n        result = vec2(-cubeCoord.z, cubeCoord.y);\n        index = 0;\n    }\n    result = result * rotates[index] / expand;\n    result = vec2((result.x + 1.0) / 6.0, (result.y + 1.0) / 4.0) + texOffset[index];\n    return result;\n}\nvec2 offsetCubicTransFunc(vec3 inCubePosition) {\n    inCubePosition = inCubePosition - zOffset;\n    inCubePosition = inCubePosition / max(max(abs(inCubePosition.x),abs(inCubePosition.y)),abs(inCubePosition.z));\n    return cubeToTexture(inCubePosition, expandCoef);\n}\nvoid main() {\n    vec3 result = vec3(offsetCubicTransFunc(verPosition),1.0) * texScale;\n    gl_FragColor = texture2D(sTexture, result.xy);\n}";
        this.V = 1.0f;
        this.W = 0;
        this.X = 0;
        this.Y = 0;
        this.Z = new float[16];
        this.aa = new float[16];
        this.ab = new float[16];
        this.ac = new float[16];
        this.ad = false;
        this.ae = false;
        this.af = new float[16];
        this.ag = new float[16];
        this.aj = true;
        this.aV = 2;
        this.al = 1;
        this.aW = 1;
        this.aX = 1;
        this.am = 360;
        this.an = 360;
        this.ao = 180;
        this.ap = 1;
        this.aY = 100.0f;
        this.aq = 100.0f;
        this.ar = 1.0f;
        this.aZ = new float[]{100.0f / 2.0f, 100.0f / 2.0f, 100.0f / 2.0f, 100.0f / 2.0f};
        this.bb = 0.03f;
        this.as = false;
        this.bc = 0.042f;
        this.bd = new float[]{0.441f, 0.156f};
        this.bh = 0.035f;
        this.bk = -1;
        this.bl = -1;
        this.bm = 1.1f;
        this.aw = 1.1f;
        this.bo = null;
        this.ax = -1;
        this.ay = -1;
        this.az = -1;
        this.br = 0.0f;
        this.bs = 0;
        this.bt = null;
        this.bu = 0;
        this.aA = null;
        j();
    }

    @Override
    public int c(EffectTexture effectTexture, k kVar) {
        float[] fArr;
        int i;
        short[] sArr;
        int i2;
        u.b(this.j, "TR_GLPanoramaFilter", "handleModlelChange mVideoStyle:" + this.al + ", this:" + this);
        float[][] fArr2 = (float[][]) null;
        float f = 2.0f;
        if (this.al != 1) {
            int i3 = this.aW;
            if (i3 != 1 && i3 != 3 && i3 != 6) {
                if (i3 != 2 && i3 != 4 && i3 != 5) {
                    fArr = null;
                    i = 0;
                    sArr = null;
                } else {
                    float[] fArr3 = {-1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f};
                    sArr = new short[]{0, 1, 2, 1, 2, 3, 4, 5, 6, 5, 6, 7, 8, 9, 10, 9, 10, 11, 12, 13, 14, 13, 14, 15, 16, 17, 18, 17, 18, 19, 20, 21, 22, 21, 22, 23};
                    float[][] fArr4 = new float[2];
                    if (i3 == 5) {
                        float f2 = this.br;
                        float f3 = 0.16666667f;
                        float f4 = 0.16666667f - (0.33333334f * f2);
                        float f5 = 0.25f - (f2 * 0.5f);
                        fArr4[0] = new float[48];
                        int i4 = 0;
                        for (int i5 = 6; i4 < i5; i5 = 6) {
                            int i6 = i4 * 8;
                            float f6 = (((i4 % 3) * 2) + 1) * f3;
                            float f7 = (((i4 / 3) * 2) + 1) * 0.25f;
                            float f8 = f6 - f4;
                            fArr4[0][i6 + 0] = f8;
                            float f9 = f7 - f5;
                            fArr4[0][i6 + 1] = f9;
                            float f10 = f6 + f4;
                            fArr4[0][i6 + 2] = f10;
                            fArr4[0][i6 + 3] = f9;
                            fArr4[0][i6 + 4] = f8;
                            float f11 = f7 + f5;
                            fArr4[0][i6 + 5] = f11;
                            fArr4[0][i6 + 6] = f10;
                            fArr4[0][i6 + 7] = f11;
                            i4++;
                            f3 = 0.16666667f;
                        }
                    } else if (i3 == 4) {
                        fArr4[0] = new float[]{0.0f, 0.0f, 0.33333334f, 0.0f, 0.0f, 0.5f, 0.33333334f, 0.5f, 0.33333334f, 0.0f, 0.6666667f, 0.0f, 0.33333334f, 0.5f, 0.6666667f, 0.5f, 0.6666667f, 0.0f, 1.0f, 0.0f, 0.6666667f, 0.5f, 1.0f, 0.5f, 0.0f, 1.0f, 0.0f, 0.5f, 0.33333334f, 1.0f, 0.33333334f, 0.5f, 0.6666667f, 0.5f, 0.6666667f, 1.0f, 0.33333334f, 0.5f, 0.33333334f, 1.0f, 0.6666667f, 1.0f, 0.6666667f, 0.5f, 1.0f, 1.0f, 1.0f, 0.5f};
                    } else if (this.am == 360) {
                        fArr4[0] = new float[]{0.0f, 0.5f, 0.33333334f, 0.5f, 0.0f, 1.0f, 0.33333334f, 1.0f, 0.33333334f, 0.5f, 0.6666667f, 0.5f, 0.33333334f, 1.0f, 0.6666667f, 1.0f, 0.6666667f, 0.5f, 1.0f, 0.5f, 0.6666667f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.5f, 0.6666667f, 0.0f, 0.6666667f, 0.5f, 0.33333334f, 0.5f, 0.33333334f, 0.0f, 0.6666667f, 0.5f, 0.6666667f, 0.0f, 0.33333334f, 0.0f, 0.33333334f, 0.5f, 0.0f, 0.0f, 0.0f, 0.5f};
                    } else {
                        fArr4[0] = new float[]{-0.16666667f, 0.0f, 0.16666667f, 0.0f, -0.16666667f, 1.0f, 0.16666667f, 1.0f, 0.16666667f, 0.0f, 0.5f, 0.0f, 0.16666667f, 1.0f, 0.5f, 1.0f, 0.5f, 0.0f, 0.8333333f, 0.0f, 0.5f, 1.0f, 0.8333333f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.6666667f, 0.0f, 0.6666667f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.6666667f, 0.0f, 0.6666667f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.6666667f, 0.0f, 0.6666667f, 1.0f};
                    }
                    fArr = fArr3;
                    fArr2 = fArr4;
                }
            } else {
                int i7 = (int) ((this.an * 150.0d) / 360.0d);
                float f12 = (float) ((r3 / 180) * 3.141592653589793d);
                float f13 = 1.0f / 75;
                float f14 = 1.0f / i7;
                int i8 = i7 + 1;
                int i9 = 76 * i8;
                fArr = new float[i9 * 3];
                short[] sArr2 = new short[i9 * 6];
                short s = 0;
                int i10 = 0;
                for (short s2 = 76; s < s2; s2 = 76) {
                    short[] sArr3 = sArr2;
                    double d = s * 3.1415927f * f13;
                    float cos = (float) Math.cos(d);
                    float sin = (float) Math.sin(d);
                    short s3 = 0;
                    while (s3 < i8) {
                        double d2 = (3.1415927f - (f12 / f)) + (s3 * f12 * f14);
                        float f15 = f12;
                        double d3 = sin;
                        int i11 = i7;
                        float f16 = f13;
                        float f17 = -((float) (Math.sin(d2) * d3));
                        float cos2 = (float) (Math.cos(d2) * d3);
                        int i12 = i10 + 1;
                        float f18 = aJ;
                        fArr[i10] = f17 * f18;
                        int i13 = i12 + 1;
                        fArr[i12] = cos * f18;
                        i10 = i13 + 1;
                        fArr[i13] = cos2 * f18;
                        s3 = (short) (s3 + 1);
                        f12 = f15;
                        i7 = i11;
                        f13 = f16;
                        f = 2.0f;
                    }
                    s = (short) (s + 1);
                    sArr2 = sArr3;
                    f = 2.0f;
                }
                int i14 = i7;
                float f19 = f13;
                short[] sArr4 = sArr2;
                int i15 = 2;
                int i16 = i9 * 2;
                fArr2 = new float[][]{new float[i16], null};
                short s4 = 0;
                int i17 = 0;
                int i18 = 0;
                while (s4 < 76) {
                    short s5 = 0;
                    while (s5 < i8) {
                        int i19 = this.al;
                        if (i19 != i15) {
                            if (i19 != 3) {
                                if (i19 == 4) {
                                    if (d.a()) {
                                        int i20 = i17 + 1;
                                        fArr2[0][i17] = s5 * f14;
                                        i2 = i20 + 1;
                                        fArr2[0][i20] = s4 * f19;
                                    } else {
                                        int i21 = i17 + 1;
                                        fArr2[0][i17] = s5 * f14 * 0.5f;
                                        i2 = i21 + 1;
                                        fArr2[0][i21] = 1.0f - (s4 * f19);
                                    }
                                    if (fArr2[1] == null) {
                                        fArr2[1] = new float[i16];
                                    }
                                    if (d.a()) {
                                        int i22 = i18 + 1;
                                        fArr2[1][i18] = s5 * f14;
                                        i18 = i22 + 1;
                                        fArr2[1][i22] = s4 * f19;
                                    } else {
                                        int i23 = i18 + 1;
                                        fArr2[1][i18] = (s5 * f14 * 0.5f) + 0.5f;
                                        fArr2[1][i23] = 1.0f - (s4 * f19);
                                        i18 = i23 + 1;
                                    }
                                }
                                s5 = (short) (s5 + 1);
                                i15 = 2;
                            } else {
                                int i24 = i17 + 1;
                                float f20 = s5 * f14;
                                fArr2[0][i17] = f20;
                                if (d.a()) {
                                    i2 = i24 + 1;
                                    fArr2[0][i24] = s4 * f19;
                                } else {
                                    i2 = i24 + 1;
                                    fArr2[0][i24] = 1.0f - ((s4 * f19) * 0.5f);
                                }
                                if (fArr2[1] == null) {
                                    fArr2[1] = new float[i16];
                                }
                                int i25 = i18 + 1;
                                fArr2[1][i18] = f20;
                                if (d.a()) {
                                    i18 = i25 + 1;
                                    fArr2[1][i25] = s4 * f19;
                                } else {
                                    fArr2[1][i25] = 0.5f - ((s4 * f19) * 0.5f);
                                    i18 = i25 + 1;
                                }
                            }
                            i17 = i2;
                            s5 = (short) (s5 + 1);
                            i15 = 2;
                        } else {
                            int i26 = i17 + 1;
                            fArr2[0][i17] = s5 * f14;
                            if (d.a()) {
                                i2 = i26 + 1;
                                fArr2[0][i26] = s4 * f19;
                            } else {
                                fArr2[0][i26] = 1.0f - (s4 * f19);
                                i17 = i26 + 1;
                                s5 = (short) (s5 + 1);
                                i15 = 2;
                            }
                        }
                        i17 = i2;
                        s5 = (short) (s5 + 1);
                        i15 = 2;
                    }
                    s4 = (short) (s4 + 1);
                    i15 = 2;
                }
                short s6 = 0;
                int i27 = 0;
                while (s6 < 75) {
                    int i28 = i14;
                    short s7 = 0;
                    while (s7 < i28) {
                        int i29 = i27 + 1;
                        int i30 = s6 * i8;
                        sArr4[i27] = (short) (i30 + s7);
                        int i31 = i29 + 1;
                        int i32 = (s6 + 1) * i8;
                        short s8 = (short) (i32 + s7);
                        sArr4[i29] = s8;
                        int i33 = i31 + 1;
                        int i34 = s7 + 1;
                        short s9 = (short) (i30 + i34);
                        sArr4[i31] = s9;
                        int i35 = i33 + 1;
                        sArr4[i33] = s9;
                        int i36 = i35 + 1;
                        sArr4[i35] = s8;
                        i27 = i36 + 1;
                        sArr4[i36] = (short) (i32 + i34);
                        s7 = (short) i34;
                    }
                    s6 = (short) (s6 + 1);
                    i14 = i28;
                }
                if (this.aW == 3) {
                    this.bp = new float[]{0.0f, 0.0f, 0.33333334f, 0.0f, 0.6666667f, 0.0f, 0.0f, 0.5f, 0.33333334f, 0.5f, 0.6666667f, 0.5f};
                    this.bq = new float[]{1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 0.0f};
                }
                sArr = sArr4;
            }
            i = 0;
        } else {
            if (effectTexture == null) {
                return -1;
            }
            float tan = (float) (aJ * Math.tan((((this.aq - 15.0f) / 2.0f) / 180.0f) * 3.141592653589793d));
            float f21 = (effectTexture.f107880c * tan) / effectTexture.d;
            float f22 = -f21;
            float f23 = -tan;
            float f24 = aJ;
            fArr = new float[]{f22, f23, -f24, f21, f23, -f24, f22, tan, -f24, f21, tan, -f24};
            u.b(this.j, "TR_GLPanoramaFilter", "triangle ver:" + Arrays.toString(q));
            fArr2 = new float[2];
            i = 0;
            fArr2[0] = new float[]{0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f};
            sArr = new short[]{0, 1, 2, 1, 2, 3};
        }
        if (fArr2 != null) {
            this.w = ByteBuffer.allocateDirect(fArr2[i].length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
            if (this.w != null) {
                this.w.put(fArr2[i]).position(i);
            }
            if (fArr2[1] != null) {
                FloatBuffer asFloatBuffer = ByteBuffer.allocateDirect(fArr2[1].length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
                this.bo = asFloatBuffer;
                if (asFloatBuffer != null) {
                    asFloatBuffer.put(fArr2[1]).position(0);
                }
            } else {
                this.bo = null;
            }
        }
        if (fArr != null) {
            this.v = ByteBuffer.allocateDirect(fArr.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
            if (this.v != null) {
                this.v.put(fArr).position(0);
            }
        }
        if (sArr != null) {
            this.x = ByteBuffer.allocateDirect(sArr.length * 2).order(ByteOrder.nativeOrder()).asShortBuffer();
            this.x.put(sArr).position(0);
            return 0;
        }
        return 0;
    }

    private void a(int i, float f, float f2, float f3, float f4, float f5, float f6, float f7, float f8) {
        float f9;
        int i2;
        if (i == aL) {
            f9 = 0.0f;
        } else {
            f9 = 0.5f;
        }
        int i3 = 0;
        while (true) {
            if (i3 >= aP) {
                break;
            }
            float f10 = (i3 * 1.0f) / (r5 - 1);
            int i4 = 0;
            while (true) {
                if (i4 < aP) {
                    float f11 = (i4 * 1.0f) / (r9 - 1);
                    float[] b2 = this.bi.b((f11 * f5) - f7, (f10 * f6) - f8);
                    float f12 = (b2[0] + f3) / f;
                    float f13 = (b2[1] + f4) / f2;
                    int i5 = ((aP * i3) + i4) * 2;
                    float[][] fArr = this.bf;
                    fArr[i][i5] = (f12 * 2.0f) - 1.0f;
                    float[] fArr2 = fArr[i];
                    int i6 = i5 + 1;
                    fArr2[i6] = (f13 * 2.0f) - 1.0f;
                    float[][] fArr3 = this.be;
                    fArr3[i][i5] = (f11 / 2.0f) + f9;
                    fArr3[i][i6] = f10;
                    i4++;
                }
            }
            i3++;
        }
        int i7 = 0;
        int i8 = 0;
        for (int i9 = 0; i9 < aP - 1; i9++) {
            if (i9 > 0) {
                short[][] sArr = this.bg;
                sArr[i][i7] = sArr[i][i7 - 1];
                i7++;
            }
            int i10 = 0;
            while (true) {
                i2 = aP;
                if (i10 < i2) {
                    if (i10 > 0) {
                        i8 = i9 % 2 == 0 ? i8 + 1 : i8 - 1;
                    }
                    short[][] sArr2 = this.bg;
                    int i11 = i7 + 1;
                    sArr2[i][i7] = (short) i8;
                    sArr2[i][i11] = (short) (i2 + i8);
                    i10++;
                    i7 = i11 + 1;
                }
            }
            i8 += i2;
        }
        this.at[i] = ByteBuffer.allocateDirect(this.bf[i].length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
        this.at[i].put(this.bf[i]).position(0);
        this.au[i] = ByteBuffer.allocateDirect(this.be[i].length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
        this.au[i].put(this.be[i]).position(0);
        this.av[i] = ByteBuffer.allocateDirect(this.bg[i].length * 2).order(ByteOrder.nativeOrder()).asShortBuffer();
        this.av[i].put(this.bg[i]).position(0);
    }
}