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

Commit 52c0ce0e authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Use CompositingStrategy.ModulateAlpha when fading elements

This CL switches the compositionStrategy of elements to ModulateAlpha
when fading the elements. While this will not always lead to the most
correct result visually if the UI has overlapping rendering (which it
should not in SysUI case), it leads to much better performance.

In a follow-up CL, I will add a way to change the compositionStrategy
for cases where there is overlapping rendering.

Bug: 291071158
Test: PlatformComposeSceneTransitionLayoutTests
Flag: N/A
Change-Id: I96a4457cba36d0fbd1d15861ea1571e74cfa7d77
parent f23d375e
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.isUnspecified
import androidx.compose.ui.geometry.isUnspecified
import androidx.compose.ui.geometry.lerp
import androidx.compose.ui.geometry.lerp
import androidx.compose.ui.graphics.CompositingStrategy
import androidx.compose.ui.graphics.drawscope.ContentDrawScope
import androidx.compose.ui.graphics.drawscope.ContentDrawScope
import androidx.compose.ui.graphics.drawscope.scale
import androidx.compose.ui.graphics.drawscope.scale
import androidx.compose.ui.layout.IntermediateMeasureScope
import androidx.compose.ui.layout.IntermediateMeasureScope
@@ -473,7 +474,8 @@ private fun IntermediateMeasureScope.place(
            placeable.place(offset)
            placeable.place(offset)
        } else {
        } else {
            placeable.placeWithLayer(offset) {
            placeable.placeWithLayer(offset) {
                this.alpha = elementAlpha(layoutImpl, element, scene)
                alpha = elementAlpha(layoutImpl, element, scene)
                compositingStrategy = CompositingStrategy.ModulateAlpha
            }
            }
        }
        }
    }
    }