package defpackage;

import android.graphics.Bitmap;
import android.os.Build;
import android.util.Log;
import j$.util.DesugarCollections;
import j$.util.Objects;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/* JADX INFO: renamed from: ᵪᵺᵧʝ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C3936 implements InterfaceC5397 {

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public static final Bitmap.Config f15030 = Bitmap.Config.ARGB_8888;

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final C4642 f15031;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public final ʻﾞ f15032;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public final Set f15033;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public final long f15034;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public long f15035;

    public C3936(long j) {
        C4642 c4642 = new C4642();
        HashSet hashSet = new HashSet(Arrays.asList(Bitmap.Config.values()));
        hashSet.add(null);
        if (Build.VERSION.SDK_INT >= 26) {
            hashSet.remove(Bitmap.Config.HARDWARE);
        }
        Set setUnmodifiableSet = DesugarCollections.unmodifiableSet(hashSet);
        this.f15034 = j;
        this.f15031 = c4642;
        this.f15033 = setUnmodifiableSet;
        this.f15032 = new ʻﾞ();
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final synchronized Bitmap m8667(int i, int i2, Bitmap.Config config) {
        Bitmap bitmapM9773;
        try {
            if (Build.VERSION.SDK_INT >= 26 && config == Bitmap.Config.HARDWARE) {
                throw new IllegalArgumentException("Cannot create a mutable Bitmap with config: " + config + ". Consider setting Downsampler#ALLOW_HARDWARE_CONFIG to false in your RequestOptions and/or in GlideBuilder.setDefaultRequestOptions");
            }
            bitmapM9773 = this.f15031.m9773(i, i2, config != null ? config : f15030);
            if (bitmapM9773 != null) {
                long j = this.f15035;
                this.f15031.getClass();
                this.f15035 = j - ((long) ᵱˉˈ.ˊᵨᵧ(bitmapM9773));
                this.f15032.getClass();
                bitmapM9773.setHasAlpha(true);
                bitmapM9773.setPremultiplied(true);
            } else if (Log.isLoggable("LruBitmapPool", 3)) {
                this.f15031.getClass();
                C4642.m9772(ᵱˉˈ.ˌᴵ(config) * i * i2, config);
            }
            if (Log.isLoggable("LruBitmapPool", 2)) {
                this.f15031.getClass();
                C4642.m9772(ᵱˉˈ.ˌᴵ(config) * i * i2, config);
            }
            if (Log.isLoggable("LruBitmapPool", 2)) {
                Objects.toString(this.f15031);
            }
        } catch (Throwable th) {
            throw th;
        }
        return bitmapM9773;
    }

    @Override // defpackage.InterfaceC5397
    /* JADX INFO: renamed from: ˉᵲ */
    public final void mo8260() {
        Log.isLoggable("LruBitmapPool", 3);
        m8668(0L);
    }

    @Override // defpackage.InterfaceC5397
    /* JADX INFO: renamed from: ˊᵙᵾᵲ */
    public final void mo8261(int i) {
        Log.isLoggable("LruBitmapPool", 3);
        if (i >= 40 || i >= 20) {
            mo8260();
        } else if (i >= 20 || i == 15) {
            m8668(this.f15034 / 2);
        }
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final synchronized void m8668(long j) {
        while (this.f15035 > j) {
            C4642 c4642 = this.f15031;
            Bitmap bitmap = (Bitmap) c4642.f17646.m2773();
            if (bitmap != null) {
                c4642.m9775(Integer.valueOf(ᵱˉˈ.ˊᵨᵧ(bitmap)), bitmap);
            }
            if (bitmap == null) {
                if (Log.isLoggable("LruBitmapPool", 5)) {
                    Objects.toString(this.f15031);
                }
                this.f15035 = 0L;
                return;
            }
            this.f15032.getClass();
            long j2 = this.f15035;
            this.f15031.getClass();
            this.f15035 = j2 - ((long) ᵱˉˈ.ˊᵨᵧ(bitmap));
            if (Log.isLoggable("LruBitmapPool", 3)) {
                this.f15031.getClass();
                C4642.m9772(ᵱˉˈ.ˊᵨᵧ(bitmap), bitmap.getConfig());
            }
            if (Log.isLoggable("LruBitmapPool", 2)) {
                Objects.toString(this.f15031);
            }
            bitmap.recycle();
        }
    }

    @Override // defpackage.InterfaceC5397
    /* JADX INFO: renamed from: ᵨᵣ */
    public final synchronized void mo7363(Bitmap bitmap) {
        try {
            if (bitmap == null) {
                throw new NullPointerException("Bitmap must not be null");
            }
            if (bitmap.isRecycled()) {
                throw new IllegalStateException("Cannot pool recycled bitmap");
            }
            if (bitmap.isMutable()) {
                this.f15031.getClass();
                if (ᵱˉˈ.ˊᵨᵧ(bitmap) <= this.f15034 && this.f15033.contains(bitmap.getConfig())) {
                    this.f15031.getClass();
                    int i = ᵱˉˈ.ˊᵨᵧ(bitmap);
                    this.f15031.m9774(bitmap);
                    this.f15032.getClass();
                    this.f15035 += (long) i;
                    if (Log.isLoggable("LruBitmapPool", 2)) {
                        this.f15031.getClass();
                        C4642.m9772(ᵱˉˈ.ˊᵨᵧ(bitmap), bitmap.getConfig());
                    }
                    if (Log.isLoggable("LruBitmapPool", 2)) {
                        Objects.toString(this.f15031);
                    }
                    m8668(this.f15034);
                    return;
                }
            }
            if (Log.isLoggable("LruBitmapPool", 2)) {
                this.f15031.getClass();
                C4642.m9772(ᵱˉˈ.ˊᵨᵧ(bitmap), bitmap.getConfig());
                bitmap.isMutable();
                this.f15033.contains(bitmap.getConfig());
            }
            bitmap.recycle();
        } catch (Throwable th) {
            throw th;
        }
    }

    @Override // defpackage.InterfaceC5397
    /* JADX INFO: renamed from: ᵱʡˏ */
    public final Bitmap mo8269(int i, int i2, Bitmap.Config config) {
        Bitmap bitmapM8667 = m8667(i, i2, config);
        if (bitmapM8667 != null) {
            bitmapM8667.eraseColor(0);
            return bitmapM8667;
        }
        if (config == null) {
            config = f15030;
        }
        return Bitmap.createBitmap(i, i2, config);
    }

    @Override // defpackage.InterfaceC5397
    /* JADX INFO: renamed from: ᵲᵶᵳˈ */
    public final Bitmap mo8270(int i, int i2, Bitmap.Config config) {
        Bitmap bitmapM8667 = m8667(i, i2, config);
        if (bitmapM8667 != null) {
            return bitmapM8667;
        }
        if (config == null) {
            config = f15030;
        }
        return Bitmap.createBitmap(i, i2, config);
    }
}
