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

Commit f77bfb60 authored by Lucas Dupin's avatar Lucas Dupin Committed by Automerger Merge Worker
Browse files

Merge changes Id157edb7,I94b05bf1 into sc-dev am: ba58f850

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14083131

Change-Id: I80b0530bf8c867462e713129d6692e1a278c6d2c
parents 365efc09 ba58f850
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -41,8 +41,8 @@ public final class RippleAnimationSession {
    private static final int ENTER_ANIM_DURATION = 450;
    private static final int ENTER_ANIM_DURATION = 450;
    private static final int EXIT_ANIM_DURATION = 300;
    private static final int EXIT_ANIM_DURATION = 300;
    private static final TimeInterpolator LINEAR_INTERPOLATOR = new LinearInterpolator();
    private static final TimeInterpolator LINEAR_INTERPOLATOR = new LinearInterpolator();
    private static final Interpolator FAST_OUT_LINEAR_IN =
    private static final Interpolator FAST_OUT_SLOW_IN =
            new PathInterpolator(0.4f, 0f, 1f, 1f);
            new PathInterpolator(0.4f, 0f, 0.2f, 1f);
    private Consumer<RippleAnimationSession> mOnSessionEnd;
    private Consumer<RippleAnimationSession> mOnSessionEnd;
    private final AnimationProperties<Float, Paint> mProperties;
    private final AnimationProperties<Float, Paint> mProperties;
    private AnimationProperties<CanvasProperty<Float>, CanvasProperty<Paint>> mCanvasProperties;
    private AnimationProperties<CanvasProperty<Float>, CanvasProperty<Paint>> mCanvasProperties;
@@ -173,7 +173,7 @@ public final class RippleAnimationSession {
    private void startAnimation(Animator expand) {
    private void startAnimation(Animator expand) {
        expand.setDuration(ENTER_ANIM_DURATION);
        expand.setDuration(ENTER_ANIM_DURATION);
        expand.addListener(new AnimatorListener(this));
        expand.addListener(new AnimatorListener(this));
        expand.setInterpolator(FAST_OUT_LINEAR_IN);
        expand.setInterpolator(FAST_OUT_SLOW_IN);
        expand.start();
        expand.start();
        mAnimateSparkle = true;
        mAnimateSparkle = true;
    }
    }
+10 −9
Original line number Original line Diff line number Diff line
@@ -48,7 +48,7 @@ final class RippleShader extends RuntimeShader {
            + "  float s = 0.0;\n"
            + "  float s = 0.0;\n"
            + "  for (float i = 0; i < 4; i += 1) {\n"
            + "  for (float i = 0; i < 4; i += 1) {\n"
            + "    float l = i * 0.01;\n"
            + "    float l = i * 0.01;\n"
            + "    float h = l + 0.1;\n"
            + "    float h = l + 0.2;\n"
            + "    float o = smoothstep(n - l, h, n);\n"
            + "    float o = smoothstep(n - l, h, n);\n"
            + "    o *= abs(sin(PI * o * (t + 0.55 * i)));\n"
            + "    o *= abs(sin(PI * o * (t + 0.55 * i)));\n"
            + "    s += o;\n"
            + "    s += o;\n"
@@ -62,7 +62,7 @@ final class RippleShader extends RuntimeShader {
            + "  return 1. - smoothstep(1. - blurHalf, 1. + blurHalf, d / radius);\n"
            + "  return 1. - smoothstep(1. - blurHalf, 1. + blurHalf, d / radius);\n"
            + "}\n"
            + "}\n"
            + "float softRing(vec2 uv, vec2 xy, float radius, float progress, float blur) {\n"
            + "float softRing(vec2 uv, vec2 xy, float radius, float progress, float blur) {\n"
            + "  float thickness = 0.2 * radius;\n"
            + "  float thickness = 0.3 * radius;\n"
            + "  float currentRadius = radius * progress;\n"
            + "  float currentRadius = radius * progress;\n"
            + "  float circle_outer = softCircle(uv, xy, currentRadius + thickness, blur);\n"
            + "  float circle_outer = softCircle(uv, xy, currentRadius + thickness, blur);\n"
            + "  float circle_inner = softCircle(uv, xy, currentRadius - thickness, blur);\n"
            + "  float circle_inner = softCircle(uv, xy, currentRadius - thickness, blur);\n"
@@ -73,18 +73,19 @@ final class RippleShader extends RuntimeShader {
            + "    return (sub - start) / (end - start); \n"
            + "    return (sub - start) / (end - start); \n"
            + "}\n";
            + "}\n";
    private static final String SHADER_MAIN = "vec4 main(vec2 p) {\n"
    private static final String SHADER_MAIN = "vec4 main(vec2 p) {\n"
            + "    float fadeIn = subProgress(0., 0.175, in_progress);\n"
            + "    float fadeIn = subProgress(0., 0.1, in_progress);\n"
            + "    float fadeOutNoise = subProgress(0.375, 1., in_progress);\n"
            + "    float scaleIn = subProgress(0., 0.45, in_progress);\n"
            + "    float fadeOutRipple = subProgress(0.375, 0.75, in_progress);\n"
            + "    float fadeOutNoise = subProgress(0.5, 1., in_progress);\n"
            + "    float fadeOutRipple = subProgress(0.5, 0.75, in_progress);\n"
            + "    vec2 center = mix(in_touch, in_origin, fadeIn);\n"
            + "    vec2 center = mix(in_touch, in_origin, fadeIn);\n"
            + "    float ring = softRing(p, center, in_maxRadius, fadeIn, 0.45);\n"
            + "    float ring = softRing(p, center, in_maxRadius, scaleIn, 0.45);\n"
            + "    float alpha = 1. - fadeOutNoise;\n"
            + "    float alpha = min(fadeIn, 1. - fadeOutNoise);\n"
            + "    vec2 uv = p * in_resolutionScale;\n"
            + "    vec2 uv = p * in_resolutionScale;\n"
            + "    vec2 densityUv = uv - mod(uv, in_noiseScale);\n"
            + "    vec2 densityUv = uv - mod(uv, in_noiseScale);\n"
            + "    float sparkle = sparkles(densityUv, in_noisePhase) * ring * alpha;\n"
            + "    float sparkle = sparkles(densityUv, in_noisePhase) * ring * alpha;\n"
            + "    float fade = min(fadeIn, 1. - fadeOutRipple);\n"
            + "    float fade = min(fadeIn, 1. - fadeOutRipple);\n"
            + "    vec4 circle = in_color * (softCircle(p, center, in_maxRadius "
            + "    vec4 circle = in_color * (softCircle(p, center, in_maxRadius "
            + "      * fadeIn, 0.2) * fade);\n"
            + "      * scaleIn, 0.2) * fade);\n"
            + "    float mask = in_hasMask == 1. ? sample(in_shader).a > 0. ? 1. : 0. : 1.;\n"
            + "    float mask = in_hasMask == 1. ? sample(in_shader).a > 0. ? 1. : 0. : 1.;\n"
            + "    return mix(circle, vec4(sparkle), sparkle) * mask;\n"
            + "    return mix(circle, vec4(sparkle), sparkle) * mask;\n"
            + "}";
            + "}";
@@ -134,7 +135,7 @@ final class RippleShader extends RuntimeShader {
    }
    }


    public void setResolution(float w, float h, int density) {
    public void setResolution(float w, float h, int density) {
        float densityScale = density * DisplayMetrics.DENSITY_DEFAULT_SCALE;
        float densityScale = density * DisplayMetrics.DENSITY_DEFAULT_SCALE * 1.25f;
        setUniform("in_resolutionScale", new float[] {1f / w, 1f / h});
        setUniform("in_resolutionScale", new float[] {1f / w, 1f / h});
        setUniform("in_noiseScale", new float[] {densityScale / w, densityScale / h});
        setUniform("in_noiseScale", new float[] {densityScale / w, densityScale / h});
    }
    }