package defpackage;

import A4.d;
import android.content.Context;
import android.graphics.Bitmap;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.ScriptIntrinsicBlur;
import coil.size.Size;
import coil.transform.Transformation;
import kotlin.jvm.internal.o;

/* JADX INFO: loaded from: classes.dex */
public final class a implements Transformation {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Context f9222a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final float f9223b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final String f9224c;

    public a(Context context, float f6) {
        o.h(context, "context");
        this.f9222a = context;
        this.f9223b = f6;
        this.f9224c = a.class.getName() + '-' + f6;
    }

    @Override // coil.transform.Transformation
    public final String getCacheKey() {
        return this.f9224c;
    }

    @Override // coil.transform.Transformation
    public final Object transform(Bitmap bitmap, Size size, d dVar) {
        o.h(bitmap, "<this>");
        Context context = this.f9222a;
        o.h(context, "context");
        float f6 = this.f9223b;
        if (f6 < 1.0f) {
            return bitmap;
        }
        double dMin = Math.min(f6, 25.0d);
        float fMin = Math.min(400.0f / bitmap.getWidth(), 400.0f / bitmap.getHeight());
        Bitmap bitmapCreateScaledBitmap = Bitmap.createScaledBitmap(bitmap, L4.a.d0(bitmap.getWidth() * fMin), L4.a.d0(fMin * bitmap.getHeight()), true);
        o.g(bitmapCreateScaledBitmap, "createScaledBitmap(this, width, height, true)");
        RenderScript renderScriptCreate = RenderScript.create(context);
        Allocation allocationCreateFromBitmap = Allocation.createFromBitmap(renderScriptCreate, bitmapCreateScaledBitmap);
        Allocation allocationCreateTyped = Allocation.createTyped(renderScriptCreate, allocationCreateFromBitmap.getType());
        ScriptIntrinsicBlur scriptIntrinsicBlurCreate = ScriptIntrinsicBlur.create(renderScriptCreate, Element.U8_4(renderScriptCreate));
        scriptIntrinsicBlurCreate.setRadius((float) dMin);
        scriptIntrinsicBlurCreate.setInput(allocationCreateFromBitmap);
        scriptIntrinsicBlurCreate.forEach(allocationCreateTyped);
        Bitmap.Config config = bitmap.getConfig();
        Bitmap bitmapCreateBitmap = config != null ? Bitmap.createBitmap(bitmapCreateScaledBitmap.getWidth(), bitmapCreateScaledBitmap.getHeight(), config) : null;
        allocationCreateTyped.copyTo(bitmapCreateBitmap);
        allocationCreateFromBitmap.destroy();
        allocationCreateTyped.destroy();
        scriptIntrinsicBlurCreate.destroy();
        renderScriptCreate.destroy();
        return bitmapCreateBitmap == null ? bitmapCreateScaledBitmap : bitmapCreateBitmap;
    }
}
