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

Commit ba2f0bc3 authored by KaiChieh Chuang's avatar KaiChieh Chuang Committed by Alec Mouri
Browse files

[RenderEngine] Introduce non-linear display color transform.

A display color transform is a non-linear color matrix that should be
applied in gamma space. Previously the non-linear display color transform
is mixed into the linear color matrix that results in incorrect color
inversion behaviour.

RenderEngineTest
fix fillBufferColorTransform calling wrong function
fillBufferColorTransform display color transform set to 0.9f
add renderengine object for useColorManagement enabled,
to test color management affected on display and layer color transform

Bug: 157203983
Test: color inversion
Test: run RenderEngineTest
Change-Id: Ic731f014a14795b80323eeaf929761c828150f91
Merged-In: Ic731f014a14795b80323eeaf929761c828150f91
parent 257db3c1
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -52,5 +52,10 @@ bool Description::hasColorMatrix() const {
    return colorMatrix != identity;
}

bool Description::hasDisplayColorMatrix() const {
    const mat4 identity;
    return displayColorMatrix != identity;
}

} // namespace renderengine
} // namespace android
+6 −1
Original line number Diff line number Diff line
@@ -1048,6 +1048,7 @@ status_t GLESRenderEngine::drawLayers(const DisplaySettings& display,

    setOutputDataSpace(display.outputDataspace);
    setDisplayMaxLuminance(display.maxLuminance);
    setDisplayColorTransform(display.colorTransform);

    const mat4 projectionMatrix =
            ui::Transform(display.orientation).asMatrix4() * mState.projectionMatrix;
@@ -1114,7 +1115,7 @@ status_t GLESRenderEngine::drawLayers(const DisplaySettings& display,
        position[3] = vec2(bounds.right, bounds.top);

        setupLayerCropping(*layer, mesh);
        setColorTransform(display.colorTransform * layer->colorTransform);
        setColorTransform(layer->colorTransform);

        bool usePremultipliedAlpha = true;
        bool disableTexture = true;
@@ -1271,6 +1272,10 @@ void GLESRenderEngine::setColorTransform(const mat4& colorTransform) {
    mState.colorMatrix = colorTransform;
}

void GLESRenderEngine::setDisplayColorTransform(const mat4& colorTransform) {
    mState.displayColorMatrix = colorTransform;
}

void GLESRenderEngine::disableTexturing() {
    mState.textureEnabled = false;
}
+1 −0
Original line number Diff line number Diff line
@@ -159,6 +159,7 @@ private:
    void setupLayerTexturing(const Texture& texture);
    void setupFillWithColor(float r, float g, float b, float a);
    void setColorTransform(const mat4& colorTransform);
    void setDisplayColorTransform(const mat4& colorTransform);
    void disableTexturing();
    void disableBlending();
    void setupCornerRadiusCropSize(float width, float height);
+4 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ Program::Program(const ProgramCache::Key& /*needs*/, const char* vertex, const c
        mTextureMatrixLoc = glGetUniformLocation(programId, "texture");
        mSamplerLoc = glGetUniformLocation(programId, "sampler");
        mColorLoc = glGetUniformLocation(programId, "color");
        mDisplayColorMatrixLoc = glGetUniformLocation(programId, "displayColorMatrix");
        mDisplayMaxLuminanceLoc = glGetUniformLocation(programId, "displayMaxLuminance");
        mMaxMasteringLuminanceLoc = glGetUniformLocation(programId, "maxMasteringLuminance");
        mMaxContentLuminanceLoc = glGetUniformLocation(programId, "maxContentLuminance");
@@ -129,6 +130,9 @@ void Program::setUniforms(const Description& desc) {
        const float color[4] = {desc.color.r, desc.color.g, desc.color.b, desc.color.a};
        glUniform4fv(mColorLoc, 1, color);
    }
    if (mDisplayColorMatrixLoc >= 0) {
        glUniformMatrix4fv(mDisplayColorMatrixLoc, 1, GL_FALSE, desc.displayColorMatrix.asArray());
    }
    if (mInputTransformMatrixLoc >= 0) {
        mat4 inputTransformMatrix = desc.inputTransformMatrix;
        glUniformMatrix4fv(mInputTransformMatrixLoc, 1, GL_FALSE, inputTransformMatrix.asArray());
+1 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ private:
    /* location of transform matrix */
    GLint mInputTransformMatrixLoc;
    GLint mOutputTransformMatrixLoc;
    GLint mDisplayColorMatrixLoc;

    /* location of corner radius uniform */
    GLint mCornerRadiusLoc;
Loading