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

Commit 9559d7a6 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Remove saturation effect from screen-off anim

Effect is starting to look dated and we're going with a simple
fade out in P.

Bug: 64155983
Test: Open coloful image, press power button
Change-Id: I1f31b4c79d4cd8d7ea8e0a32936bdb8498fe2c4c
parent e1daf52b
Loading
Loading
Loading
Loading
+1 −29
Original line number Diff line number Diff line
@@ -3,40 +3,12 @@
precision mediump float;
uniform samplerExternalOES texUnit;
uniform float opacity;
uniform float saturation;
uniform float gamma;
varying vec2 UV;

vec3 rgb2hsl(vec3 rgb)
{
    float e = 1.0e-7;

    vec4 p = rgb.g < rgb.b ? vec4(rgb.bg, -1.0, 2.0 / 3.0) : vec4(rgb.gb, 0.0, -1.0 / 3.0);
    vec4 q = rgb.r < p.x ? vec4(p.xyw, rgb.r) : vec4(rgb.r, p.yzx);

    float v = q.x;
    float c = v - min(q.w, q.y);
    float h = abs((q.w - q.y) / (6.0 * c + e) + q.z);
    float l = v - c * 0.5;
    float s = c / (1.0 - abs(2.0 * l - 1.0) + e);
    return clamp(vec3(h, s, l), 0.0, 1.0);
}

vec3 hsl2rgb(vec3 hsl)
{
    vec3 h = vec3(hsl.x * 6.0);
    vec3 p = abs(h - vec3(3.0, 2.0, 4.0));
    vec3 q = 2.0 - p;

    vec3 rgb = clamp(vec3(p.x - 1.0, q.yz), 0.0, 1.0);
    float c = (1.0 - abs(2.0 * hsl.z - 1.0)) * hsl.y;
    return (rgb - vec3(0.5)) * c + hsl.z;
}

void main()
{
    vec4 color = texture2D(texUnit, UV);
    vec3 hsl = rgb2hsl(color.xyz);
    vec3 rgb = pow(hsl2rgb(vec3(hsl.x, hsl.y * saturation, hsl.z * opacity)), vec3(gamma));
    vec3 rgb = pow(color.rgb * opacity, vec3(gamma));
    gl_FragColor = vec4(rgb, 1.0);
}
+4 −8
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ final class ColorFade {
    private final float mProjMatrix[] = new float[16];
    private final int[] mGLBuffers = new int[2];
    private int mTexCoordLoc, mVertexLoc, mTexUnitLoc, mProjMatrixLoc, mTexMatrixLoc;
    private int mOpacityLoc, mGammaLoc, mSaturationLoc;
    private int mOpacityLoc, mGammaLoc;
    private int mProgram;

    // Vertex and corresponding texture coordinates.
@@ -245,7 +245,6 @@ final class ColorFade {

        mOpacityLoc = GLES20.glGetUniformLocation(mProgram, "opacity");
        mGammaLoc = GLES20.glGetUniformLocation(mProgram, "gamma");
        mSaturationLoc = GLES20.glGetUniformLocation(mProgram, "saturation");
        mTexUnitLoc = GLES20.glGetUniformLocation(mProgram, "texUnit");

        GLES20.glUseProgram(mProgram);
@@ -393,9 +392,8 @@ final class ColorFade {
            double cos = Math.cos(Math.PI * one_minus_level);
            double sign = cos < 0 ? -1 : 1;
            float opacity = (float) -Math.pow(one_minus_level, 2) + 1;
            float saturation = (float) Math.pow(level, 4);
            float gamma = (float) ((0.5d * sign * Math.pow(cos, 2) + 0.5d) * 0.9d + 0.1d);
            drawFaded(opacity, 1.f / gamma, saturation);
            drawFaded(opacity, 1.f / gamma);
            if (checkGlErrors("drawFrame")) {
                return false;
            }
@@ -407,10 +405,9 @@ final class ColorFade {
        return showSurface(1.0f);
    }

    private void drawFaded(float opacity, float gamma, float saturation) {
    private void drawFaded(float opacity, float gamma) {
        if (DEBUG) {
            Slog.d(TAG, "drawFaded: opacity=" + opacity + ", gamma=" + gamma +
                        ", saturation=" + saturation);
            Slog.d(TAG, "drawFaded: opacity=" + opacity + ", gamma=" + gamma);
        }
        // Use shaders
        GLES20.glUseProgram(mProgram);
@@ -420,7 +417,6 @@ final class ColorFade {
        GLES20.glUniformMatrix4fv(mTexMatrixLoc, 1, false, mTexMatrix, 0);
        GLES20.glUniform1f(mOpacityLoc, opacity);
        GLES20.glUniform1f(mGammaLoc, gamma);
        GLES20.glUniform1f(mSaturationLoc, saturation);

        // Use textures
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);