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

Commit a3ea559c authored by Peiyong Lin's avatar Peiyong Lin
Browse files

[SurfaceFlinger] Allow force a supported color mode.

Device now can force color mode by setting persist.sys.sf.color_mode.
persist.sys.sf.color_mode must:
    1. not be NATIVE color mode, NATIVE color mode means no forced color mode;
    2. be one of the supported color modes returned by hardware composer,
       otherwise it will not be respected.

persist.sys.sf.color_mode will only take effect when persist.sys.sf.native_mode
is not set to 1.

Minor: Fix some color profile tests.

BUG: 124129486
Test: Build, flash and boot. Verify by hacking Pixel 3.
Change-Id: I6aa4cff5aec16f0953d63e698919b41d617ea111
parent f1adb4aa
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -303,7 +303,7 @@ void DisplayColorProfile::populateColorModes(
    }

    // add all known HDR combinations
    for (auto intent : sHdrRenderIntents) {
    for (auto intent : hdrRenderIntents) {
        for (auto mode : sHdrColorModes) {
            addColorMode(hwcColorModes, mode, intent);
        }
+109 −111

File changed.

Preview size limit exceeded, changes collapsed.

+14 −0
Original line number Diff line number Diff line
@@ -767,6 +767,9 @@ void SurfaceFlinger::readPersistentProperties() {

    property_get("persist.sys.sf.native_mode", value, "0");
    mDisplayColorSetting = static_cast<DisplayColorSetting>(atoi(value));

    property_get("persist.sys.sf.color_mode", value, "0");
    mForceColorMode = static_cast<ColorMode>(atoi(value));
}

void SurfaceFlinger::startBootAnim() {
@@ -2394,6 +2397,17 @@ void SurfaceFlinger::pickColorMode(const sp<DisplayDevice>& display, ColorMode*

    auto* profile = display->getCompositionDisplay()->getDisplayColorProfile();

    switch (mForceColorMode) {
        case ColorMode::SRGB:
            bestDataSpace = Dataspace::V0_SRGB;
            break;
        case ColorMode::DISPLAY_P3:
            bestDataSpace = Dataspace::DISPLAY_P3;
            break;
        default:
            break;
    }

    // respect hdrDataSpace only when there is no legacy HDR support
    const bool isHdr =
            hdrDataSpace != Dataspace::UNKNOWN && !profile->hasLegacyHdrSupport(hdrDataSpace);
+9 −0
Original line number Diff line number Diff line
@@ -1069,6 +1069,15 @@ private:

    DisplayColorSetting mDisplayColorSetting = DisplayColorSetting::ENHANCED;

    // Color mode forced by setting persist.sys.sf.color_mode, it must:
    //     1. not be NATIVE color mode, NATIVE color mode means no forced color mode;
    //     2. be one of the supported color modes returned by hardware composer, otherwise
    //        it will not be respected.
    // persist.sys.sf.color_mode will only take effect when persist.sys.sf.native_mode
    // is not set to 1.
    // This property can be used to force SurfaceFlinger to always pick a certain color mode.
    ui::ColorMode mForceColorMode = ui::ColorMode::NATIVE;

    ui::Dataspace mDefaultCompositionDataspace;
    ui::Dataspace mWideColorGamutCompositionDataspace;