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

Commit b74c88be authored by Alec Mouri's avatar Alec Mouri Committed by Automerger Merge Worker
Browse files

Merge "Remove the WCG check from switch Color Modes" into main am: 45cf9878

parents b90b1c14 45cf9878
Loading
Loading
Loading
Loading
+3 −11
Original line number Diff line number Diff line
@@ -260,10 +260,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());
@@ -352,13 +348,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)
@@ -289,7 +289,7 @@ TEST_F(DisplayColorProfileTest, ctorUsesOrDefaultsLuminanceValuesFromInputArgs)
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));
@@ -306,6 +306,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();

@@ -476,6 +486,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();