package androidx.compose.ui.platform; import android.graphics.Outline; import androidx.compose.ui.geometry.CornerRadius; import androidx.compose.ui.geometry.CornerRadiusKt; import androidx.compose.ui.geometry.Offset; import androidx.compose.ui.geometry.OffsetKt; import androidx.compose.ui.geometry.Rect; import androidx.compose.ui.geometry.RoundRect; import androidx.compose.ui.geometry.RoundRectKt; import androidx.compose.ui.geometry.Size; import androidx.compose.ui.geometry.SizeKt; import androidx.compose.ui.graphics.AndroidPath; import androidx.compose.ui.graphics.AndroidPath_androidKt; import androidx.compose.ui.graphics.Canvas; import androidx.compose.ui.graphics.Outline; import androidx.compose.ui.graphics.Path; import androidx.compose.ui.graphics.RectangleShapeKt; import androidx.compose.ui.graphics.Shape; import androidx.compose.ui.unit.Density; import androidx.compose.ui.unit.LayoutDirection; import io.sentry.protocol.ViewHierarchyNode; import kotlin.Metadata; import kotlin.jvm.internal.Intrinsics; import kotlin.math.MathKt; /* compiled from: OutlineResolver.android.kt */ @Metadata(d1 = {"\u0000n\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0007\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u000e\n\u0002\u0018\u0002\n\u0002\b\b\b\u0000\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\u000e\u0010+\u001a\u00020,2\u0006\u0010-\u001a\u00020.J\u001b\u0010/\u001a\u00020\u00062\u0006\u00100\u001a\u00020\u001fø\u0001\u0001ø\u0001\u0000¢\u0006\u0004\b1\u00102J\u001b\u00103\u001a\u00020,2\u0006\u0010$\u001a\u00020\u001cø\u0001\u0001ø\u0001\u0000¢\u0006\u0004\b4\u00105J6\u00103\u001a\u00020\u00062\u0006\u0010\"\u001a\u00020#2\u0006\u00106\u001a\u00020!2\u0006\u0010+\u001a\u00020\u00062\u0006\u00107\u001a\u00020!2\u0006\u0010\u0011\u001a\u00020\u00122\u0006\u0010\u0002\u001a\u00020\u0003J\b\u00108\u001a\u00020,H\u0002J\u0010\u00109\u001a\u00020,2\u0006\u0010:\u001a\u00020\nH\u0002J\u0010\u0010;\u001a\u00020,2\u0006\u0010<\u001a\u00020=H\u0002J\u0010\u0010>\u001a\u00020,2\u0006\u0010?\u001a\u00020(H\u0002J3\u0010@\u001a\u00020\u0006*\u0004\u0018\u00010(2\u0006\u0010A\u001a\u00020\u001f2\u0006\u0010$\u001a\u00020\u001c2\u0006\u0010B\u001a\u00020!H\u0002ø\u0001\u0001ø\u0001\u0000¢\u0006\u0004\bC\u0010DR\u000e\u0010\u0005\u001a\u00020\u0006X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\bX\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\t\u001a\u0004\u0018\u00010\nX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u000b\u001a\u0004\u0018\u00010\fX\u0082\u000e¢\u0006\u0002\n\u0000R\u0013\u0010\r\u001a\u0004\u0018\u00010\n8F¢\u0006\u0006\u001a\u0004\b\u000e\u0010\u000fR\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0010\u001a\u00020\u0006X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0011\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R\u0013\u0010\u0013\u001a\u0004\u0018\u00010\b8F¢\u0006\u0006\u001a\u0004\b\u0014\u0010\u0015R\u0011\u0010\u0016\u001a\u00020\u00068F¢\u0006\u0006\u001a\u0004\b\u0017\u0010\u0018R\u000e\u0010\u0019\u001a\u00020\u0006X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u001a\u001a\u0004\u0018\u00010\nX\u0082\u000e¢\u0006\u0002\n\u0000R\u0019\u0010\u001b\u001a\u00020\u001cX\u0082\u000eø\u0001\u0000ø\u0001\u0001ø\u0001\u0002¢\u0006\u0004\n\u0002\u0010\u001dR\u0019\u0010\u001e\u001a\u00020\u001fX\u0082\u000eø\u0001\u0000ø\u0001\u0001ø\u0001\u0002¢\u0006\u0004\n\u0002\u0010\u001dR\u000e\u0010 \u001a\u00020!X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\"\u001a\u00020#X\u0082\u000e¢\u0006\u0002\n\u0000R\u0019\u0010$\u001a\u00020\u001cX\u0082\u000eø\u0001\u0000ø\u0001\u0001ø\u0001\u0002¢\u0006\u0004\n\u0002\u0010\u001dR\u0010\u0010%\u001a\u0004\u0018\u00010\nX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010&\u001a\u0004\u0018\u00010\nX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010'\u001a\u0004\u0018\u00010(X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010)\u001a\u0004\u0018\u00010\nX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010*\u001a\u00020\u0006X\u0082\u000e¢\u0006\u0002\n\u0000\u0082\u0002\u000f\n\u0002\b\u0019\n\u0005\b¡\u001e0\u0001\n\u0002\b!¨\u0006E"}, d2 = {"Landroidx/compose/ui/platform/OutlineResolver;", "", "density", "Landroidx/compose/ui/unit/Density;", "(Landroidx/compose/ui/unit/Density;)V", "cacheIsDirty", "", "cachedOutline", "Landroid/graphics/Outline;", "cachedRrectPath", "Landroidx/compose/ui/graphics/Path;", "calculatedOutline", "Landroidx/compose/ui/graphics/Outline;", "clipPath", "getClipPath", "()Landroidx/compose/ui/graphics/Path;", "isSupportedOutline", "layoutDirection", "Landroidx/compose/ui/unit/LayoutDirection;", "outline", "getOutline", "()Landroid/graphics/Outline;", "outlineClipSupported", "getOutlineClipSupported", "()Z", "outlineNeeded", "outlinePath", "rectSize", "Landroidx/compose/ui/geometry/Size;", "J", "rectTopLeft", "Landroidx/compose/ui/geometry/Offset;", "roundedCornerRadius", "", "shape", "Landroidx/compose/ui/graphics/Shape;", "size", "tmpOpPath", "tmpPath", "tmpRoundRect", "Landroidx/compose/ui/geometry/RoundRect;", "tmpTouchPointPath", "usePathForClip", "clipToOutline", "", "canvas", "Landroidx/compose/ui/graphics/Canvas;", "isInOutline", "position", "isInOutline-k-4lQ0M", "(J)Z", "update", "update-uvyYCjk", "(J)V", ViewHierarchyNode.JsonKeys.ALPHA, "elevation", "updateCache", "updateCacheWithPath", "composePath", "updateCacheWithRect", "rect", "Landroidx/compose/ui/geometry/Rect;", "updateCacheWithRoundRect", "roundRect", "isSameBounds", "offset", "radius", "isSameBounds-4L21HEs", "(Landroidx/compose/ui/geometry/RoundRect;JJF)Z", "ui_release"}, k = 1, mv = {1, 8, 0}, xi = 48) /* loaded from: classes.dex */ public final class OutlineResolver { private boolean cacheIsDirty; private final Outline cachedOutline; private Path cachedRrectPath; private androidx.compose.ui.graphics.Outline calculatedOutline; private Density density; private boolean isSupportedOutline; private LayoutDirection layoutDirection; private boolean outlineNeeded; private Path outlinePath; private long rectSize; private long rectTopLeft; private float roundedCornerRadius; private Shape shape; private long size; private Path tmpOpPath; private Path tmpPath; private RoundRect tmpRoundRect; private Path tmpTouchPointPath; private boolean usePathForClip; public final boolean getOutlineClipSupported() { return !this.usePathForClip; } public OutlineResolver(Density density) { Intrinsics.checkNotNullParameter(density, "density"); this.density = density; this.isSupportedOutline = true; Outline outline = new Outline(); outline.setAlpha(1.0f); this.cachedOutline = outline; this.size = Size.INSTANCE.m2478getZeroNHjbRc(); this.shape = RectangleShapeKt.getRectangleShape(); this.rectTopLeft = Offset.INSTANCE.m2416getZeroF1C5BW0(); this.rectSize = Size.INSTANCE.m2478getZeroNHjbRc(); this.layoutDirection = LayoutDirection.Ltr; } public final Outline getOutline() { updateCache(); if (this.outlineNeeded && this.isSupportedOutline) { return this.cachedOutline; } return null; } public final Path getClipPath() { updateCache(); return this.outlinePath; } public final boolean update(Shape shape, float alpha, boolean clipToOutline, float elevation, LayoutDirection layoutDirection, Density density) { Intrinsics.checkNotNullParameter(shape, "shape"); Intrinsics.checkNotNullParameter(layoutDirection, "layoutDirection"); Intrinsics.checkNotNullParameter(density, "density"); this.cachedOutline.setAlpha(alpha); boolean z = !Intrinsics.areEqual(this.shape, shape); if (z) { this.shape = shape; this.cacheIsDirty = true; } boolean z2 = clipToOutline || elevation > 0.0f; if (this.outlineNeeded != z2) { this.outlineNeeded = z2; this.cacheIsDirty = true; } if (this.layoutDirection != layoutDirection) { this.layoutDirection = layoutDirection; this.cacheIsDirty = true; } if (!Intrinsics.areEqual(this.density, density)) { this.density = density; this.cacheIsDirty = true; } return z; } /* renamed from: isInOutline-k-4lQ0M, reason: not valid java name */ public final boolean m4230isInOutlinek4lQ0M(long position) { androidx.compose.ui.graphics.Outline outline; if (this.outlineNeeded && (outline = this.calculatedOutline) != null) { return ShapeContainingUtilKt.isInOutline(outline, Offset.m2400getXimpl(position), Offset.m2401getYimpl(position), this.tmpTouchPointPath, this.tmpOpPath); } return true; } public final void clipToOutline(Canvas canvas) { Intrinsics.checkNotNullParameter(canvas, "canvas"); Path clipPath = getClipPath(); if (clipPath != null) { Canvas.m2610clipPathmtrdDE$default(canvas, clipPath, 0, 2, null); return; } float f = this.roundedCornerRadius; if (f > 0.0f) { Path path = this.tmpPath; RoundRect roundRect = this.tmpRoundRect; if (path == null || !m4229isSameBounds4L21HEs(roundRect, this.rectTopLeft, this.rectSize, f)) { RoundRect m2454RoundRectgG7oq9Y = RoundRectKt.m2454RoundRectgG7oq9Y(Offset.m2400getXimpl(this.rectTopLeft), Offset.m2401getYimpl(this.rectTopLeft), Offset.m2400getXimpl(this.rectTopLeft) + Size.m2469getWidthimpl(this.rectSize), Offset.m2401getYimpl(this.rectTopLeft) + Size.m2466getHeightimpl(this.rectSize), CornerRadiusKt.CornerRadius$default(this.roundedCornerRadius, 0.0f, 2, null)); if (path == null) { path = AndroidPath_androidKt.Path(); } else { path.reset(); } path.addRoundRect(m2454RoundRectgG7oq9Y); this.tmpRoundRect = m2454RoundRectgG7oq9Y; this.tmpPath = path; } Canvas.m2610clipPathmtrdDE$default(canvas, path, 0, 2, null); return; } Canvas.m2611clipRectN_I0leg$default(canvas, Offset.m2400getXimpl(this.rectTopLeft), Offset.m2401getYimpl(this.rectTopLeft), Size.m2469getWidthimpl(this.rectSize) + Offset.m2400getXimpl(this.rectTopLeft), Size.m2466getHeightimpl(this.rectSize) + Offset.m2401getYimpl(this.rectTopLeft), 0, 16, null); } /* renamed from: update-uvyYCjk, reason: not valid java name */ public final void m4231updateuvyYCjk(long size) { if (Size.m2465equalsimpl0(this.size, size)) { return; } this.size = size; this.cacheIsDirty = true; } private final void updateCache() { if (this.cacheIsDirty) { this.rectTopLeft = Offset.INSTANCE.m2416getZeroF1C5BW0(); long j = this.size; this.rectSize = j; this.roundedCornerRadius = 0.0f; this.outlinePath = null; this.cacheIsDirty = false; this.usePathForClip = false; if (this.outlineNeeded && Size.m2469getWidthimpl(j) > 0.0f && Size.m2466getHeightimpl(this.size) > 0.0f) { this.isSupportedOutline = true; androidx.compose.ui.graphics.Outline mo218createOutlinePq9zytI = this.shape.mo218createOutlinePq9zytI(this.size, this.layoutDirection, this.density); this.calculatedOutline = mo218createOutlinePq9zytI; if (mo218createOutlinePq9zytI instanceof Outline.Rectangle) { updateCacheWithRect(((Outline.Rectangle) mo218createOutlinePq9zytI).getRect()); return; } else if (mo218createOutlinePq9zytI instanceof Outline.Rounded) { updateCacheWithRoundRect(((Outline.Rounded) mo218createOutlinePq9zytI).getRoundRect()); return; } else { if (mo218createOutlinePq9zytI instanceof Outline.Generic) { updateCacheWithPath(((Outline.Generic) mo218createOutlinePq9zytI).getPath()); return; } return; } } this.cachedOutline.setEmpty(); } } private final void updateCacheWithRect(Rect rect) { this.rectTopLeft = OffsetKt.Offset(rect.getLeft(), rect.getTop()); this.rectSize = SizeKt.Size(rect.getWidth(), rect.getHeight()); this.cachedOutline.setRect(MathKt.roundToInt(rect.getLeft()), MathKt.roundToInt(rect.getTop()), MathKt.roundToInt(rect.getRight()), MathKt.roundToInt(rect.getBottom())); } private final void updateCacheWithRoundRect(RoundRect roundRect) { float m2375getXimpl = CornerRadius.m2375getXimpl(roundRect.m2450getTopLeftCornerRadiuskKHJgLs()); this.rectTopLeft = OffsetKt.Offset(roundRect.getLeft(), roundRect.getTop()); this.rectSize = SizeKt.Size(roundRect.getWidth(), roundRect.getHeight()); if (RoundRectKt.isSimple(roundRect)) { this.cachedOutline.setRoundRect(MathKt.roundToInt(roundRect.getLeft()), MathKt.roundToInt(roundRect.getTop()), MathKt.roundToInt(roundRect.getRight()), MathKt.roundToInt(roundRect.getBottom()), m2375getXimpl); this.roundedCornerRadius = m2375getXimpl; return; } Path path = this.cachedRrectPath; if (path == null) { path = AndroidPath_androidKt.Path(); this.cachedRrectPath = path; } path.reset(); path.addRoundRect(roundRect); updateCacheWithPath(path); } /* renamed from: isSameBounds-4L21HEs, reason: not valid java name */ private final boolean m4229isSameBounds4L21HEs(RoundRect roundRect, long j, long j2, float f) { return roundRect != null && RoundRectKt.isSimple(roundRect) && roundRect.getLeft() == Offset.m2400getXimpl(j) && roundRect.getTop() == Offset.m2401getYimpl(j) && roundRect.getRight() == Offset.m2400getXimpl(j) + Size.m2469getWidthimpl(j2) && roundRect.getBottom() == Offset.m2401getYimpl(j) + Size.m2466getHeightimpl(j2) && CornerRadius.m2375getXimpl(roundRect.m2450getTopLeftCornerRadiuskKHJgLs()) == f; } private final void updateCacheWithPath(Path composePath) { android.graphics.Outline outline = this.cachedOutline; if (composePath instanceof AndroidPath) { outline.setConvexPath(((AndroidPath) composePath).getInternalPath()); this.usePathForClip = !this.cachedOutline.canClip(); this.outlinePath = composePath; return; } throw new UnsupportedOperationException("Unable to obtain android.graphics.Path"); } }