Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit debf1d03 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Remove Modifier.measureTracer {}

This CL removes Modifier.measureTracer {} given that it was unused and
most importantly misleading. From adamp@:

"The layout at the end returns an object that contains the placement
code as a callback. Many layouts measure their children as part of
placement, not container measurement, because the child's measured size
cannot affect the measurement of the parent. This aids compose in
skipping unnecessary layout up the hierarchy.There are many ways that a
child of this modifier can be remeasured completely outside of this
trace recording."

Bug: 291071158
Test: N/A
Flag: EXEMPT deleted unused code
Change-Id: I9cc6a728e3aa90615dfd1fd7e0a700e52f3319a9
parent daca9110
Loading
Loading
Loading
Loading
+0 −32
Original line number Diff line number Diff line
/*
 * 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) }
        }
    }
}