surfaceflinger: no re-saturation when in SRGB mode
Under ColorMode::SRGB and RenderIntent::ENHANCE, HWC always applies
the legacy sRGB saturation matrix. SurfaceFlinger should not apply
the matrix.
Bug: 78891890
Test: no color shift when forcing GPU fallback
Change-Id: I7ebbefa38c5a6b72d326e0b2d4eee52d8409b5c7
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 7a4bc2a..95287d2 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1873,13 +1873,13 @@
// Returns a dataspace that fits all visible layers. The returned dataspace
// can only be one of
//
-// - Dataspace::V0_SRGB
+// - Dataspace::SRGB (use legacy dataspace and let HWC saturate when colors are enhanced)
// - Dataspace::DISPLAY_P3
// - Dataspace::V0_SCRGB_LINEAR
// TODO(b/73825729) Add BT2020 data space.
ui::Dataspace SurfaceFlinger::getBestDataspace(
const sp<const DisplayDevice>& displayDevice) const {
- Dataspace bestDataspace = Dataspace::V0_SRGB;
+ Dataspace bestDataspace = Dataspace::SRGB;
for (const auto& layer : displayDevice->getVisibleLayersSortedByZ()) {
switch (layer->getDataSpace()) {
case Dataspace::V0_SCRGB:
@@ -1930,7 +1930,7 @@
break;
default:
*outMode = ColorMode::SRGB;
- *outDataSpace = Dataspace::V0_SRGB;
+ *outDataSpace = Dataspace::SRGB;
break;
}
}
@@ -2901,7 +2901,9 @@
colorMatrix = mDrawingState.colorMatrix;
}
- applyLegacyColorMatrix = mDisplayColorSetting == DisplayColorSetting::ENHANCED;
+ applyLegacyColorMatrix = (mDisplayColorSetting == DisplayColorSetting::ENHANCED &&
+ outputDataspace != Dataspace::UNKNOWN &&
+ outputDataspace != Dataspace::SRGB);
if (applyLegacyColorMatrix) {
if (applyColorMatrix) {
legacyColorMatrix = colorMatrix * mLegacySrgbSaturationMatrix;