package r2;

import android.text.BoringLayout;
import android.text.Layout;
import android.text.TextPaint;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;

/* loaded from: classes.dex */
public final class z {

    /* renamed from: a, reason: collision with root package name */
    private final CharSequence f34425a;

    /* renamed from: b, reason: collision with root package name */
    private final TextPaint f34426b;

    /* renamed from: c, reason: collision with root package name */
    private final int f34427c;

    /* renamed from: d, reason: collision with root package name */
    private float f34428d = Float.NaN;

    /* renamed from: e, reason: collision with root package name */
    private float f34429e = Float.NaN;

    /* renamed from: f, reason: collision with root package name */
    private BoringLayout.Metrics f34430f;

    /* renamed from: g, reason: collision with root package name */
    private boolean f34431g;

    public z(CharSequence charSequence, TextPaint textPaint, int i10) {
        this.f34425a = charSequence;
        this.f34426b = textPaint;
        this.f34427c = i10;
    }

    public final BoringLayout.Metrics a() {
        if (!this.f34431g) {
            this.f34430f = k.f34349a.c(this.f34425a, this.f34426b, w0.k(this.f34427c));
            this.f34431g = true;
        }
        return this.f34430f;
    }

    public final float b() {
        boolean e10;
        if (!Float.isNaN(this.f34428d)) {
            return this.f34428d;
        }
        BoringLayout.Metrics a10 = a();
        float f10 = a10 != null ? a10.width : -1;
        if (f10 < BitmapDescriptorFactory.HUE_RED) {
            CharSequence charSequence = this.f34425a;
            f10 = (float) Math.ceil(Layout.getDesiredWidth(charSequence, 0, charSequence.length(), this.f34426b));
        }
        e10 = b0.e(f10, this.f34425a, this.f34426b);
        if (e10) {
            f10 += 0.5f;
        }
        this.f34428d = f10;
        return f10;
    }

    public final float c() {
        if (!Float.isNaN(this.f34429e)) {
            return this.f34429e;
        }
        float c10 = b0.c(this.f34425a, this.f34426b);
        this.f34429e = c10;
        return c10;
    }
}
