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

Commit 4b3b7adc authored by Olivier St-Onge's avatar Olivier St-Onge Committed by Android (Google) Code Review
Browse files

Revert "Read the animated color value in the drawing phase for icons"

Revert submission 35181708-438935145

Reason for revert: Causing performance regressions b/441161005

Reverted changes: /q/submissionid:35181708-438935145

Change-Id: I8135023e8a0ac778011bdef789b03ea632053f08
parent 1c0af7a1
Loading
Loading
Loading
Loading
+11 −16
Original line number Original line Diff line number Diff line
@@ -56,7 +56,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.draw.paint
import androidx.compose.ui.draw.paint
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Offset
@@ -71,7 +70,6 @@ import androidx.compose.ui.graphics.DefaultAlpha
import androidx.compose.ui.graphics.TransformOrigin
import androidx.compose.ui.graphics.TransformOrigin
import androidx.compose.ui.graphics.drawscope.DrawScope
import androidx.compose.ui.graphics.drawscope.DrawScope
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.layer.drawLayer
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.Layout
@@ -295,7 +293,7 @@ fun SmallTileContent(
            NonClippedImage(
            NonClippedImage(
                painter = painter,
                painter = painter,
                contentDescription = icon.contentDescription?.load(),
                contentDescription = icon.contentDescription?.load(),
                tint = { animatedColor },
                colorFilter = ColorFilter.tint(color = animatedColor),
                modifier = iconModifier,
                modifier = iconModifier,
                contentScale = ContentScale.Crop,
                contentScale = ContentScale.Crop,
            )
            )
@@ -308,7 +306,7 @@ fun SmallTileContent(
            )
            )
        }
        }
    } else {
    } else {
        Icon(icon = icon, tint = { animatedColor }, modifier = iconModifier)
        Icon(icon = icon, tint = animatedColor, modifier = iconModifier)
    }
    }
}
}


@@ -411,6 +409,7 @@ object CommonTileDefaults {
    val LargeTileIconSize = 28.dp
    val LargeTileIconSize = 28.dp
    val SideIconWidth = 32.dp
    val SideIconWidth = 32.dp
    val SideIconHeight = 20.dp
    val SideIconHeight = 20.dp
    val ChevronSize = 14.dp
    val ToggleTargetSize = 56.dp
    val ToggleTargetSize = 56.dp
    val TileHeight = 72.dp
    val TileHeight = 72.dp
    val TileStartPadding = 8.dp
    val TileStartPadding = 8.dp
@@ -439,7 +438,7 @@ private fun NonClippedImage(
    alignment: Alignment = Alignment.Center,
    alignment: Alignment = Alignment.Center,
    contentScale: ContentScale = ContentScale.Fit,
    contentScale: ContentScale = ContentScale.Fit,
    alpha: Float = DefaultAlpha,
    alpha: Float = DefaultAlpha,
    tint: ColorProducer,
    colorFilter: ColorFilter,
) {
) {
    val semantics =
    val semantics =
        if (contentDescription != null) {
        if (contentDescription != null) {
@@ -456,17 +455,13 @@ private fun NonClippedImage(
    Layout(
    Layout(
        modifier
        modifier
            .then(semantics)
            .then(semantics)
            .drawWithCache {
            .paint(
                // Applying the color filter directly on the layer since it's an animated value.
                painter,
                // This is taken from the Material3 Icon implementation
                alignment = alignment,
                val layer = obtainGraphicsLayer()
                contentScale = contentScale,
                layer.apply {
                alpha = alpha,
                    record { drawContent() }
                colorFilter = colorFilter,
                    this@apply.colorFilter = ColorFilter.tint(tint())
            )
                }
                onDrawWithContent { drawLayer(graphicsLayer = layer) }
            }
            .paint(painter, alignment = alignment, contentScale = contentScale, alpha = alpha)
    ) { _, constraints ->
    ) { _, constraints ->
        layout(constraints.minWidth, constraints.minHeight) {}
        layout(constraints.minWidth, constraints.minHeight) {}
    }
    }