Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b150b7c authored by RuXin Jiang's avatar RuXin Jiang Committed by Snild Dolkow
Browse files

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: default avatarSnild Dolkow <snild@sony.com>
Change-Id: I91ddf9cb6ffd1fb7accf2985f006720f4d02c65b
parent 3b7bc1dd
Loading
Loading
Loading
Loading
+3 −11
Original line number Diff line number Diff line
@@ -271,10 +271,6 @@ const HdrCapabilities& DisplayColorProfile::getHdrCapabilities() const {

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 @@ void DisplayColorProfile::getBestColorMode(Dataspace dataspace, RenderIntent int
        *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",
        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;
+47 −3
Original line number Diff line number Diff line
@@ -123,10 +123,10 @@ public:
                .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, ctorSignalsHdrSupportForAnyWideColorGamutDevice)
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 @@ TEST_F(DisplayColorProfileTest, hasRenderIntentReturnsExpectedValueWhenOutputHas
    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 @@ TEST_F(DisplayColorProfileTest, getBestColorModeReturnsExpectedModesWhenOutputHa
    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();