package com.lynx.tasm.behavior.ui;

import X.C4393QmU;
import X.C4394QmV;
import X.C4398QmZ;
import X.C4449QnO;
import X.C4460QnZ;
import X.QNL;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Build;
import com.bytedance.covode.number.Covode;
import com.lynx.react.bridge.ReadableArray;
import com.lynx.tasm.base.TraceEvent;
import com.lynx.tasm.behavior.ui.utils.BackgroundDrawable;

public class LynxFlattenUI extends LynxBaseUI {
    public float LIZ;
    public C4393QmU LIZIZ;
    public boolean LIZJ;

    static {
        Covode.recordClassIndex(46608);
    }

    public float getTranslationX() {
        return 0.0f;
    }

    public float getTranslationY() {
        return 0.0f;
    }

    public float getTranslationZ() {
        return 0.0f;
    }

    public boolean isFlatten() {
        return true;
    }

    public void onDrawingPositionChanged() {
        invalidate();
    }

    public void onAttach() {
        super.onAttach();
        invalidate();
    }

    public void invalidate() {
        this.LIZJ = false;
        if (this.mDrawParent != null) {
            this.mDrawParent.invalidate();
        }
    }

    public void requestLayout() {
        this.LIZJ = false;
        if (this.mDrawParent != null) {
            this.mDrawParent.requestLayout();
        }
    }

    public void measure() {
        for (LynxBaseUI measure : this.mChildren) {
            measure.measure();
        }
    }

    public int getInitialOverflowType() {
        if (!this.mContext.LJIILL) {
            return 1;
        }
        if (getTagName().equals("view") || getTagName().equals("component")) {
            return 0;
        }
        return 1;
    }

    public LynxFlattenUI(C4398QmZ qmZ) {
        this(qmZ, (byte) 0);
    }

    @QNL(LIZ = "opacity", LIZLLL = 1.0f)
    public void setAlpha(float f) {
        this.LIZ = f;
        invalidate();
    }

    @QNL(LIZ = "transform")
    public void setTransform(ReadableArray readableArray) {
        super.setTransform(readableArray);
        invalidate();
    }

    public void LIZJ(Canvas canvas) {
        BackgroundDrawable backgroundDrawable = this.mLynxBackground.LJ;
        if (backgroundDrawable != null) {
            backgroundDrawable.setBounds(0, 0, getWidth(), getHeight());
            backgroundDrawable.draw(canvas);
        }
    }

    public final void LIZ(Canvas canvas) {
        boolean z = this.LIZJ;
        this.LIZJ = true;
        if (this.LIZIZ == null || !canvas.isHardwareAccelerated()) {
            LIZIZ(canvas);
            return;
        }
        if (!z || !this.LIZIZ.LIZIZ()) {
            C4393QmU qmU = this.LIZIZ;
            int width = getWidth();
            int height = getHeight();
            int left = getLeft();
            int top = getTop();
            int i = left + width;
            int i2 = top + height;
            if (getOverflow() != 0) {
                Rect clipBounds = getClipBounds();
                i = clipBounds.right + left;
                i2 = clipBounds.bottom + top;
                left += clipBounds.left;
                top += clipBounds.top;
                width = i - left;
                height = i2 - top;
            }
            qmU.LIZ(left, top, i, i2);
            Canvas LIZ2 = qmU.LIZ(width, height);
            try {
                LIZ2.translate((float) (-left), (float) (-top));
                LIZIZ(LIZ2);
            } finally {
                qmU.LIZIZ(LIZ2);
            }
        }
        if (this.LIZIZ.LIZIZ()) {
            this.LIZIZ.LIZ(canvas);
        }
    }

    public final void LIZIZ(Canvas canvas) {
        LynxFlattenUI lynxFlattenUI = this;
        String str = lynxFlattenUI.getTagName() + ".flatten.draw";
        TraceEvent.LIZ(0, str);
        if (lynxFlattenUI.LIZ <= 0.0f) {
            TraceEvent.LIZIZ(0, str);
            return;
        }
        int left = lynxFlattenUI.getLeft();
        int top = lynxFlattenUI.getTop();
        int i = 0;
        Canvas canvas2 = canvas;
        if (lynxFlattenUI.LIZ >= 1.0f) {
            if ((left | top) == 0) {
                if (lynxFlattenUI.mTransformRaw != null) {
                    int save = canvas2.save();
                    lynxFlattenUI.LIZ(canvas2, false);
                    i = save;
                }
                lynxFlattenUI.LIZJ(canvas2);
                if (lynxFlattenUI.mTransformRaw != null) {
                    canvas2.restoreToCount(i);
                }
            } else {
                int save2 = canvas2.save();
                lynxFlattenUI.LIZ(canvas2, true);
                if (lynxFlattenUI.getOverflow() != 0) {
                    Rect boundRectForOverflow = lynxFlattenUI.getBoundRectForOverflow();
                    if (boundRectForOverflow != null) {
                        canvas2.clipRect(boundRectForOverflow);
                    }
                } else {
                    canvas2.clipRect(new Rect(0, 0, lynxFlattenUI.getWidth(), lynxFlattenUI.getHeight()));
                }
                lynxFlattenUI.LIZJ(canvas2);
                canvas2.restoreToCount(save2);
            }
        } else if ((left | top) == 0) {
            canvas2.saveLayerAlpha(0.0f, 0.0f, (float) lynxFlattenUI.getWidth(), (float) lynxFlattenUI.getHeight(), (int) (lynxFlattenUI.LIZ * 255.0f), 31);
            lynxFlattenUI.LIZ(canvas2, false);
            lynxFlattenUI.LIZJ(canvas2);
            canvas2.restore();
        } else {
            lynxFlattenUI.LIZ(canvas2, true);
            canvas2.saveLayerAlpha(0.0f, 0.0f, (float) lynxFlattenUI.getWidth(), (float) lynxFlattenUI.getHeight(), (int) (lynxFlattenUI.LIZ * 255.0f), 31);
            lynxFlattenUI.LIZJ(canvas2);
            canvas2.restore();
            canvas2.translate((float) (-left), (float) (-top));
        }
        TraceEvent.LIZIZ(0, str);
    }

    public void setSign(int i, String str) {
        super.setSign(i, str);
        if (!this.mContext.LJIILL) {
            return;
        }
        if (str.equals("view") || str.equals("component")) {
            this.mOverflow = 3;
        }
    }

    public LynxFlattenUI(C4398QmZ qmZ, byte b) {
        super(qmZ, (Object) null);
        C4393QmU qmV;
        this.LIZ = 1.0f;
        if (C4393QmU.LIZ) {
            if (Build.VERSION.SDK_INT >= 29) {
                qmV = new C4460QnZ();
            } else if (Build.VERSION.SDK_INT >= 23) {
                qmV = new C4449QnO();
            } else {
                qmV = new C4394QmV();
            }
            qmV.LIZ();
            this.LIZIZ = qmV;
        }
    }

    /* JADX WARNING: Can't fix incorrect switch cases order */
    /* JADX WARNING: Code restructure failed: missing block: B:33:0x00ce, code lost:
        switch(r0) {
            case 0: goto L_0x00ea;
            case 1: goto L_0x00e4;
            case 2: goto L_0x00de;
            case 3: goto L_0x00d8;
            case 4: goto L_0x00d2;
            default: goto L_0x00d1;
        };
     */
    /* JADX WARNING: Code restructure failed: missing block: B:34:0x00d2, code lost:
        r5.LIZLLL.preScale(1.0f, r3, r6, r4);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:35:0x00d8, code lost:
        r5.LIZLLL.preScale(r3, 1.0f, r6, r4);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:36:0x00de, code lost:
        r5.LIZLLL.preRotate(r3, r6, r4);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:37:0x00e4, code lost:
        r5.LIZLLL.preTranslate(0.0f, r3);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:38:0x00ea, code lost:
        r5.LIZLLL.preTranslate(r3, 0.0f);
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private void LIZ(android.graphics.Canvas r9, boolean r10) {
        /*
            r8 = this;
            X.QmO r2 = r8.mTransformOrigin
            int r0 = r8.getLatestWidth()
            float r1 = (float) r0
            int r0 = r8.getLatestWidth()
            float r0 = (float) r0
            X.QmP r2 = X.C4388QmP.LIZ(r2, r1, r0)
            java.util.List<X.Qm5> r4 = r8.mTransformRaw
            X.QmZ r0 = r8.mContext
            com.lynx.tasm.behavior.ui.UIBody r0 = r0.LJIIIIZZ
            int r0 = r0.getLatestWidth()
            float r3 = (float) r0
            X.QmZ r0 = r8.mContext
            com.lynx.tasm.behavior.ui.UIBody r0 = r0.LJIIIIZZ
            r0.getLatestHeight()
            int r0 = r8.getLatestWidth()
            float r1 = (float) r0
            int r0 = r8.getLatestHeight()
            float r0 = (float) r0
            X.QmP r5 = X.C4388QmP.LIZ(r4, r3, r1, r0)
            X.Qnk r0 = r8.mParent
            boolean r0 = r0 instanceof com.lynx.tasm.behavior.ui.UIShadowProxy
            if (r0 == 0) goto L_0x003d
            X.Qnk r0 = r8.mParent
            com.lynx.tasm.behavior.ui.UIShadowProxy r0 = (com.lynx.tasm.behavior.ui.UIShadowProxy) r0
            r0.LIZIZ()
        L_0x003d:
            if (r10 == 0) goto L_0x004c
            int r0 = r8.getLeft()
            float r1 = (float) r0
            int r0 = r8.getTop()
            float r0 = (float) r0
            r9.translate(r1, r0)
        L_0x004c:
            java.util.List<X.Qm5> r0 = r8.mTransformRaw
            if (r0 == 0) goto L_0x00f5
            if (r5 == 0) goto L_0x00f5
            float r6 = r2.LIZIZ
            float r4 = r2.LIZJ
            android.graphics.Matrix r0 = r5.LIZLLL
            if (r0 != 0) goto L_0x0061
            android.graphics.Matrix r0 = new android.graphics.Matrix
            r0.<init>()
            r5.LIZLLL = r0
        L_0x0061:
            android.graphics.Matrix r0 = r5.LIZLLL
            boolean r0 = r0.isIdentity()
            if (r0 == 0) goto L_0x00f0
            java.util.LinkedHashMap<java.lang.String, java.lang.Float> r0 = r5.LJ
            java.util.Set r0 = r0.keySet()
            java.util.Iterator r7 = r0.iterator()
        L_0x0073:
            boolean r0 = r7.hasNext()
            if (r0 == 0) goto L_0x00f0
            java.lang.Object r1 = r7.next()
            java.lang.String r1 = (java.lang.String) r1
            java.util.LinkedHashMap<java.lang.String, java.lang.Float> r0 = r5.LJ
            java.lang.Object r0 = r0.get(r1)
            java.lang.Float r0 = (java.lang.Float) r0
            float r3 = r0.floatValue()
            r1.hashCode()
            r0 = -1
            int r0 = r1.hashCode()
            switch(r0) {
                case -1721943862: goto L_0x00c1;
                case -1721943861: goto L_0x00b6;
                case -925180581: goto L_0x00ad;
                case -908189618: goto L_0x00a2;
                case -908189617: goto L_0x0097;
                default: goto L_0x0096;
            }
        L_0x0096:
            goto L_0x0073
        L_0x0097:
            java.lang.String r0 = "scaleY"
            boolean r0 = r1.equals(r0)
            if (r0 != 0) goto L_0x00a0
            goto L_0x0073
        L_0x00a0:
            r0 = 4
            goto L_0x00cb
        L_0x00a2:
            java.lang.String r0 = "scaleX"
            boolean r0 = r1.equals(r0)
            if (r0 != 0) goto L_0x00ab
            goto L_0x0073
        L_0x00ab:
            r0 = 3
            goto L_0x00cb
        L_0x00ad:
            java.lang.String r0 = "rotate"
            boolean r0 = r1.equals(r0)
            if (r0 != 0) goto L_0x00de
            goto L_0x0073
        L_0x00b6:
            java.lang.String r0 = "translateY"
            boolean r0 = r1.equals(r0)
            if (r0 != 0) goto L_0x00bf
            goto L_0x0073
        L_0x00bf:
            r0 = 1
            goto L_0x00cb
        L_0x00c1:
            java.lang.String r0 = "translateX"
            boolean r0 = r1.equals(r0)
            if (r0 != 0) goto L_0x00ca
            goto L_0x0073
        L_0x00ca:
            r0 = 0
        L_0x00cb:
            r2 = 1065353216(0x3f800000, float:1.0)
            r1 = 0
            switch(r0) {
                case 0: goto L_0x00ea;
                case 1: goto L_0x00e4;
                case 2: goto L_0x00de;
                case 3: goto L_0x00d8;
                case 4: goto L_0x00d2;
                default: goto L_0x00d1;
            }
        L_0x00d1:
            goto L_0x0073
        L_0x00d2:
            android.graphics.Matrix r0 = r5.LIZLLL
            r0.preScale(r2, r3, r6, r4)
            goto L_0x0073
        L_0x00d8:
            android.graphics.Matrix r0 = r5.LIZLLL
            r0.preScale(r3, r2, r6, r4)
            goto L_0x0073
        L_0x00de:
            android.graphics.Matrix r0 = r5.LIZLLL
            r0.preRotate(r3, r6, r4)
            goto L_0x0073
        L_0x00e4:
            android.graphics.Matrix r0 = r5.LIZLLL
            r0.preTranslate(r1, r3)
            goto L_0x0073
        L_0x00ea:
            android.graphics.Matrix r0 = r5.LIZLLL
            r0.preTranslate(r3, r1)
            goto L_0x0073
        L_0x00f0:
            android.graphics.Matrix r0 = r5.LIZLLL
            r9.concat(r0)
        L_0x00f5:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.lynx.tasm.behavior.ui.LynxFlattenUI.LIZ(android.graphics.Canvas, boolean):void");
    }

    /* JADX WARNING: Removed duplicated region for block: B:32:0x0099  */
    /* JADX WARNING: Removed duplicated region for block: B:35:0x00a7  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void LIZ(int r7, int r8, android.graphics.Rect r9) {
        /*
            r6 = this;
            r6.updateDrawingLayoutInfo(r7, r8, r9)
            android.graphics.Rect r2 = new android.graphics.Rect
            int r5 = r6.getLeft()
            int r4 = r6.getTop()
            int r3 = r6.getLeft()
            int r0 = r6.getWidth()
            int r3 = r3 + r0
            int r1 = r6.getTop()
            int r0 = r6.getHeight()
            int r1 = r1 + r0
            r2.<init>(r5, r4, r3, r1)
            int r3 = r6.getOverflow()
            r1 = r3 & 1
            r4 = 0
            r0 = 1
            if (r1 == 0) goto L_0x00cd
            r1 = 1
        L_0x002d:
            r0 = r3 & 2
            if (r0 == 0) goto L_0x0032
            r4 = 1
        L_0x0032:
            X.QmZ r0 = r6.mContext
            android.util.DisplayMetrics r3 = r0.LJIILIIL
            if (r1 == 0) goto L_0x0072
            if (r4 == 0) goto L_0x008a
            if (r9 != 0) goto L_0x00c6
            r2 = 0
        L_0x003d:
            java.util.List<com.lynx.tasm.behavior.ui.LynxBaseUI> r0 = r6.mChildren
            java.util.Iterator r5 = r0.iterator()
        L_0x0043:
            boolean r0 = r5.hasNext()
            if (r0 == 0) goto L_0x00d0
            java.lang.Object r4 = r5.next()
            com.lynx.tasm.behavior.ui.LynxBaseUI r4 = (com.lynx.tasm.behavior.ui.LynxBaseUI) r4
            int r3 = r4.getOriginLeft()
            int r3 = r3 + r7
            int r1 = r4.getOriginTop()
            int r1 = r1 + r8
            boolean r0 = r4.isFlatten()
            if (r0 != 0) goto L_0x0066
            r4.updateDrawingLayoutInfo(r3, r1, r2)
            r4.layout()
            goto L_0x0043
        L_0x0066:
            boolean r0 = r4.isFlatten()
            if (r0 == 0) goto L_0x0043
            com.lynx.tasm.behavior.ui.LynxFlattenUI r4 = (com.lynx.tasm.behavior.ui.LynxFlattenUI) r4
            r4.LIZ(r3, r1, r2)
            goto L_0x0043
        L_0x0072:
            if (r9 == 0) goto L_0x0097
            int r1 = r2.left
            int r0 = r9.left
            if (r1 <= r0) goto L_0x0087
            int r0 = r2.left
        L_0x007c:
            r2.left = r0
            int r1 = r2.right
            int r0 = r9.right
            if (r1 >= r0) goto L_0x00ca
            int r0 = r2.right
            goto L_0x0095
        L_0x0087:
            int r0 = r9.left
            goto L_0x007c
        L_0x008a:
            if (r9 != 0) goto L_0x00c6
            int r0 = r3.widthPixels
            int r0 = -r0
            r2.left = r0
            int r0 = r3.widthPixels
            int r0 = r0 * 2
        L_0x0095:
            r2.right = r0
        L_0x0097:
            if (r4 == 0) goto L_0x00a7
            if (r9 != 0) goto L_0x00bf
            int r0 = r3.heightPixels
            int r0 = -r0
            r2.top = r0
            int r0 = r3.heightPixels
            int r0 = r0 * 2
        L_0x00a4:
            r2.bottom = r0
            goto L_0x003d
        L_0x00a7:
            if (r9 == 0) goto L_0x003d
            int r1 = r2.top
            int r0 = r9.top
            if (r1 <= r0) goto L_0x00bc
            int r0 = r2.top
        L_0x00b1:
            r2.top = r0
            int r1 = r2.bottom
            int r0 = r9.bottom
            if (r1 >= r0) goto L_0x00c3
            int r0 = r2.bottom
            goto L_0x00a4
        L_0x00bc:
            int r0 = r9.top
            goto L_0x00b1
        L_0x00bf:
            int r0 = r9.top
            r2.top = r0
        L_0x00c3:
            int r0 = r9.bottom
            goto L_0x00a4
        L_0x00c6:
            int r0 = r9.left
            r2.left = r0
        L_0x00ca:
            int r0 = r9.right
            goto L_0x0095
        L_0x00cd:
            r1 = 0
            goto L_0x002d
        L_0x00d0:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.lynx.tasm.behavior.ui.LynxFlattenUI.LIZ(int, int, android.graphics.Rect):void");
    }

    public void setTransformData(float f, float f2, int[] iArr, float[] fArr) {
        super.setTransformData(f, f2, iArr, fArr);
        invalidate();
    }
}
