surfaceflinger: generalize Description::mIsWideGamut
Generalize the mIsWideGamut bool into input and output transfer
functions. In most cases, the transfer functions are LINEAR,
meaning EOTF() and OETF() are no-op.
Test: manual
Change-Id: I18bfa97ffa950190b553a2ebb18f68b72ab296dd
diff --git a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp
index d1ee6f8..745929d 100644
--- a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp
+++ b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp
@@ -130,14 +130,8 @@
// Compute sRGB to DisplayP3 color transform
// NOTE: For now, we are limiting wide-color support to
// Display-P3 only.
- mat3 srgbToP3 =
- ColorSpaceConnector(ColorSpace::sRGB(), ColorSpace::DisplayP3()).getTransform();
-
- // color transform needs to be expanded to 4x4 to be what the shader wants
- // mat has an initializer that expands mat3 to mat4, but
- // not an assignment operator
- mat4 gamutTransform(srgbToP3);
- mSrgbToDisplayP3 = gamutTransform;
+ mSrgbToDisplayP3 = mat4(
+ ColorSpaceConnector(ColorSpace::sRGB(), ColorSpace::DisplayP3()).getTransform());
}
}
@@ -324,10 +318,16 @@
if (usesWideColor()) {
Description wideColorState = mState;
- if (mDataSpace != HAL_DATASPACE_DISPLAY_P3) {
- wideColorState.setColorMatrix(mState.getColorMatrix() * mSrgbToDisplayP3);
- wideColorState.setWideGamut(true);
- ALOGV("drawMesh: gamut transform applied");
+ switch (mDataSpace) {
+ case HAL_DATASPACE_DISPLAY_P3:
+ // input matches output
+ break;
+ default:
+ wideColorState.setColorMatrix(mState.getColorMatrix() * mSrgbToDisplayP3);
+ wideColorState.setInputTransferFunction(Description::TransferFunction::SRGB);
+ wideColorState.setOutputTransferFunction(Description::TransferFunction::SRGB);
+ ALOGV("drawMesh: gamut transform applied");
+ break;
}
ProgramCache::getInstance().useProgram(wideColorState);