diff options
| author | 2024-04-22 05:54:11 +0000 | |
|---|---|---|
| committer | 2024-04-22 05:54:11 +0000 | |
| commit | cc4c09fc321a17e1198b9cb888d590fd6d9616a1 (patch) | |
| tree | ca2976e44974526903b43158341b74671cddc3d1 | |
| parent | ab000505a0358b2fd0cff1e0dea28d56dc3f354e (diff) | |
| parent | f055241bf5cb04c1b23034971bcfc7a75ade9391 (diff) | |
Merge "Adding a modifier to add perfetto marker for the measure and layout phases of compose." into main
| -rw-r--r-- | packages/SystemUI/compose/core/Android.bp | 1 | ||||
| -rw-r--r-- | packages/SystemUI/compose/core/src/com/android/compose/modifiers/MeasureTracing.kt | 32 |
2 files changed, 33 insertions, 0 deletions
diff --git a/packages/SystemUI/compose/core/Android.bp b/packages/SystemUI/compose/core/Android.bp index 4f7a43e7cb1c..49ae821dd2fb 100644 --- a/packages/SystemUI/compose/core/Android.bp +++ b/packages/SystemUI/compose/core/Android.bp @@ -38,6 +38,7 @@ android_library { "androidx.compose.material3_material3-window-size-class", "androidx.savedstate_savedstate", "androidx.window_window", + "//frameworks/libs/systemui:tracinglib-platform", ], kotlincflags: ["-Xjvm-default=all"], diff --git a/packages/SystemUI/compose/core/src/com/android/compose/modifiers/MeasureTracing.kt b/packages/SystemUI/compose/core/src/com/android/compose/modifiers/MeasureTracing.kt new file mode 100644 index 000000000000..9ce6cd11a2b0 --- /dev/null +++ b/packages/SystemUI/compose/core/src/com/android/compose/modifiers/MeasureTracing.kt @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.compose.modifiers + +import androidx.compose.ui.Modifier +import androidx.compose.ui.layout.layout +import androidx.compose.ui.unit.IntOffset +import com.android.app.tracing.traceSection + +/** Adds perfetto markers for the measure + layout stages. */ +inline fun Modifier.measureTracer(crossinline traceNameProducer: () -> String): Modifier { + return layout { measurable, constraints -> + traceSection(traceNameProducer) { + val placeable = measurable.measure(constraints) + layout(placeable.width, placeable.height) { placeable.placeRelative(IntOffset.Zero) } + } + } +} |