@@ -64,6 +64,7 @@ import androidx.constraintlayout.core.widgets.analyzer.BasicMeasure.Measure.USE_
64
64
@Composable
65
65
fun ConstraintLayout (
66
66
modifier : Modifier = Modifier ,
67
+ optimizationLevel : Int = Optimizer .OPTIMIZATION_STANDARD ,
67
68
content : @Composable ConstraintLayoutScope .() -> Unit
68
69
) {
69
70
val measurer = remember { Measurer () }
@@ -100,6 +101,7 @@ fun ConstraintLayout(
100
101
layoutDirection,
101
102
constraintSet,
102
103
measurables,
104
+ optimizationLevel,
103
105
this
104
106
)
105
107
layout(layoutSize.width, layoutSize.height) {
@@ -118,6 +120,7 @@ fun ConstraintLayout(
118
120
fun ConstraintLayout (
119
121
constraintSet : ConstraintSet ,
120
122
modifier : Modifier = Modifier ,
123
+ optimizationLevel : Int = Optimizer .OPTIMIZATION_STANDARD ,
121
124
content : @Composable () -> Unit
122
125
) {
123
126
val measurer = remember { Measurer () }
@@ -131,6 +134,7 @@ fun ConstraintLayout(
131
134
layoutDirection,
132
135
constraintSet,
133
136
measurables,
137
+ optimizationLevel,
134
138
this
135
139
)
136
140
layout(layoutSize.width, layoutSize.height) {
@@ -1291,12 +1295,12 @@ private class Measurer : BasicMeasure.Measurer {
1291
1295
Log .d(" CCL2" , " DW ${matchConstraintDefaultDimension} " )
1292
1296
Log .d(" CCL2" , " ODR ${otherDimensionResolved} " )
1293
1297
Log .d(" CCL2" , " IRH ${currentDimensionResolved} " )
1294
- val useDimension = (measureStrategy == TRY_GIVEN_DIMENSIONS ||
1298
+ val useDimension = currentDimensionResolved ||
1299
+ (measureStrategy == TRY_GIVEN_DIMENSIONS ||
1295
1300
measureStrategy == USE_GIVEN_DIMENSIONS ) &&
1296
1301
(measureStrategy == USE_GIVEN_DIMENSIONS ||
1297
1302
matchConstraintDefaultDimension != MATCH_CONSTRAINT_WRAP ||
1298
- otherDimensionResolved ||
1299
- currentDimensionResolved)
1303
+ otherDimensionResolved)
1300
1304
Log .d(" CCL" , " UD $useDimension " )
1301
1305
outConstraints[0 ] = if (useDimension) dimension else 0
1302
1306
outConstraints[1 ] = if (useDimension) dimension else rootMaxConstraint
@@ -1318,6 +1322,7 @@ private class Measurer : BasicMeasure.Measurer {
1318
1322
layoutDirection : LayoutDirection ,
1319
1323
constraintSet : ConstraintSet ,
1320
1324
measurables : List <Measurable >,
1325
+ optimizationLevel : Int ,
1321
1326
measureScope : MeasureScope
1322
1327
): IntSize {
1323
1328
this .density = measureScope
@@ -1361,7 +1366,7 @@ private class Measurer : BasicMeasure.Measurer {
1361
1366
}
1362
1367
1363
1368
// No need to set sizes and size modes as we passed them to the state above.
1364
- root.optimizationLevel = Optimizer .OPTIMIZATION_STANDARD
1369
+ root.optimizationLevel = optimizationLevel // Optimizer.OPTIMIZATION_STANDARD
1365
1370
root.measure(root.optimizationLevel, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )
1366
1371
1367
1372
for (child in root.children) {
0 commit comments