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

Commit 794c5ba9 authored by Alan Viverette's avatar Alan Viverette
Browse files

Simplify color adjustment using homogeneous coordinates

Change-Id: Ie31abacb134c29d82a6041fa7d521f68a1a273af
parent 59d6992f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -169,7 +169,8 @@ String8 ProgramCache::generateFragmentShader(const Key& needs) {
            fs << "gl_FragColor.rgb = gl_FragColor.rgb/gl_FragColor.a;";
        }
        fs << "gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(2.2));";
        fs << "gl_FragColor.rgb = mat3(colorMatrix) * gl_FragColor.rgb + vec3(colorMatrix[3]);";
        fs << "vec4 transformed = colorMatrix * vec4(gl_FragColor.rgb, 1);";
        fs << "gl_FragColor.rgb = transformed.rgb/transformed.a;";
        fs << "gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(1.0 / 2.2));";
        if (!needs.isOpaque() && needs.isPremultiplied()) {
            // and re-premultiply if needed after gamma correction
+4 −11
Original line number Diff line number Diff line
@@ -1507,9 +1507,7 @@ void SurfaceFlinger::doDisplayComposition(const sp<const DisplayDevice>& hw,
        RenderEngine& engine(getRenderEngine());
        mat4 colorMatrix = mColorMatrix;
        if (mDaltonize) {
            // preserve last row of color matrix
            colorMatrix = colorMatrix * mDaltonizer();
            colorMatrix[3] = mColorMatrix[3];
        }
        engine.beginGroup(colorMatrix);
        doComposeSurfaces(hw, dirtyRegion);
@@ -2570,16 +2568,11 @@ status_t SurfaceFlinger::onTransact(
                    // color matrix is sent as mat3 matrix followed by vec3
                    // offset, then packed into a mat4 where the last row is
                    // the offset and extra values are 0
                    for (size_t i = 0 ; i < 3 ; i++) {
                        for (size_t j = 0; j < 3; j++) {
                    for (size_t i = 0 ; i < 4; i++) {
                      for (size_t j = 0; j < 4; j++) {
                          mColorMatrix[i][j] = data.readFloat();
                      }
                        mColorMatrix[i][3] = 0;
                    }
                    for (size_t i = 0; i < 3; i++) {
                        mColorMatrix[3][i] = data.readFloat();
                    }
                    mColorMatrix[3][3] = 0;
                } else {
                    mColorMatrix = mat4();
                }