package p3; import android.content.Context; import android.content.res.ColorStateList; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.Matrix; import android.graphics.Outline; import android.graphics.Paint; import android.graphics.Path; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Region; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import p3.k; import p3.l; import p3.m; import r.q; /* loaded from: classes2.dex */ public class g extends Drawable implements q, n { /* renamed from: v, reason: collision with root package name */ private static final Paint f13121v = new Paint(1); /* renamed from: a, reason: collision with root package name */ private c f13122a; /* renamed from: b, reason: collision with root package name */ private final m.g[] f13123b; /* renamed from: c, reason: collision with root package name */ private final m.g[] f13124c; /* renamed from: d, reason: collision with root package name */ private boolean f13125d; /* renamed from: e, reason: collision with root package name */ private final Matrix f13126e; /* renamed from: f, reason: collision with root package name */ private final Path f13127f; /* renamed from: g, reason: collision with root package name */ private final Path f13128g; /* renamed from: h, reason: collision with root package name */ private final RectF f13129h; /* renamed from: i, reason: collision with root package name */ private final RectF f13130i; /* renamed from: j, reason: collision with root package name */ private final Region f13131j; /* renamed from: k, reason: collision with root package name */ private final Region f13132k; /* renamed from: l, reason: collision with root package name */ private k f13133l; /* renamed from: m, reason: collision with root package name */ private final Paint f13134m; /* renamed from: n, reason: collision with root package name */ private final Paint f13135n; /* renamed from: o, reason: collision with root package name */ private final o3.a f13136o; /* renamed from: p, reason: collision with root package name */ private final l.a f13137p; /* renamed from: q, reason: collision with root package name */ private final l f13138q; /* renamed from: r, reason: collision with root package name */ private PorterDuffColorFilter f13139r; /* renamed from: s, reason: collision with root package name */ private PorterDuffColorFilter f13140s; /* renamed from: t, reason: collision with root package name */ private Rect f13141t; /* renamed from: u, reason: collision with root package name */ private final RectF f13142u; class a implements l.a { a() { } @Override // p3.l.a public void a(m mVar, Matrix matrix, int i10) { g.this.f13124c[i10] = mVar.e(matrix); } @Override // p3.l.a public void b(m mVar, Matrix matrix, int i10) { g.this.f13123b[i10] = mVar.e(matrix); } } class b implements k.c { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ float f13144a; b(float f10) { this.f13144a = f10; } @Override // p3.k.c public p3.c a(p3.c cVar) { return cVar instanceof i ? cVar : new p3.b(this.f13144a, cVar); } } /* synthetic */ g(c cVar, a aVar) { this(cVar); } private float B() { if (I()) { return this.f13135n.getStrokeWidth() / 2.0f; } return 0.0f; } private boolean G() { c cVar = this.f13122a; int i10 = cVar.f13162q; return i10 != 1 && cVar.f13163r > 0 && (i10 == 2 || P()); } private boolean H() { Paint.Style style = this.f13122a.f13167v; return style == Paint.Style.FILL_AND_STROKE || style == Paint.Style.FILL; } private boolean I() { Paint.Style style = this.f13122a.f13167v; return (style == Paint.Style.FILL_AND_STROKE || style == Paint.Style.STROKE) && this.f13135n.getStrokeWidth() > 0.0f; } private void K() { super.invalidateSelf(); } private static int N(int i10, int i11) { return (i10 * (i11 + (i11 >>> 7))) >>> 8; } private void O(Canvas canvas) { canvas.translate(y(), z()); } private boolean P() { return (M() || this.f13127f.isConvex()) ? false : true; } private boolean Z(int[] iArr) { boolean z10; int color; int colorForState; int color2; int colorForState2; if (this.f13122a.f13149d == null || color2 == (colorForState2 = this.f13122a.f13149d.getColorForState(iArr, (color2 = this.f13134m.getColor())))) { z10 = false; } else { this.f13134m.setColor(colorForState2); z10 = true; } if (this.f13122a.f13150e == null || color == (colorForState = this.f13122a.f13150e.getColorForState(iArr, (color = this.f13135n.getColor())))) { return z10; } this.f13135n.setColor(colorForState); return true; } private boolean a0() { PorterDuffColorFilter porterDuffColorFilter = this.f13139r; PorterDuffColorFilter porterDuffColorFilter2 = this.f13140s; c cVar = this.f13122a; this.f13139r = j(cVar.f13152g, cVar.f13153h, this.f13134m, true); c cVar2 = this.f13122a; this.f13140s = j(cVar2.f13151f, cVar2.f13153h, this.f13135n, false); c cVar3 = this.f13122a; if (cVar3.f13166u) { this.f13136o.d(cVar3.f13152g.getColorForState(getState(), 0)); } return (y.c.a(porterDuffColorFilter, this.f13139r) && y.c.a(porterDuffColorFilter2, this.f13140s)) ? false : true; } private void b0() { float F = F(); this.f13122a.f13163r = (int) Math.ceil(0.75f * F); this.f13122a.f13164s = (int) Math.ceil(F * 0.25f); a0(); K(); } private PorterDuffColorFilter e(Paint paint, boolean z10) { int color; int k10; if (!z10 || (k10 = k((color = paint.getColor()))) == color) { return null; } return new PorterDuffColorFilter(k10, PorterDuff.Mode.SRC_IN); } private void f(RectF rectF, Path path) { g(rectF, path); if (this.f13122a.f13155j != 1.0f) { this.f13126e.reset(); Matrix matrix = this.f13126e; float f10 = this.f13122a.f13155j; matrix.setScale(f10, f10, rectF.width() / 2.0f, rectF.height() / 2.0f); path.transform(this.f13126e); } path.computeBounds(this.f13142u, true); } private void h() { k x10 = A().x(new b(-B())); this.f13133l = x10; this.f13138q.d(x10, this.f13122a.f13156k, u(), this.f13128g); } private PorterDuffColorFilter i(ColorStateList colorStateList, PorterDuff.Mode mode, boolean z10) { int colorForState = colorStateList.getColorForState(getState(), 0); if (z10) { colorForState = k(colorForState); } return new PorterDuffColorFilter(colorForState, mode); } private PorterDuffColorFilter j(ColorStateList colorStateList, PorterDuff.Mode mode, Paint paint, boolean z10) { return (colorStateList == null || mode == null) ? e(paint, z10) : i(colorStateList, mode, z10); } private int k(int i10) { float F = F() + x(); j3.a aVar = this.f13122a.f13147b; return aVar != null ? aVar.c(i10, F) : i10; } public static g l(Context context, float f10) { int b10 = g3.a.b(context, c3.a.f3454j, g.class.getSimpleName()); g gVar = new g(); gVar.J(context); gVar.R(ColorStateList.valueOf(b10)); gVar.Q(f10); return gVar; } private void m(Canvas canvas) { if (this.f13122a.f13164s != 0) { canvas.drawPath(this.f13127f, this.f13136o.c()); } for (int i10 = 0; i10 < 4; i10++) { this.f13123b[i10].b(this.f13136o, this.f13122a.f13163r, canvas); this.f13124c[i10].b(this.f13136o, this.f13122a.f13163r, canvas); } int y10 = y(); int z10 = z(); canvas.translate(-y10, -z10); canvas.drawPath(this.f13127f, f13121v); canvas.translate(y10, z10); } private void n(Canvas canvas) { p(canvas, this.f13134m, this.f13127f, this.f13122a.f13146a, t()); } private void p(Canvas canvas, Paint paint, Path path, k kVar, RectF rectF) { if (!kVar.u(rectF)) { canvas.drawPath(path, paint); } else { float a10 = kVar.t().a(rectF); canvas.drawRoundRect(rectF, a10, a10, paint); } } private void q(Canvas canvas) { p(canvas, this.f13135n, this.f13128g, this.f13133l, u()); } private RectF u() { RectF t10 = t(); float B = B(); this.f13130i.set(t10.left + B, t10.top + B, t10.right - B, t10.bottom - B); return this.f13130i; } public k A() { return this.f13122a.f13146a; } public float C() { return this.f13122a.f13146a.r().a(t()); } public float D() { return this.f13122a.f13146a.t().a(t()); } public float E() { return this.f13122a.f13161p; } public float F() { return v() + E(); } public void J(Context context) { this.f13122a.f13147b = new j3.a(context); b0(); } public boolean L() { j3.a aVar = this.f13122a.f13147b; return aVar != null && aVar.d(); } public boolean M() { return this.f13122a.f13146a.u(t()); } public void Q(float f10) { c cVar = this.f13122a; if (cVar.f13160o != f10) { cVar.f13160o = f10; b0(); } } public void R(ColorStateList colorStateList) { c cVar = this.f13122a; if (cVar.f13149d != colorStateList) { cVar.f13149d = colorStateList; onStateChange(getState()); } } public void S(float f10) { c cVar = this.f13122a; if (cVar.f13156k != f10) { cVar.f13156k = f10; this.f13125d = true; invalidateSelf(); } } public void T(int i10, int i11, int i12, int i13) { c cVar = this.f13122a; if (cVar.f13154i == null) { cVar.f13154i = new Rect(); } this.f13122a.f13154i.set(i10, i11, i12, i13); this.f13141t = this.f13122a.f13154i; invalidateSelf(); } public void U(float f10) { c cVar = this.f13122a; if (cVar.f13159n != f10) { cVar.f13159n = f10; b0(); } } public void V(float f10, int i10) { Y(f10); X(ColorStateList.valueOf(i10)); } public void W(float f10, ColorStateList colorStateList) { Y(f10); X(colorStateList); } public void X(ColorStateList colorStateList) { c cVar = this.f13122a; if (cVar.f13150e != colorStateList) { cVar.f13150e = colorStateList; onStateChange(getState()); } } public void Y(float f10) { this.f13122a.f13157l = f10; invalidateSelf(); } @Override // android.graphics.drawable.Drawable public void draw(Canvas canvas) { this.f13134m.setColorFilter(this.f13139r); int alpha = this.f13134m.getAlpha(); this.f13134m.setAlpha(N(alpha, this.f13122a.f13158m)); this.f13135n.setColorFilter(this.f13140s); this.f13135n.setStrokeWidth(this.f13122a.f13157l); int alpha2 = this.f13135n.getAlpha(); this.f13135n.setAlpha(N(alpha2, this.f13122a.f13158m)); if (this.f13125d) { h(); f(t(), this.f13127f); this.f13125d = false; } if (G()) { canvas.save(); O(canvas); int width = (int) (this.f13142u.width() - getBounds().width()); int height = (int) (this.f13142u.height() - getBounds().height()); Bitmap createBitmap = Bitmap.createBitmap(((int) this.f13142u.width()) + (this.f13122a.f13163r * 2) + width, ((int) this.f13142u.height()) + (this.f13122a.f13163r * 2) + height, Bitmap.Config.ARGB_8888); Canvas canvas2 = new Canvas(createBitmap); float f10 = (getBounds().left - this.f13122a.f13163r) - width; float f11 = (getBounds().top - this.f13122a.f13163r) - height; canvas2.translate(-f10, -f11); m(canvas2); canvas.drawBitmap(createBitmap, f10, f11, (Paint) null); createBitmap.recycle(); canvas.restore(); } if (H()) { n(canvas); } if (I()) { q(canvas); } this.f13134m.setAlpha(alpha); this.f13135n.setAlpha(alpha2); } protected final void g(RectF rectF, Path path) { l lVar = this.f13138q; c cVar = this.f13122a; lVar.e(cVar.f13146a, cVar.f13156k, rectF, this.f13137p, path); } @Override // android.graphics.drawable.Drawable public Drawable.ConstantState getConstantState() { return this.f13122a; } @Override // android.graphics.drawable.Drawable public int getOpacity() { return -3; } @Override // android.graphics.drawable.Drawable public void getOutline(Outline outline) { if (this.f13122a.f13162q == 2) { return; } if (M()) { outline.setRoundRect(getBounds(), C()); } else { f(t(), this.f13127f); if (this.f13127f.isConvex()) { outline.setConvexPath(this.f13127f); } } } @Override // android.graphics.drawable.Drawable public boolean getPadding(Rect rect) { Rect rect2 = this.f13141t; if (rect2 == null) { return super.getPadding(rect); } rect.set(rect2); return true; } @Override // android.graphics.drawable.Drawable public Region getTransparentRegion() { this.f13131j.set(getBounds()); f(t(), this.f13127f); this.f13132k.setPath(this.f13127f, this.f13131j); this.f13131j.op(this.f13132k, Region.Op.DIFFERENCE); return this.f13131j; } @Override // android.graphics.drawable.Drawable public void invalidateSelf() { this.f13125d = true; super.invalidateSelf(); } @Override // android.graphics.drawable.Drawable public boolean isStateful() { ColorStateList colorStateList; ColorStateList colorStateList2; ColorStateList colorStateList3; ColorStateList colorStateList4; return super.isStateful() || ((colorStateList = this.f13122a.f13152g) != null && colorStateList.isStateful()) || (((colorStateList2 = this.f13122a.f13151f) != null && colorStateList2.isStateful()) || (((colorStateList3 = this.f13122a.f13150e) != null && colorStateList3.isStateful()) || ((colorStateList4 = this.f13122a.f13149d) != null && colorStateList4.isStateful()))); } @Override // android.graphics.drawable.Drawable public Drawable mutate() { this.f13122a = new c(this.f13122a); return this; } protected void o(Canvas canvas, Paint paint, Path path, RectF rectF) { p(canvas, paint, path, this.f13122a.f13146a, rectF); } @Override // android.graphics.drawable.Drawable protected void onBoundsChange(Rect rect) { this.f13125d = true; super.onBoundsChange(rect); } @Override // android.graphics.drawable.Drawable, com.google.android.material.internal.e.b protected boolean onStateChange(int[] iArr) { boolean z10 = Z(iArr) || a0(); if (z10) { invalidateSelf(); } return z10; } public float r() { return this.f13122a.f13146a.j().a(t()); } public float s() { return this.f13122a.f13146a.l().a(t()); } @Override // android.graphics.drawable.Drawable public void setAlpha(int i10) { c cVar = this.f13122a; if (cVar.f13158m != i10) { cVar.f13158m = i10; K(); } } @Override // android.graphics.drawable.Drawable public void setColorFilter(ColorFilter colorFilter) { this.f13122a.f13148c = colorFilter; K(); } @Override // p3.n public void setShapeAppearanceModel(k kVar) { this.f13122a.f13146a = kVar; invalidateSelf(); } @Override // android.graphics.drawable.Drawable public void setTint(int i10) { setTintList(ColorStateList.valueOf(i10)); } @Override // android.graphics.drawable.Drawable public void setTintList(ColorStateList colorStateList) { this.f13122a.f13152g = colorStateList; a0(); K(); } @Override // android.graphics.drawable.Drawable public void setTintMode(PorterDuff.Mode mode) { c cVar = this.f13122a; if (cVar.f13153h != mode) { cVar.f13153h = mode; a0(); K(); } } protected RectF t() { Rect bounds = getBounds(); this.f13129h.set(bounds.left, bounds.top, bounds.right, bounds.bottom); return this.f13129h; } public float v() { return this.f13122a.f13160o; } public ColorStateList w() { return this.f13122a.f13149d; } public float x() { return this.f13122a.f13159n; } public int y() { c cVar = this.f13122a; return (int) (cVar.f13164s * Math.sin(Math.toRadians(cVar.f13165t))); } public int z() { c cVar = this.f13122a; return (int) (cVar.f13164s * Math.cos(Math.toRadians(cVar.f13165t))); } public g() { this(new k()); } public g(Context context, AttributeSet attributeSet, int i10, int i11) { this(k.e(context, attributeSet, i10, i11).m()); } public g(k kVar) { this(new c(kVar, null)); } private g(c cVar) { this.f13123b = new m.g[4]; this.f13124c = new m.g[4]; this.f13126e = new Matrix(); this.f13127f = new Path(); this.f13128g = new Path(); this.f13129h = new RectF(); this.f13130i = new RectF(); this.f13131j = new Region(); this.f13132k = new Region(); Paint paint = new Paint(1); this.f13134m = paint; Paint paint2 = new Paint(1); this.f13135n = paint2; this.f13136o = new o3.a(); this.f13138q = new l(); this.f13142u = new RectF(); this.f13122a = cVar; paint2.setStyle(Paint.Style.STROKE); paint.setStyle(Paint.Style.FILL); Paint paint3 = f13121v; paint3.setColor(-1); paint3.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); a0(); Z(getState()); this.f13137p = new a(); } static final class c extends Drawable.ConstantState { /* renamed from: a, reason: collision with root package name */ public k f13146a; /* renamed from: b, reason: collision with root package name */ public j3.a f13147b; /* renamed from: c, reason: collision with root package name */ public ColorFilter f13148c; /* renamed from: d, reason: collision with root package name */ public ColorStateList f13149d; /* renamed from: e, reason: collision with root package name */ public ColorStateList f13150e; /* renamed from: f, reason: collision with root package name */ public ColorStateList f13151f; /* renamed from: g, reason: collision with root package name */ public ColorStateList f13152g; /* renamed from: h, reason: collision with root package name */ public PorterDuff.Mode f13153h; /* renamed from: i, reason: collision with root package name */ public Rect f13154i; /* renamed from: j, reason: collision with root package name */ public float f13155j; /* renamed from: k, reason: collision with root package name */ public float f13156k; /* renamed from: l, reason: collision with root package name */ public float f13157l; /* renamed from: m, reason: collision with root package name */ public int f13158m; /* renamed from: n, reason: collision with root package name */ public float f13159n; /* renamed from: o, reason: collision with root package name */ public float f13160o; /* renamed from: p, reason: collision with root package name */ public float f13161p; /* renamed from: q, reason: collision with root package name */ public int f13162q; /* renamed from: r, reason: collision with root package name */ public int f13163r; /* renamed from: s, reason: collision with root package name */ public int f13164s; /* renamed from: t, reason: collision with root package name */ public int f13165t; /* renamed from: u, reason: collision with root package name */ public boolean f13166u; /* renamed from: v, reason: collision with root package name */ public Paint.Style f13167v; public c(k kVar, j3.a aVar) { this.f13149d = null; this.f13150e = null; this.f13151f = null; this.f13152g = null; this.f13153h = PorterDuff.Mode.SRC_IN; this.f13154i = null; this.f13155j = 1.0f; this.f13156k = 1.0f; this.f13158m = 255; this.f13159n = 0.0f; this.f13160o = 0.0f; this.f13161p = 0.0f; this.f13162q = 0; this.f13163r = 0; this.f13164s = 0; this.f13165t = 0; this.f13166u = false; this.f13167v = Paint.Style.FILL_AND_STROKE; this.f13146a = kVar; this.f13147b = aVar; } @Override // android.graphics.drawable.Drawable.ConstantState public int getChangingConfigurations() { return 0; } @Override // android.graphics.drawable.Drawable.ConstantState public Drawable newDrawable() { g gVar = new g(this, null); gVar.f13125d = true; return gVar; } public c(c cVar) { this.f13149d = null; this.f13150e = null; this.f13151f = null; this.f13152g = null; this.f13153h = PorterDuff.Mode.SRC_IN; this.f13154i = null; this.f13155j = 1.0f; this.f13156k = 1.0f; this.f13158m = 255; this.f13159n = 0.0f; this.f13160o = 0.0f; this.f13161p = 0.0f; this.f13162q = 0; this.f13163r = 0; this.f13164s = 0; this.f13165t = 0; this.f13166u = false; this.f13167v = Paint.Style.FILL_AND_STROKE; this.f13146a = cVar.f13146a; this.f13147b = cVar.f13147b; this.f13157l = cVar.f13157l; this.f13148c = cVar.f13148c; this.f13149d = cVar.f13149d; this.f13150e = cVar.f13150e; this.f13153h = cVar.f13153h; this.f13152g = cVar.f13152g; this.f13158m = cVar.f13158m; this.f13155j = cVar.f13155j; this.f13164s = cVar.f13164s; this.f13162q = cVar.f13162q; this.f13166u = cVar.f13166u; this.f13156k = cVar.f13156k; this.f13159n = cVar.f13159n; this.f13160o = cVar.f13160o; this.f13161p = cVar.f13161p; this.f13163r = cVar.f13163r; this.f13165t = cVar.f13165t; this.f13151f = cVar.f13151f; this.f13167v = cVar.f13167v; if (cVar.f13154i != null) { this.f13154i = new Rect(cVar.f13154i); } } } }