Merge "Use setPath on Android R+" into androidx-main
diff --git a/compose/ui/ui-graphics/src/androidMain/kotlin/androidx/compose/ui/graphics/layer/AndroidGraphicsLayer.android.kt b/compose/ui/ui-graphics/src/androidMain/kotlin/androidx/compose/ui/graphics/layer/AndroidGraphicsLayer.android.kt
index ac0523c..1ddf106 100644
--- a/compose/ui/ui-graphics/src/androidMain/kotlin/androidx/compose/ui/graphics/layer/AndroidGraphicsLayer.android.kt
+++ b/compose/ui/ui-graphics/src/androidMain/kotlin/androidx/compose/ui/graphics/layer/AndroidGraphicsLayer.android.kt
@@ -607,7 +607,7 @@
     private fun updatePathOutline(path: Path): AndroidOutline {
         val resultOutline = obtainAndroidOutline()
         if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P || path.isConvex) {
-            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
+            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
                 OutlineVerificationHelper.setPath(resultOutline, path)
             } else {
                 resultOutline.setConvexPath(path.asAndroidPath())
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/OutlineResolver.android.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/OutlineResolver.android.kt
index 9f26185..987b13a 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/OutlineResolver.android.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/OutlineResolver.android.kt
@@ -18,6 +18,8 @@
 
 import android.graphics.Outline as AndroidOutline
 import android.os.Build
+import androidx.annotation.DoNotInline
+import androidx.annotation.RequiresApi
 import androidx.compose.ui.geometry.CornerRadius
 import androidx.compose.ui.geometry.Offset
 import androidx.compose.ui.geometry.Rect
@@ -278,8 +280,11 @@
     @Suppress("deprecation")
     private fun updateCacheWithPath(composePath: Path) {
         if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P || composePath.isConvex) {
-            // TODO(mount): Use setPath() for R+ when available.
-            cachedOutline.setConvexPath(composePath.asAndroidPath())
+            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+                OutlineVerificationHelper.setPath(cachedOutline, composePath)
+            } else {
+                cachedOutline.setConvexPath(composePath.asAndroidPath())
+            }
             usePathForClip = !cachedOutline.canClip()
         } else {
             isSupportedOutline = false // Concave outlines are not supported on older API levels
@@ -305,3 +310,12 @@
             topLeftCornerRadius.x == radius
     }
 }
+
+@RequiresApi(Build.VERSION_CODES.R)
+internal object OutlineVerificationHelper {
+
+    @DoNotInline
+    fun setPath(outline: AndroidOutline, path: Path) {
+        outline.setPath(path.asAndroidPath())
+    }
+}