package com.tencent.filter.art;

import android.graphics.Bitmap;
import com.tencent.filter.BaseFilter;
import com.tencent.filter.GLSLRender;
import com.tencent.filter.QImage;
import com.tencent.filter.m.f;
import com.tencent.filter.m.i;
import com.tencent.filter.m.o;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.view.b;
import com.tencent.view.g;

public class BokehFilter$a extends BaseFilter {
    int bNh = 1;
    float bNj = ((float) (1.0d / Math.exp(0.0d)));
    float bNk = 0.0f;
    int bNl = 1;
    int paramTEXTRUEID = -2000;
    int radius = 8;

    public BokehFilter$a(int i, float f, float f2, int i2, int i3) {
        super(GLSLRender.bJB);
        AppMethodBeat.i(86284);
        this.radius = i;
        this.bNj = f;
        this.bNk = f2;
        this.bNh = i2;
        this.bNl = i3;
        if (this.bNl > 0) {
            addParam(new o("inputImageTexture2", fN(this.bNh), 33986));
            addParam(new f("lumi_threshold", this.bNk));
            addParam(new f("lumi_weight", this.bNj));
            if (this.bNl == 1) {
                this.glsl_programID = GLSLRender.bKc;
                addParam(new i("r", this.radius));
                AppMethodBeat.o(86284);
                return;
            }
            this.glsl_programID = GLSLRender.bKo;
            AppMethodBeat.o(86284);
            return;
        }
        this.paramTEXTRUEID = g.dSO();
        AppMethodBeat.o(86284);
    }

    private static String fN(int i) {
        switch (i) {
            case 1:
                return "bokeh/circle.jpg";
            case 2:
                return "bokeh/shape2.jpg";
            case 3:
                return "bokeh/heart.jpg";
            default:
                return "bokeh/shape1.jpg";
        }
    }

    public final void beforeRender(int i, int i2, int i3) {
        AppMethodBeat.i(86285);
        if (this.bNl == 0) {
            Bitmap vt = b.vt(fN(this.bNh));
            QImage aL = g.aL(i, i2, i3);
            QImage BindBitmap = QImage.BindBitmap(vt);
            BokehFilter.nativeBokehProcess(aL, BindBitmap, this.radius, this.bNj, this.bNk);
            BindBitmap.UnBindBitmap(vt);
            vt.recycle();
            GLSLRender.nativeTextImage(aL, this.paramTEXTRUEID);
            aL.Dispose();
        }
        AppMethodBeat.o(86285);
    }

    public final boolean renderTexture(int i, int i2, int i3) {
        AppMethodBeat.i(86286);
        boolean renderTexture;
        if (this.paramTEXTRUEID != -2000) {
            renderTexture = super.renderTexture(this.paramTEXTRUEID, i2, i3);
            AppMethodBeat.o(86286);
            return renderTexture;
        }
        renderTexture = super.renderTexture(i, i2, i3);
        AppMethodBeat.o(86286);
        return renderTexture;
    }

    public final void ClearGLSL() {
        AppMethodBeat.i(86287);
        if (this.paramTEXTRUEID != -2000) {
            g.Sk(this.paramTEXTRUEID);
            this.paramTEXTRUEID = -2000;
        }
        super.ClearGLSL();
        AppMethodBeat.o(86287);
    }
}
