package o; 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.graphics.RectF; import android.os.Build; import android.util.Log; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.kofax.kmc.kui.uicontrols.Utility; import java.util.Arrays; import java.util.HashSet; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import org.bouncycastle.crypto.tls.CipherSuite; /* loaded from: classes.dex */ public final class JUv { private static final Paint b = new Paint(6); private static final Lock e; public static boolean a(int i) { switch (i) { case 2: case 3: case 4: case 5: case 6: case 7: case 8: return true; default: return false; } } public static int d(int i) { switch (i) { case 3: case 4: return CipherSuite.TLS_DHE_PSK_WITH_NULL_SHA256; case 5: case 6: return 90; case 7: case 8: return 270; default: return 0; } } static { new Paint(7); e = new HashSet(Arrays.asList("XT1085", "XT1092", "XT1093", "XT1094", "XT1095", "XT1096", "XT1097", "XT1098", "XT1031", "XT1028", "XT937C", Utility.MOTO_G_MODEL, "XT1008", "XT1033", "XT1035", Utility.MOTO_G_1034, "XT939G", "XT1039", "XT1040", "XT1042", "XT1045", "XT1063", "XT1064", "XT1068", "XT1069", "XT1072", "XT1077", "XT1078", "XT1079")).contains(Build.MODEL) ? new ReentrantLock() : new RVV(); new Paint(7).setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); } public static Bitmap Fa_(sqY sqy, Bitmap bitmap, int i, int i2) { float width; float height; if (bitmap.getWidth() == i && bitmap.getHeight() == i2) { return bitmap; } Matrix matrix = new Matrix(); int width2 = bitmap.getWidth() * i2; int height2 = bitmap.getHeight() * i; float f = BitmapDescriptorFactory.HUE_RED; if (width2 > height2) { width = i2 / bitmap.getHeight(); f = (i - (bitmap.getWidth() * width)) * 0.5f; height = 0.0f; } else { width = i / bitmap.getWidth(); height = (i2 - (bitmap.getHeight() * width)) * 0.5f; } matrix.setScale(width, width); matrix.postTranslate((int) (f + 0.5f), (int) (height + 0.5f)); Bitmap Ea_ = sqy.Ea_(i, i2, bitmap.getConfig() != null ? bitmap.getConfig() : Bitmap.Config.ARGB_8888); Ea_.setHasAlpha(bitmap.hasAlpha()); EZ_(bitmap, Ea_, matrix); return Ea_; } public static Bitmap Fc_(sqY sqy, Bitmap bitmap, int i, int i2) { if (bitmap.getWidth() == i && bitmap.getHeight() == i2) { return bitmap; } float min = Math.min(i / bitmap.getWidth(), i2 / bitmap.getHeight()); int round = Math.round(bitmap.getWidth() * min); int round2 = Math.round(bitmap.getHeight() * min); if (bitmap.getWidth() == round && bitmap.getHeight() == round2) { return bitmap; } Bitmap Ea_ = sqy.Ea_((int) (bitmap.getWidth() * min), (int) (bitmap.getHeight() * min), bitmap.getConfig() != null ? bitmap.getConfig() : Bitmap.Config.ARGB_8888); Ea_.setHasAlpha(bitmap.hasAlpha()); if (Log.isLoggable("TransformationUtils", 2)) { bitmap.getWidth(); bitmap.getHeight(); Ea_.getWidth(); Ea_.getHeight(); } Matrix matrix = new Matrix(); matrix.setScale(min, min); EZ_(bitmap, Ea_, matrix); return Ea_; } public static Bitmap Fb_(sqY sqy, Bitmap bitmap, int i, int i2) { return (bitmap.getWidth() > i || bitmap.getHeight() > i2) ? Fc_(sqy, bitmap, i, i2) : bitmap; } public static Bitmap Fd_(sqY sqy, Bitmap bitmap, int i) { if (!a(i)) { return bitmap; } Matrix matrix = new Matrix(); switch (i) { case 2: matrix.setScale(-1.0f, 1.0f); break; case 3: matrix.setRotate(180.0f); break; case 4: matrix.setRotate(180.0f); matrix.postScale(-1.0f, 1.0f); break; case 5: matrix.setRotate(90.0f); matrix.postScale(-1.0f, 1.0f); break; case 6: matrix.setRotate(90.0f); break; case 7: matrix.setRotate(-90.0f); matrix.postScale(-1.0f, 1.0f); break; case 8: matrix.setRotate(-90.0f); break; } RectF rectF = new RectF(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, bitmap.getWidth(), bitmap.getHeight()); matrix.mapRect(rectF); Bitmap Ea_ = sqy.Ea_(Math.round(rectF.width()), Math.round(rectF.height()), bitmap.getConfig() != null ? bitmap.getConfig() : Bitmap.Config.ARGB_8888); matrix.postTranslate(-rectF.left, -rectF.top); Ea_.setHasAlpha(bitmap.hasAlpha()); EZ_(bitmap, Ea_, matrix); return Ea_; } private static void EZ_(Bitmap bitmap, Bitmap bitmap2, Matrix matrix) { Lock lock = e; lock.lock(); try { Canvas canvas = new Canvas(bitmap2); canvas.drawBitmap(bitmap, matrix, b); canvas.setBitmap(null); lock.unlock(); } catch (Throwable th) { e.unlock(); throw th; } } /* loaded from: classes.dex */ static final class RVV implements Lock { @Override // java.util.concurrent.locks.Lock public final void lock() { } @Override // java.util.concurrent.locks.Lock public final void lockInterruptibly() throws InterruptedException { } @Override // java.util.concurrent.locks.Lock public final boolean tryLock() { return true; } @Override // java.util.concurrent.locks.Lock public final boolean tryLock(long j, TimeUnit timeUnit) throws InterruptedException { return true; } @Override // java.util.concurrent.locks.Lock public final void unlock() { } RVV() { } @Override // java.util.concurrent.locks.Lock public final Condition newCondition() { throw new UnsupportedOperationException("Should not be called"); } } public static Lock d() { return e; } }