package vc;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Paint;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.ScriptIntrinsicBlur;

/* JADX INFO: loaded from: classes.dex */
public final class h {

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public Allocation f33804d;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Paint f33801a = new Paint(2);

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public int f33805e = -1;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public int f33806f = -1;

    public h(Context context) {
        RenderScript renderScriptCreate = RenderScript.create(context);
        this.f33802b = renderScriptCreate;
        this.f33803c = ScriptIntrinsicBlur.create(renderScriptCreate, Element.U8_4(renderScriptCreate));
    }

    public final void a(Bitmap bitmap, float f10) {
        RenderScript renderScript = this.f33802b;
        ScriptIntrinsicBlur scriptIntrinsicBlur = this.f33803c;
        try {
            Allocation allocationCreateFromBitmap = Allocation.createFromBitmap(renderScript, bitmap);
            if (bitmap.getHeight() != this.f33806f || bitmap.getWidth() != this.f33805e) {
                Allocation allocation = this.f33804d;
                if (allocation != null) {
                    allocation.destroy();
                }
                this.f33804d = Allocation.createTyped(renderScript, allocationCreateFromBitmap.getType());
                this.f33805e = bitmap.getWidth();
                this.f33806f = bitmap.getHeight();
            }
            scriptIntrinsicBlur.setRadius(Math.min(f10, 25.0f));
            scriptIntrinsicBlur.setInput(allocationCreateFromBitmap);
            scriptIntrinsicBlur.forEach(this.f33804d);
            this.f33804d.copyTo(bitmap);
            allocationCreateFromBitmap.destroy();
        } catch (Exception unused) {
        }
    }
}
