[SurfaceFlinger] Allow force a supported color mode.
Device now can force color mode by setting persist.sys.sf.color_mode.
persist.sys.sf.color_mode must:
1. not be NATIVE color mode, NATIVE color mode means no forced color mode;
2. be one of the supported color modes returned by hardware composer,
otherwise it will not be respected.
persist.sys.sf.color_mode will only take effect when persist.sys.sf.native_mode
is not set to 1.
Minor: Fix some color profile tests.
BUG: 124129486
Test: Build, flash and boot. Verify by hacking Pixel 3.
Change-Id: I6aa4cff5aec16f0953d63e698919b41d617ea111
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 5f8de83..954ecda 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -767,6 +767,9 @@
property_get("persist.sys.sf.native_mode", value, "0");
mDisplayColorSetting = static_cast<DisplayColorSetting>(atoi(value));
+
+ property_get("persist.sys.sf.color_mode", value, "0");
+ mForceColorMode = static_cast<ColorMode>(atoi(value));
}
void SurfaceFlinger::startBootAnim() {
@@ -2394,6 +2397,17 @@
auto* profile = display->getCompositionDisplay()->getDisplayColorProfile();
+ switch (mForceColorMode) {
+ case ColorMode::SRGB:
+ bestDataSpace = Dataspace::V0_SRGB;
+ break;
+ case ColorMode::DISPLAY_P3:
+ bestDataSpace = Dataspace::DISPLAY_P3;
+ break;
+ default:
+ break;
+ }
+
// respect hdrDataSpace only when there is no legacy HDR support
const bool isHdr =
hdrDataSpace != Dataspace::UNKNOWN && !profile->hasLegacyHdrSupport(hdrDataSpace);