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

Commit 38e9a561 authored by Peiyong Lin's avatar Peiyong Lin
Browse files

[SurfaceFlinger] Fix color mode switch.

Previously we didn't take render intent into account when switch color mode,
switching from staturated to automatic and then to natural/boosted doesn't
work.

BUG: 73824924
BUG: 73825729
Test: Built, flashed to taimen, and verified with Color settings.
Change-Id: I4556e82e2bab10113d05c446fc4bb3351a3e65a6
parent ac6521d7
Loading
Loading
Loading
Loading
+14 −11
Original line number Diff line number Diff line
@@ -1020,18 +1020,8 @@ void SurfaceFlinger::setActiveColorModeInternal(const sp<DisplayDevice>& hw,
    int32_t type = hw->getDisplayType();
    ColorMode currentMode = hw->getActiveColorMode();
    Dataspace currentDataSpace = hw->getCompositionDataSpace();
    RenderIntent currentRenderIntent = hw->getActiveRenderIntent();

    if (mode == currentMode && dataSpace == currentDataSpace) {
        return;
    }

    if (type >= DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) {
        ALOGW("Trying to set config for virtual display");
        return;
    }

    hw->setActiveColorMode(mode);
    hw->setCompositionDataSpace(dataSpace);
    // Natural Mode means it's color managed and the color must be right,
    // thus we pick RenderIntent::COLORIMETRIC as render intent.
    // Native Mode means the display is not color managed, and whichever
@@ -1046,6 +1036,19 @@ void SurfaceFlinger::setActiveColorModeInternal(const sp<DisplayDevice>& hw,
        hw->getDisplayType() == DisplayDevice::DISPLAY_PRIMARY) {
        renderIntent = RenderIntent::ENHANCE;
    }

    if (mode == currentMode && dataSpace == currentDataSpace &&
        renderIntent == currentRenderIntent) {
        return;
    }

    if (type >= DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) {
        ALOGW("Trying to set config for virtual display");
        return;
    }

    hw->setActiveColorMode(mode);
    hw->setCompositionDataSpace(dataSpace);
    hw->setActiveRenderIntent(renderIntent);
    getHwComposer().setActiveColorMode(type, mode, renderIntent);