Skip to content

Commit 0b150b7

Browse files
RuXin JiangSnild-Sony
authored andcommitted
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
1 parent 3b7bc1d commit 0b150b7

2 files changed

Lines changed: 50 additions & 14 deletions

File tree

services/surfaceflinger/CompositionEngine/src/DisplayColorProfile.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,6 @@ const HdrCapabilities& DisplayColorProfile::getHdrCapabilities() const {
271271

272272
void DisplayColorProfile::populateColorModes(
273273
const DisplayColorProfileCreationArgs::HwcColorModes& hwcColorModes) {
274-
if (!hasWideColorGamut()) {
275-
return;
276-
}
277-
278274
// collect all known SDR render intents
279275
std::unordered_set<RenderIntent> sdrRenderIntents(sSdrRenderIntents.begin(),
280276
sSdrRenderIntents.end());
@@ -363,13 +359,9 @@ void DisplayColorProfile::getBestColorMode(Dataspace dataspace, RenderIntent int
363359
*outMode = iter->second.colorMode;
364360
*outIntent = iter->second.renderIntent;
365361
} else {
366-
// this is unexpected on a WCG display
367-
if (hasWideColorGamut()) {
368-
ALOGE("map unknown (%s)/(%s) to default color mode",
369-
dataspaceDetails(static_cast<android_dataspace_t>(dataspace)).c_str(),
370-
decodeRenderIntent(intent).c_str());
371-
}
372-
362+
ALOGI("map unknown (%s)/(%s) to default color mode",
363+
dataspaceDetails(static_cast<android_dataspace_t>(dataspace)).c_str(),
364+
decodeRenderIntent(intent).c_str());
373365
*outDataspace = Dataspace::UNKNOWN;
374366
*outMode = ColorMode::NATIVE;
375367
*outIntent = RenderIntent::COLORIMETRIC;

services/surfaceflinger/CompositionEngine/tests/DisplayColorProfileTest.cpp

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ class ProfileFactory {
123123
.build();
124124
}
125125

126-
static impl::DisplayColorProfile createProfileWithSRGBColorModeSupport() {
126+
static impl::DisplayColorProfile createProfileWithSRGBColorModeSupport(bool wcg = true) {
127127
return ProfileFactory()
128-
.setHasWideColorGamut(true)
129128
.addHdrType(Hdr::HDR10)
129+
.setHasWideColorGamut(wcg)
130130
.addColorModeRenderIntent(ColorMode::SRGB, RenderIntent::COLORIMETRIC)
131131
.addColorModeRenderIntent(ColorMode::SRGB, RenderIntent::ENHANCE)
132132
.addColorModeRenderIntent(ColorMode::SRGB, VendorRenderIntent)
@@ -322,7 +322,7 @@ TEST_F(DisplayColorProfileTest, ctorSignalsHdrSupportForAnyWideColorGamutDevice)
322322
TEST_F(DisplayColorProfileTest, hasRenderIntentReturnsExpectedValueWhenOutputHasNoSupport) {
323323
auto profile = ProfileFactory::createProfileWithNoColorModeSupport();
324324

325-
EXPECT_FALSE(profile.hasRenderIntent(RenderIntent::COLORIMETRIC));
325+
EXPECT_TRUE(profile.hasRenderIntent(RenderIntent::COLORIMETRIC));
326326
EXPECT_FALSE(profile.hasRenderIntent(RenderIntent::ENHANCE));
327327
EXPECT_FALSE(profile.hasRenderIntent(RenderIntent::TONE_MAP_COLORIMETRIC));
328328
EXPECT_FALSE(profile.hasRenderIntent(RenderIntent::TONE_MAP_ENHANCE));
@@ -339,6 +339,16 @@ TEST_F(DisplayColorProfileTest, hasRenderIntentReturnsExpectedValueWhenOutputHas
339339
EXPECT_FALSE(profile.hasRenderIntent(VendorRenderIntent));
340340
}
341341

342+
TEST_F(DisplayColorProfileTest, hasRenderIntentReturnsExpectedValueWhenOutputHasSRGBSupport_NoWCG) {
343+
auto profile = ProfileFactory::createProfileWithSRGBColorModeSupport(false);
344+
345+
EXPECT_TRUE(profile.hasRenderIntent(RenderIntent::COLORIMETRIC));
346+
EXPECT_TRUE(profile.hasRenderIntent(RenderIntent::ENHANCE));
347+
EXPECT_FALSE(profile.hasRenderIntent(RenderIntent::TONE_MAP_COLORIMETRIC));
348+
EXPECT_FALSE(profile.hasRenderIntent(RenderIntent::TONE_MAP_ENHANCE));
349+
EXPECT_TRUE(profile.hasRenderIntent(VendorRenderIntent));
350+
}
351+
342352
TEST_F(DisplayColorProfileTest, hasRenderIntentReturnsExpectedValueWhenOutputHasSRGBSupport) {
343353
auto profile = ProfileFactory::createProfileWithSRGBColorModeSupport();
344354

@@ -509,6 +519,40 @@ TEST_F(DisplayColorProfileTest, getBestColorModeReturnsExpectedModesWhenOutputHa
509519
checkGetBestColorMode(profile, expectedResults);
510520
}
511521

522+
TEST_F(DisplayColorProfileTest,
523+
getBestColorModeReturnsExpectedModesWhenOutputHasSRGBSupport_NoWCG) {
524+
auto profile = ProfileFactory::createProfileWithSRGBColorModeSupport(false);
525+
526+
// Note: This table of expected values goes with the table of arguments
527+
// used in checkGetBestColorMode.
528+
using Result = std::tuple<Dataspace, ColorMode, RenderIntent>;
529+
std::array<Result, 15> expectedResults = {
530+
/* clang-format off */
531+
/* 0 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
532+
/* 1 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::ENHANCE},
533+
/* 2 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, VendorRenderIntent},
534+
535+
/* 3 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
536+
/* 4 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::ENHANCE},
537+
/* 5 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, VendorRenderIntent},
538+
539+
/* 6 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
540+
/* 7 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::ENHANCE},
541+
/* 8 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, VendorRenderIntent},
542+
543+
/* 9 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
544+
/* 10 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
545+
/* 11 */ Result{Dataspace::UNKNOWN, ColorMode::NATIVE, RenderIntent::COLORIMETRIC},
546+
547+
/* 12 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
548+
/* 13 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
549+
/* 14 */ Result{Dataspace::UNKNOWN, ColorMode::NATIVE, RenderIntent::COLORIMETRIC},
550+
/* clang-format on */
551+
};
552+
553+
checkGetBestColorMode(profile, expectedResults);
554+
}
555+
512556
TEST_F(DisplayColorProfileTest, getBestColorModeReturnsExpectedModesWhenOutputHasSRGBSupport) {
513557
auto profile = ProfileFactory::createProfileWithSRGBColorModeSupport();
514558

0 commit comments

Comments
 (0)