Remove the WCG check from switch Color Modes
For devices that doesn't support Wide Color Gamut,
color modes can't be switched due to WCG check
condition within populateColorModes.
Remove WCG check from populateColorModes,so that
color mode can be switched correctly.
Bug: 304471085
Test: CtsDisplayTestCases
Test: CtsGraphicsTestCases
Test: CtsMediaV2TestCases
Test: many more CTS modules
Test: manual-switch color modes
Test: manual-check white balance
Test: manualuse commands to check if renderintent value is correct
Iffy-tests-added-by: Snild Dolkow <snild@sony.com>
Change-Id: I91ddf9cb6ffd1fb7accf2985f006720f4d02c65b
diff --git a/services/surfaceflinger/CompositionEngine/src/DisplayColorProfile.cpp b/services/surfaceflinger/CompositionEngine/src/DisplayColorProfile.cpp
index a7c4512..98c25ba 100644
--- a/services/surfaceflinger/CompositionEngine/src/DisplayColorProfile.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/DisplayColorProfile.cpp
@@ -271,10 +271,6 @@
void DisplayColorProfile::populateColorModes(
const DisplayColorProfileCreationArgs::HwcColorModes& hwcColorModes) {
- if (!hasWideColorGamut()) {
- return;
- }
-
// collect all known SDR render intents
std::unordered_set<RenderIntent> sdrRenderIntents(sSdrRenderIntents.begin(),
sSdrRenderIntents.end());
@@ -363,13 +359,9 @@
*outMode = iter->second.colorMode;
*outIntent = iter->second.renderIntent;
} else {
- // this is unexpected on a WCG display
- if (hasWideColorGamut()) {
- ALOGE("map unknown (%s)/(%s) to default color mode",
- dataspaceDetails(static_cast<android_dataspace_t>(dataspace)).c_str(),
- decodeRenderIntent(intent).c_str());
- }
-
+ ALOGI("map unknown (%s)/(%s) to default color mode",
+ dataspaceDetails(static_cast<android_dataspace_t>(dataspace)).c_str(),
+ decodeRenderIntent(intent).c_str());
*outDataspace = Dataspace::UNKNOWN;
*outMode = ColorMode::NATIVE;
*outIntent = RenderIntent::COLORIMETRIC;
diff --git a/services/surfaceflinger/CompositionEngine/tests/DisplayColorProfileTest.cpp b/services/surfaceflinger/CompositionEngine/tests/DisplayColorProfileTest.cpp
index 21b9aa9..518081a 100644
--- a/services/surfaceflinger/CompositionEngine/tests/DisplayColorProfileTest.cpp
+++ b/services/surfaceflinger/CompositionEngine/tests/DisplayColorProfileTest.cpp
@@ -123,10 +123,10 @@
.build();
}
- static impl::DisplayColorProfile createProfileWithSRGBColorModeSupport() {
+ static impl::DisplayColorProfile createProfileWithSRGBColorModeSupport(bool wcg = true) {
return ProfileFactory()
- .setHasWideColorGamut(true)
.addHdrType(Hdr::HDR10)
+ .setHasWideColorGamut(wcg)
.addColorModeRenderIntent(ColorMode::SRGB, RenderIntent::COLORIMETRIC)
.addColorModeRenderIntent(ColorMode::SRGB, RenderIntent::ENHANCE)
.addColorModeRenderIntent(ColorMode::SRGB, VendorRenderIntent)
@@ -322,7 +322,7 @@
TEST_F(DisplayColorProfileTest, hasRenderIntentReturnsExpectedValueWhenOutputHasNoSupport) {
auto profile = ProfileFactory::createProfileWithNoColorModeSupport();
- EXPECT_FALSE(profile.hasRenderIntent(RenderIntent::COLORIMETRIC));
+ EXPECT_TRUE(profile.hasRenderIntent(RenderIntent::COLORIMETRIC));
EXPECT_FALSE(profile.hasRenderIntent(RenderIntent::ENHANCE));
EXPECT_FALSE(profile.hasRenderIntent(RenderIntent::TONE_MAP_COLORIMETRIC));
EXPECT_FALSE(profile.hasRenderIntent(RenderIntent::TONE_MAP_ENHANCE));
@@ -339,6 +339,16 @@
EXPECT_FALSE(profile.hasRenderIntent(VendorRenderIntent));
}
+TEST_F(DisplayColorProfileTest, hasRenderIntentReturnsExpectedValueWhenOutputHasSRGBSupport_NoWCG) {
+ auto profile = ProfileFactory::createProfileWithSRGBColorModeSupport(false);
+
+ EXPECT_TRUE(profile.hasRenderIntent(RenderIntent::COLORIMETRIC));
+ EXPECT_TRUE(profile.hasRenderIntent(RenderIntent::ENHANCE));
+ EXPECT_FALSE(profile.hasRenderIntent(RenderIntent::TONE_MAP_COLORIMETRIC));
+ EXPECT_FALSE(profile.hasRenderIntent(RenderIntent::TONE_MAP_ENHANCE));
+ EXPECT_TRUE(profile.hasRenderIntent(VendorRenderIntent));
+}
+
TEST_F(DisplayColorProfileTest, hasRenderIntentReturnsExpectedValueWhenOutputHasSRGBSupport) {
auto profile = ProfileFactory::createProfileWithSRGBColorModeSupport();
@@ -509,6 +519,40 @@
checkGetBestColorMode(profile, expectedResults);
}
+TEST_F(DisplayColorProfileTest,
+ getBestColorModeReturnsExpectedModesWhenOutputHasSRGBSupport_NoWCG) {
+ auto profile = ProfileFactory::createProfileWithSRGBColorModeSupport(false);
+
+ // Note: This table of expected values goes with the table of arguments
+ // used in checkGetBestColorMode.
+ using Result = std::tuple<Dataspace, ColorMode, RenderIntent>;
+ std::array<Result, 15> expectedResults = {
+ /* clang-format off */
+ /* 0 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
+ /* 1 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::ENHANCE},
+ /* 2 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, VendorRenderIntent},
+
+ /* 3 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
+ /* 4 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::ENHANCE},
+ /* 5 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, VendorRenderIntent},
+
+ /* 6 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
+ /* 7 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::ENHANCE},
+ /* 8 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, VendorRenderIntent},
+
+ /* 9 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
+ /* 10 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
+ /* 11 */ Result{Dataspace::UNKNOWN, ColorMode::NATIVE, RenderIntent::COLORIMETRIC},
+
+ /* 12 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
+ /* 13 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
+ /* 14 */ Result{Dataspace::UNKNOWN, ColorMode::NATIVE, RenderIntent::COLORIMETRIC},
+ /* clang-format on */
+ };
+
+ checkGetBestColorMode(profile, expectedResults);
+}
+
TEST_F(DisplayColorProfileTest, getBestColorModeReturnsExpectedModesWhenOutputHasSRGBSupport) {
auto profile = ProfileFactory::createProfileWithSRGBColorModeSupport();