package ඓ.ῲ.K.ᕣ.ᕣ;

import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.graphics.ColorSpace;
import android.graphics.ImageDecoder;
import android.os.Build;
import android.util.Log;
import android.util.Size;
import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.load.PreferredColorSpace;
import com.bumptech.glide.load.resource.bitmap.DownsampleStrategy;
import java.io.IOException;
import ඓ.ῲ.K.ᕣ.AbstractC0853;
import ඓ.ῲ.K.ᕣ.C1121;
import ඓ.ῲ.K.ᕣ.ᕣ.ʬ.C0857;
import ඓ.ῲ.K.ᕣ.ᕣ.ʬ.C0859;
import ඓ.ῲ.K.ᕣ.ᕣ.ʬ.C0873;
import ඓ.ῲ.K.ᕣ.ᕣ.ʬ.C0891;
import ඓ.ῲ.K.ᕣ.ᨨ.AbstractC1027;
import ඓ.K.K.K.C1293;

/* renamed from: ඓ.ῲ.K.ᕣ.ᕣ.K  reason: contains not printable characters */
/* compiled from: ImageDecoderResourceDecoder */
public abstract class AbstractC0918<T> implements AbstractC0853<ImageDecoder.Source, T> {

    /* renamed from: K  reason: contains not printable characters */
    public final C0857 f4206 = C0857.m2481();

    /* renamed from: ඓ.ῲ.K.ᕣ.ᕣ.K$K  reason: contains not printable characters */
    /* compiled from: ImageDecoderResourceDecoder */
    public class C0919 implements ImageDecoder.OnHeaderDecodedListener {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final /* synthetic */ boolean f4207;

        /* renamed from: ඓ  reason: contains not printable characters */
        public final /* synthetic */ DownsampleStrategy f4208;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final /* synthetic */ int f4209;

        /* renamed from: K  reason: contains not printable characters */
        public final /* synthetic */ int f4211;

        /* renamed from: 㴹  reason: contains not printable characters */
        public final /* synthetic */ PreferredColorSpace f4212;

        /* renamed from: 㸾  reason: contains not printable characters */
        public final /* synthetic */ DecodeFormat f4213;

        /* renamed from: ඓ.ῲ.K.ᕣ.ᕣ.K$K$K  reason: contains not printable characters */
        /* compiled from: ImageDecoderResourceDecoder */
        public class C0920 implements ImageDecoder.OnPartialImageListener {
            public C0920(C0919 k) {
            }

            public boolean onPartialImage(ImageDecoder.DecodeException decodeException) {
                return false;
            }
        }

        public C0919(int i, int i2, boolean z, DecodeFormat decodeFormat, DownsampleStrategy downsampleStrategy, PreferredColorSpace preferredColorSpace) {
            this.f4211 = i;
            this.f4209 = i2;
            this.f4207 = z;
            this.f4213 = decodeFormat;
            this.f4208 = downsampleStrategy;
            this.f4212 = preferredColorSpace;
        }

        @SuppressLint({"Override"})
        public void onHeaderDecoded(ImageDecoder imageDecoder, ImageDecoder.ImageInfo imageInfo, ImageDecoder.Source source) {
            boolean z = true;
            if (AbstractC0918.this.f4206.m2483(this.f4211, this.f4209, this.f4207, false)) {
                imageDecoder.setAllocator(3);
            } else {
                imageDecoder.setAllocator(1);
            }
            if (this.f4213 == DecodeFormat.PREFER_RGB_565) {
                imageDecoder.setMemorySizePolicy(0);
            }
            imageDecoder.setOnPartialImageListener(new C0920(this));
            Size size = imageInfo.getSize();
            int i = this.f4211;
            if (i == Integer.MIN_VALUE) {
                i = size.getWidth();
            }
            int i2 = this.f4209;
            if (i2 == Integer.MIN_VALUE) {
                i2 = size.getHeight();
            }
            float r1 = this.f4208.m1317(size.getWidth(), size.getHeight(), i, i2);
            int round = Math.round(((float) size.getWidth()) * r1);
            int round2 = Math.round(((float) size.getHeight()) * r1);
            if (Log.isLoggable("ImageDecoder", 2)) {
                StringBuilder r4 = C1293.m3416("Resizing from [");
                r4.append(size.getWidth());
                r4.append("x");
                r4.append(size.getHeight());
                r4.append("] to [");
                r4.append(round);
                r4.append("x");
                r4.append(round2);
                r4.append("] scaleFactor: ");
                r4.append(r1);
                Log.v("ImageDecoder", r4.toString());
            }
            imageDecoder.setTargetSize(round, round2);
            int i3 = Build.VERSION.SDK_INT;
            if (i3 >= 28) {
                if (this.f4212 != PreferredColorSpace.DISPLAY_P3 || imageInfo.getColorSpace() == null || !imageInfo.getColorSpace().isWideGamut()) {
                    z = false;
                }
                imageDecoder.setTargetColorSpace(ColorSpace.get(z ? ColorSpace.Named.DISPLAY_P3 : ColorSpace.Named.SRGB));
            } else if (i3 >= 26) {
                imageDecoder.setTargetColorSpace(ColorSpace.get(ColorSpace.Named.SRGB));
            }
        }
    }

    /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, ඓ.ῲ.K.ᕣ.㸾] */
    @Override // ඓ.ῲ.K.ᕣ.AbstractC0853
    /* renamed from: K  reason: contains not printable characters */
    public boolean m2627(ImageDecoder.Source source, C1121 r2) throws IOException {
        return true;
    }

    /* JADX DEBUG: Multi-variable search result rejected for r13v0, resolved type: ඓ.ῲ.K.ᕣ.㸾 */
    /* JADX WARN: Multi-variable type inference failed */
    /* renamed from: K  reason: contains not printable characters */
    public final AbstractC1027<T> m2626(ImageDecoder.Source source, int i, int i2, C1121 r13) throws IOException {
        C0891 r0 = (C0891) this;
        Bitmap decodeBitmap = ImageDecoder.decodeBitmap(source, new C0919(i, i2, r13.m3002(C0873.f4118) != null && ((Boolean) r13.m3002(C0873.f4118)).booleanValue(), (DecodeFormat) r13.m3002(C0873.f4122), (DownsampleStrategy) r13.m3002(DownsampleStrategy.f2248), (PreferredColorSpace) r13.m3002(C0873.f4119)));
        if (Log.isLoggable("BitmapImageDecoder", 2)) {
            StringBuilder r1 = C1293.m3416("Decoded [");
            r1.append(decodeBitmap.getWidth());
            r1.append("x");
            r1.append(decodeBitmap.getHeight());
            r1.append("] for [");
            r1.append(i);
            r1.append("x");
            r1.append(i2);
            r1.append("]");
            Log.v("BitmapImageDecoder", r1.toString());
        }
        return new C0859(decodeBitmap, r0.f4146);
    }
}
