Skip to content

Commit 45cf987

Browse files
AMouriGerrit Code Review
authored andcommitted
Merge "Remove the WCG check from switch Color Modes" into main
2 parents fd474d7 + 0b150b7 commit 45cf987

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
@@ -260,10 +260,6 @@ const HdrCapabilities& DisplayColorProfile::getHdrCapabilities() const {
260260

261261
void DisplayColorProfile::populateColorModes(
262262
const DisplayColorProfileCreationArgs::HwcColorModes& hwcColorModes) {
263-
if (!hasWideColorGamut()) {
264-
return;
265-
}
266-
267263
// collect all known SDR render intents
268264
std::unordered_set<RenderIntent> sdrRenderIntents(sSdrRenderIntents.begin(),
269265
sSdrRenderIntents.end());
@@ -352,13 +348,9 @@ void DisplayColorProfile::getBestColorMode(Dataspace dataspace, RenderIntent int
352348
*outMode = iter->second.colorMode;
353349
*outIntent = iter->second.renderIntent;
354350
} else {
355-
// this is unexpected on a WCG display
356-
if (hasWideColorGamut()) {
357-
ALOGE("map unknown (%s)/(%s) to default color mode",
358-
dataspaceDetails(static_cast<android_dataspace_t>(dataspace)).c_str(),
359-
decodeRenderIntent(intent).c_str());
360-
}
361-
351+
ALOGI("map unknown (%s)/(%s) to default color mode",
352+
dataspaceDetails(static_cast<android_dataspace_t>(dataspace)).c_str(),
353+
decodeRenderIntent(intent).c_str());
362354
*outDataspace = Dataspace::UNKNOWN;
363355
*outMode = ColorMode::NATIVE;
364356
*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)
@@ -289,7 +289,7 @@ TEST_F(DisplayColorProfileTest, ctorUsesOrDefaultsLuminanceValuesFromInputArgs)
289289
TEST_F(DisplayColorProfileTest, hasRenderIntentReturnsExpectedValueWhenOutputHasNoSupport) {
290290
auto profile = ProfileFactory::createProfileWithNoColorModeSupport();
291291

292-
EXPECT_FALSE(profile.hasRenderIntent(RenderIntent::COLORIMETRIC));
292+
EXPECT_TRUE(profile.hasRenderIntent(RenderIntent::COLORIMETRIC));
293293
EXPECT_FALSE(profile.hasRenderIntent(RenderIntent::ENHANCE));
294294
EXPECT_FALSE(profile.hasRenderIntent(RenderIntent::TONE_MAP_COLORIMETRIC));
295295
EXPECT_FALSE(profile.hasRenderIntent(RenderIntent::TONE_MAP_ENHANCE));
@@ -306,6 +306,16 @@ TEST_F(DisplayColorProfileTest, hasRenderIntentReturnsExpectedValueWhenOutputHas
306306
EXPECT_FALSE(profile.hasRenderIntent(VendorRenderIntent));
307307
}
308308

309+
TEST_F(DisplayColorProfileTest, hasRenderIntentReturnsExpectedValueWhenOutputHasSRGBSupport_NoWCG) {
310+
auto profile = ProfileFactory::createProfileWithSRGBColorModeSupport(false);
311+
312+
EXPECT_TRUE(profile.hasRenderIntent(RenderIntent::COLORIMETRIC));
313+
EXPECT_TRUE(profile.hasRenderIntent(RenderIntent::ENHANCE));
314+
EXPECT_FALSE(profile.hasRenderIntent(RenderIntent::TONE_MAP_COLORIMETRIC));
315+
EXPECT_FALSE(profile.hasRenderIntent(RenderIntent::TONE_MAP_ENHANCE));
316+
EXPECT_TRUE(profile.hasRenderIntent(VendorRenderIntent));
317+
}
318+
309319
TEST_F(DisplayColorProfileTest, hasRenderIntentReturnsExpectedValueWhenOutputHasSRGBSupport) {
310320
auto profile = ProfileFactory::createProfileWithSRGBColorModeSupport();
311321

@@ -476,6 +486,40 @@ TEST_F(DisplayColorProfileTest, getBestColorModeReturnsExpectedModesWhenOutputHa
476486
checkGetBestColorMode(profile, expectedResults);
477487
}
478488

489+
TEST_F(DisplayColorProfileTest,
490+
getBestColorModeReturnsExpectedModesWhenOutputHasSRGBSupport_NoWCG) {
491+
auto profile = ProfileFactory::createProfileWithSRGBColorModeSupport(false);
492+
493+
// Note: This table of expected values goes with the table of arguments
494+
// used in checkGetBestColorMode.
495+
using Result = std::tuple<Dataspace, ColorMode, RenderIntent>;
496+
std::array<Result, 15> expectedResults = {
497+
/* clang-format off */
498+
/* 0 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
499+
/* 1 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::ENHANCE},
500+
/* 2 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, VendorRenderIntent},
501+
502+
/* 3 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
503+
/* 4 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::ENHANCE},
504+
/* 5 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, VendorRenderIntent},
505+
506+
/* 6 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
507+
/* 7 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::ENHANCE},
508+
/* 8 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, VendorRenderIntent},
509+
510+
/* 9 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
511+
/* 10 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
512+
/* 11 */ Result{Dataspace::UNKNOWN, ColorMode::NATIVE, RenderIntent::COLORIMETRIC},
513+
514+
/* 12 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
515+
/* 13 */ Result{Dataspace::V0_SRGB, ColorMode::SRGB, RenderIntent::COLORIMETRIC},
516+
/* 14 */ Result{Dataspace::UNKNOWN, ColorMode::NATIVE, RenderIntent::COLORIMETRIC},
517+
/* clang-format on */
518+
};
519+
520+
checkGetBestColorMode(profile, expectedResults);
521+
}
522+
479523
TEST_F(DisplayColorProfileTest, getBestColorModeReturnsExpectedModesWhenOutputHasSRGBSupport) {
480524
auto profile = ProfileFactory::createProfileWithSRGBColorModeSupport();
481525

0 commit comments

Comments
 (0)