得物.apk(点击下载) / b.java


package lf1;

import a.f;
import android.content.Context;
import android.opengl.GLES20;
import com.bytedance.labcv.effectsdk.BytedEffectConstants;
import com.meituan.robust.ChangeQuickRedirect;
import com.meituan.robust.PatchProxy;
import com.meituan.robust.PatchProxyResult;
import fd.n;
import java.io.File;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import kotlin.text.StringsKt__StringsKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import pf1.g;
import pf1.h;

/* compiled from: EffectHelper.kt */
public final class b {
    public static ChangeQuickRedirect changeQuickRedirect;

    /* renamed from: a  reason: collision with root package name */
    public a f35125a;
    public d b;

    /* renamed from: c  reason: collision with root package name */
    public h f35126c;
    public h d;
    public Queue<Runnable> e = new LinkedList();
    public boolean f = true;

    /* compiled from: EffectHelper.kt */
    public static final class a implements Runnable {
        public static ChangeQuickRedirect changeQuickRedirect;
        public final /* synthetic */ b b;

        /* renamed from: c  reason: collision with root package name */
        public final /* synthetic */ List f35127c;

        public a(b bVar, List list) {
            this.b = bVar;
            this.f35127c = list;
        }

        public final void run() {
            if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 335912, new Class[0], Void.TYPE).isSupported) {
                a aVar = this.b.f35125a;
                if (aVar != null) {
                    aVar.setComposerMode(1, 0);
                }
                a aVar2 = this.b.f35125a;
                if (aVar2 != null) {
                    aVar2.setComposerNodes((String[]) this.f35127c.toArray(new String[0]));
                }
            }
        }
    }

    /* renamed from: lf1.b$b  reason: collision with other inner class name */
    /* compiled from: EffectHelper.kt */
    public static final class RunnableC0548b implements Runnable {
        public static ChangeQuickRedirect changeQuickRedirect;
        public final /* synthetic */ b b;

        /* renamed from: c  reason: collision with root package name */
        public final /* synthetic */ String f35128c;

        public RunnableC0548b(b bVar, String str) {
            this.b = bVar;
            this.f35128c = str;
        }

        public final void run() {
            a aVar;
            if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 335913, new Class[0], Void.TYPE).isSupported && (aVar = this.b.f35125a) != null) {
                aVar.setSticker(this.f35128c);
            }
        }
    }

    public final void a(@NotNull Context context) {
        String str;
        String str2;
        String name;
        if (!PatchProxy.proxy(new Object[]{context}, this, changeQuickRedirect, false, 335903, new Class[]{Context.class}, Void.TYPE).isSupported) {
            if (this.b == null) {
                this.b = new d();
            }
            if (this.f35126c == null) {
                this.f35126c = new h();
            }
            if (this.d == null) {
                this.d = new h();
            }
            if (this.f35125a == null) {
                a aVar = new a();
                this.f35125a = aVar;
                if (!aVar.isInited()) {
                    g gVar = g.f37076a;
                    PatchProxyResult proxy = PatchProxy.proxy(new Object[]{context}, gVar, g.changeQuickRedirect, false, 336243, new Class[]{Context.class}, String.class);
                    if (proxy.isSupported) {
                        str = (String) proxy.result;
                    } else {
                        File t = tl.a.t((String) n.c("community_module", "community_cv_license_v2", String.class, "https://apk.poizon.com/duApp/Android_Config/license/cv/duapp_20210309_20210608_com.shizhuang.duapp_v1.0.2.licbag"));
                        str = t != null ? t.getAbsolutePath() : null;
                    }
                    if (str != null) {
                        a aVar2 = this.f35125a;
                        if (aVar2 != null) {
                            Context applicationContext = context.getApplicationContext();
                            PatchProxyResult proxy2 = PatchProxy.proxy(new Object[]{context}, gVar, g.changeQuickRedirect, false, 336242, new Class[]{Context.class}, String.class);
                            if (proxy2.isSupported) {
                                str2 = (String) proxy2.result;
                            } else {
                                File t4 = tl.a.t((String) n.c("community_module", "ModelResourceV2", String.class, "https://apk.poizon.com/duApp/Android_Config/Assets/resouces/150892cc40cf771a348e45fac826ac07.zip"));
                                if (t4 == null || (name = t4.getName()) == null) {
                                    str2 = "";
                                } else {
                                    String substring = name.substring(0, StringsKt__StringsKt.indexOf$default((CharSequence) name, ".", 0, false, 6, (Object) null));
                                    StringBuilder sb2 = new StringBuilder();
                                    sb2.append(gVar.b(context));
                                    str2 = f.g(sb2, File.separator, substring);
                                }
                            }
                            aVar2.init(applicationContext, str2, str);
                        }
                    } else {
                        return;
                    }
                }
            }
            while (!this.e.isEmpty()) {
                Runnable poll = this.e.poll();
                if (poll != null) {
                    poll.run();
                }
            }
        }
    }

    public final int b(int i, int i3, int i12, @Nullable BytedEffectConstants.Rotation rotation) {
        d dVar;
        Object[] objArr = {new Integer(i), new Integer(i3), new Integer(i12), rotation};
        ChangeQuickRedirect changeQuickRedirect2 = changeQuickRedirect;
        Class cls = Integer.TYPE;
        PatchProxyResult proxy = PatchProxy.proxy(objArr, this, changeQuickRedirect2, false, 335905, new Class[]{cls, cls, cls, BytedEffectConstants.Rotation.class}, cls);
        if (proxy.isSupported) {
            return ((Integer) proxy.result).intValue();
        }
        a aVar = this.f35125a;
        if (aVar == null || !aVar.isInited() || (dVar = this.b) == null) {
            return -1;
        }
        int b2 = dVar.b(i3, i12);
        if (this.f35125a.processTexture(i, b2, i3, i12, rotation, System.nanoTime())) {
            GLES20.glBindFramebuffer(36160, 0);
            return b2;
        } else if (this.f) {
            this.f35125a.processTexture(i, b2, i3, i12, rotation, System.nanoTime());
            GLES20.glBindFramebuffer(36160, 0);
            return b2;
        } else {
            this.f = false;
            return i;
        }
    }

    public final int c(int i, int i3, int i12, @Nullable BytedEffectConstants.Rotation rotation) {
        h hVar;
        Object[] objArr = {new Integer(i), new Integer(i3), new Integer(i12), rotation};
        ChangeQuickRedirect changeQuickRedirect2 = changeQuickRedirect;
        Class cls = Integer.TYPE;
        PatchProxyResult proxy = PatchProxy.proxy(objArr, this, changeQuickRedirect2, false, 335904, new Class[]{cls, cls, cls, BytedEffectConstants.Rotation.class}, cls);
        if (proxy.isSupported) {
            return ((Integer) proxy.result).intValue();
        }
        a aVar = this.f35125a;
        if (!(aVar == null || !aVar.isInited() || (hVar = this.f35126c) == null)) {
            int c5 = hVar.c(i, i3, i12);
            d dVar = this.b;
            if (dVar != null) {
                int b2 = dVar.b(i3, i12);
                if (this.f35125a.processTexture(c5, b2, i3, i12, rotation, System.nanoTime())) {
                    GLES20.glBindFramebuffer(36160, 0);
                    h hVar2 = this.d;
                    return hVar2 != null ? hVar2.c(b2, i3, i12) : i;
                } else if (this.f) {
                    this.f35125a.processTexture(c5, b2, i3, i12, rotation, System.nanoTime());
                    GLES20.glBindFramebuffer(36160, 0);
                    h hVar3 = this.d;
                    return hVar3 != null ? hVar3.c(b2, i3, i12) : i;
                } else {
                    this.f = false;
                    h hVar4 = this.d;
                    if (hVar4 != null) {
                        return hVar4.c(c5, i3, i12);
                    }
                }
            }
        }
        return i;
    }

    public final void d() {
        if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 335911, new Class[0], Void.TYPE).isSupported) {
            this.e.clear();
            a aVar = this.f35125a;
            if (aVar != null) {
                aVar.release();
            }
            d dVar = this.b;
            if (dVar != null && !PatchProxy.proxy(new Object[0], dVar, d.changeQuickRedirect, false, 335923, new Class[0], Void.TYPE).isSupported) {
                dVar.a();
            }
            h hVar = this.f35126c;
            if (hVar != null) {
                hVar.b();
            }
            h hVar2 = this.d;
            if (hVar2 != null) {
                hVar2.b();
            }
            this.f35125a = null;
            this.b = null;
            this.f35126c = null;
            this.d = null;
        }
    }

    public final boolean e(@NotNull List<String> list) {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[]{list}, this, changeQuickRedirect, false, 335907, new Class[]{List.class}, Boolean.TYPE);
        if (proxy.isSupported) {
            return ((Boolean) proxy.result).booleanValue();
        }
        a aVar = this.f35125a;
        if (aVar == null || !aVar.isInited()) {
            this.e.offer(new a(this, list));
            return true;
        }
        a aVar2 = this.f35125a;
        if (aVar2 != null) {
            aVar2.setComposerMode(1, 0);
        }
        a aVar3 = this.f35125a;
        if (aVar3 == null || aVar3.setComposerNodes((String[]) list.toArray(new String[0])) != 0) {
            return false;
        }
        return true;
    }

    public final void f(boolean z) {
        a aVar;
        if (!PatchProxy.proxy(new Object[]{new Byte(z ? (byte) 1 : 0)}, this, changeQuickRedirect, false, 335909, new Class[]{Boolean.TYPE}, Void.TYPE).isSupported && (aVar = this.f35125a) != null) {
            aVar.setPipeline(z);
        }
    }

    public final void g(@Nullable String str) {
        if (!PatchProxy.proxy(new Object[]{str}, this, changeQuickRedirect, false, 335906, new Class[]{String.class}, Void.TYPE).isSupported) {
            a aVar = this.f35125a;
            if (aVar == null || !aVar.isInited()) {
                this.e.offer(new RunnableC0548b(this, str));
                return;
            }
            a aVar2 = this.f35125a;
            if (aVar2 != null) {
                aVar2.setSticker(str);
            }
        }
    }
}