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

Commit b081c321 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere Committed by Android (Google) Code Review
Browse files

Merge "Revert "Remove computeValue.isSpecified"" into main

parents 52520391 5ef60378
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -385,6 +385,7 @@ private fun elementAlpha(
            transformation = { it.alpha },
            transformation = { it.alpha },
            idleValue = 1f,
            idleValue = 1f,
            currentValue = { 1f },
            currentValue = { 1f },
            isSpecified = { true },
            ::lerp,
            ::lerp,
        )
        )
        .fastCoerceIn(0f, 1f)
        .fastCoerceIn(0f, 1f)
@@ -422,6 +423,7 @@ private fun ApproachMeasureScope.measure(
            transformation = { it.size },
            transformation = { it.size },
            idleValue = lookaheadSize,
            idleValue = lookaheadSize,
            currentValue = { measurable.measure(constraints).also { maybePlaceable = it }.size() },
            currentValue = { measurable.measure(constraints).also { maybePlaceable = it }.size() },
            isSpecified = { it != Element.SizeUnspecified },
            ::lerp,
            ::lerp,
        )
        )


@@ -447,6 +449,7 @@ private fun getDrawScale(
        transformation = { it.drawScale },
        transformation = { it.drawScale },
        idleValue = Scale.Default,
        idleValue = Scale.Default,
        currentValue = { Scale.Default },
        currentValue = { Scale.Default },
        isSpecified = { true },
        ::lerp,
        ::lerp,
    )
    )
}
}
@@ -487,6 +490,7 @@ private fun ApproachMeasureScope.place(
                transformation = { it.offset },
                transformation = { it.offset },
                idleValue = targetOffsetInScene,
                idleValue = targetOffsetInScene,
                currentValue = { currentOffset },
                currentValue = { currentOffset },
                isSpecified = { it != Offset.Unspecified },
                ::lerp,
                ::lerp,
            )
            )


@@ -533,6 +537,7 @@ private inline fun <T> computeValue(
    transformation: (ElementTransformations) -> PropertyTransformation<T>?,
    transformation: (ElementTransformations) -> PropertyTransformation<T>?,
    idleValue: T,
    idleValue: T,
    currentValue: () -> T,
    currentValue: () -> T,
    isSpecified: (T) -> Boolean,
    lerp: (T, T, Float) -> T,
    lerp: (T, T, Float) -> T,
): T {
): T {
    val transition =
    val transition =
@@ -598,6 +603,11 @@ private inline fun <T> computeValue(
        val start = sceneValue(fromState!!)
        val start = sceneValue(fromState!!)
        val end = sceneValue(toState!!)
        val end = sceneValue(toState!!)


        // TODO(b/316901148): Remove checks to isSpecified() once the lookahead pass runs for all
        // nodes before the intermediate layout pass.
        if (!isSpecified(start)) return end
        if (!isSpecified(end)) return start

        // Make sure we don't read progress if values are the same and we don't need to interpolate,
        // Make sure we don't read progress if values are the same and we don't need to interpolate,
        // so we don't invalidate the phase where this is read.
        // so we don't invalidate the phase where this is read.
        return if (start == end) start else lerp(start, end, transition.progress)
        return if (start == end) start else lerp(start, end, transition.progress)