[SurfaceFlinger] Add methods for setting legacy starution matrix.
This patch adds methods for setting legacy saturation matrix for legacy sRGB
content. Previously it was combined into the color transform matrix which was
applied right before applying OETF, however, we want to apply the legacy
staturation matrix right after applying EOTF.
BUG: 78891890
Test: build
Change-Id: I7709eab0857822e48c49237d6681f6e337b4d29e
Merged-In: I7709eab0857822e48c49237d6681f6e337b4d29e
diff --git a/services/surfaceflinger/RenderEngine/Program.cpp b/services/surfaceflinger/RenderEngine/Program.cpp
index fd2c968..95adaca 100644
--- a/services/surfaceflinger/RenderEngine/Program.cpp
+++ b/services/surfaceflinger/RenderEngine/Program.cpp
@@ -135,13 +135,22 @@
glUniform4fv(mColorLoc, 1, color);
}
if (mInputTransformMatrixLoc >= 0) {
- glUniformMatrix3fv(mInputTransformMatrixLoc, 1, GL_FALSE,
- desc.mInputTransformMatrix.asArray());
+ // If the input transform matrix is not identity matrix, we want to merge
+ // the saturation matrix with input transform matrix so that the saturation
+ // matrix is applied at the correct stage.
+ mat4 inputTransformMatrix = mat4(desc.mInputTransformMatrix) * desc.mSaturationMatrix;
+ glUniformMatrix4fv(mInputTransformMatrixLoc, 1, GL_FALSE, inputTransformMatrix.asArray());
}
if (mOutputTransformMatrixLoc >= 0) {
// The output transform matrix and color matrix can be combined as one matrix
// that is applied right before applying OETF.
mat4 outputTransformMatrix = desc.mColorMatrix * desc.mOutputTransformMatrix;
+ // If there is no input transform matrix, we want to merge the saturation
+ // matrix with output transform matrix to avoid extra matrix multiplication
+ // in shader.
+ if (mInputTransformMatrixLoc < 0) {
+ outputTransformMatrix *= desc.mSaturationMatrix;
+ }
glUniformMatrix4fv(mOutputTransformMatrixLoc, 1, GL_FALSE,
outputTransformMatrix.asArray());
}