package ඓ.ῲ.K.ᕣ.ᕣ.ʬ;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.os.Build;
import android.util.Log;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import ඓ.ῲ.K.ᕣ.ᨨ.ゎ.AbstractC0976;

/* renamed from: ඓ.ῲ.K.ᕣ.ᕣ.ʬ.ᓆ  reason: contains not printable characters */
/* compiled from: TransformationUtils */
public final class C0868 {

    /* renamed from: ʬ  reason: contains not printable characters */
    public static final Set<String> f4107 = new HashSet(Arrays.asList("XT1085", "XT1092", "XT1093", "XT1094", "XT1095", "XT1096", "XT1097", "XT1098", "XT1031", "XT1028", "XT937C", "XT1032", "XT1008", "XT1033", "XT1035", "XT1034", "XT939G", "XT1039", "XT1040", "XT1042", "XT1045", "XT1063", "XT1064", "XT1068", "XT1069", "XT1072", "XT1077", "XT1078", "XT1079"));

    /* renamed from: ῲ  reason: contains not printable characters */
    public static final Paint f4108 = new Paint(7);

    /* renamed from: K  reason: contains not printable characters */
    public static final Paint f4109 = new Paint(6);

    /* renamed from: 㸾  reason: contains not printable characters */
    public static final Lock f4110 = (f4107.contains(Build.MODEL) ? new ReentrantLock() : new locks.LockC0869());

    /* renamed from: ඓ.ῲ.K.ᕣ.ᕣ.ʬ.ᓆ$K  reason: contains not printable characters */
    /* compiled from: TransformationUtils */
    public static final class locks.LockC0869 implements Lock {
        public void lock() {
        }

        @Override // java.util.concurrent.locks.Lock
        public void lockInterruptibly() throws InterruptedException {
        }

        public Condition newCondition() {
            throw new UnsupportedOperationException("Should not be called");
        }

        public boolean tryLock() {
            return true;
        }

        @Override // java.util.concurrent.locks.Lock
        public boolean tryLock(long j, TimeUnit timeUnit) throws InterruptedException {
            return true;
        }

        public void unlock() {
        }
    }

    static {
        new Paint(7);
        f4108.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    }

    /* renamed from: ʬ  reason: contains not printable characters */
    public static Bitmap m2504(AbstractC0976 r6, Bitmap bitmap, int i, int i2) {
        if (bitmap.getWidth() == i && bitmap.getHeight() == i2) {
            if (Log.isLoggable("TransformationUtils", 2)) {
                Log.v("TransformationUtils", "requested target size matches input, returning input");
            }
            return bitmap;
        }
        float min = Math.min(((float) i) / ((float) bitmap.getWidth()), ((float) i2) / ((float) bitmap.getHeight()));
        int round = Math.round(((float) bitmap.getWidth()) * min);
        int round2 = Math.round(((float) bitmap.getHeight()) * min);
        if (bitmap.getWidth() == round && bitmap.getHeight() == round2) {
            if (Log.isLoggable("TransformationUtils", 2)) {
                Log.v("TransformationUtils", "adjusted target size matches input, returning input");
            }
            return bitmap;
        }
        Bitmap r62 = r6.m2769((int) (((float) bitmap.getWidth()) * min), (int) (((float) bitmap.getHeight()) * min), m2506(bitmap));
        r62.setHasAlpha(bitmap.hasAlpha());
        if (Log.isLoggable("TransformationUtils", 2)) {
            Log.v("TransformationUtils", "request: " + i + "x" + i2);
            Log.v("TransformationUtils", "toFit:   " + bitmap.getWidth() + "x" + bitmap.getHeight());
            Log.v("TransformationUtils", "toReuse: " + r62.getWidth() + "x" + r62.getHeight());
            StringBuilder sb = new StringBuilder();
            sb.append("minPct:   ");
            sb.append(min);
            Log.v("TransformationUtils", sb.toString());
        }
        Matrix matrix = new Matrix();
        matrix.setScale(min, min);
        m2508(bitmap, r62, matrix);
        return r62;
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public static Bitmap m2505(AbstractC0976 r3, Bitmap bitmap, int i, int i2) {
        if (bitmap.getWidth() > i || bitmap.getHeight() > i2) {
            if (Log.isLoggable("TransformationUtils", 2)) {
                Log.v("TransformationUtils", "requested target size too big for input, fit centering instead");
            }
            return m2504(r3, bitmap, i, i2);
        }
        if (Log.isLoggable("TransformationUtils", 2)) {
            Log.v("TransformationUtils", "requested target size larger or equal to input, returning input");
        }
        return bitmap;
    }

    /* renamed from: K  reason: contains not printable characters */
    public static Bitmap m2507(AbstractC0976 r6, Bitmap bitmap, int i, int i2) {
        float f;
        float f2;
        if (bitmap.getWidth() == i && bitmap.getHeight() == i2) {
            return bitmap;
        }
        Matrix matrix = new Matrix();
        float f3 = 0.0f;
        if (bitmap.getWidth() * i2 > bitmap.getHeight() * i) {
            f2 = ((float) i2) / ((float) bitmap.getHeight());
            f = (((float) i) - (((float) bitmap.getWidth()) * f2)) * 0.5f;
        } else {
            f2 = ((float) i) / ((float) bitmap.getWidth());
            f3 = (((float) i2) - (((float) bitmap.getHeight()) * f2)) * 0.5f;
            f = 0.0f;
        }
        matrix.setScale(f2, f2);
        matrix.postTranslate((float) ((int) (f + 0.5f)), (float) ((int) (f3 + 0.5f)));
        Bitmap r62 = r6.m2769(i, i2, m2506(bitmap));
        r62.setHasAlpha(bitmap.hasAlpha());
        m2508(bitmap, r62, matrix);
        return r62;
    }

    /* renamed from: K  reason: contains not printable characters */
    public static Bitmap.Config m2506(Bitmap bitmap) {
        return bitmap.getConfig() != null ? bitmap.getConfig() : Bitmap.Config.ARGB_8888;
    }

    /* renamed from: K  reason: contains not printable characters */
    public static void m2508(Bitmap bitmap, Bitmap bitmap2, Matrix matrix) {
        f4110.lock();
        try {
            Canvas canvas = new Canvas(bitmap2);
            canvas.drawBitmap(bitmap, matrix, f4109);
            canvas.setBitmap(null);
        } finally {
            f4110.unlock();
        }
    }
}
