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

Commit 9e2754d1 authored by Lucas Dupin's avatar Lucas Dupin Committed by Android (Google) Code Review
Browse files

Merge "Avoid recreating shader during recomposition" into main

parents dd4b5a63 4c5ecbfe
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -81,15 +81,14 @@ fun BackgroundGlow(
    val color2 = Color(boostChroma(MaterialTheme.colorScheme.primary.toArgb()))
    val color3 = Color(boostChroma(MaterialTheme.colorScheme.tertiary.toArgb()))

    val shader = RuntimeShader(BackgroundGlowShader.FRAG_SHADER)
    val shaderBrush = ShaderBrush(shader)
    val shader = remember { RuntimeShader(BackgroundGlowShader.FRAG_SHADER) }
    val shaderBrush = remember { ShaderBrush(shader) }

    Box(
        modifier.size(400.dp, 200.dp).alpha(alpha).drawWithCache {
            onDrawWithContent {
                val offsetX = with(density) { verticalOffset.x.dp.toPx() }
                val offsetY = with(density) { verticalOffset.y.dp.toPx() }
                shader.setFloatUniform("alpha", alpha)
                shader.setFloatUniform("resolution", size.width, size.height)
                shader.setColorUniform("color1", color1.toArgb())
                shader.setColorUniform("color2", color2.toArgb())
+0 −1
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ object BackgroundGlowShader {
    uniform float2 resolution;
    uniform half2 origin;
    uniform half radius;
    uniform half alpha;
    uniform half turbulencePhase;
    uniform half turbulenceAmount;
    uniform half turbulenceSize;