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

Commit c53d3558 authored by Romain Guy's avatar Romain Guy
Browse files

Postpone color mode change until after boot animation

sRGB is only set by SurfaceFlinger when the default display is
wide color capable. Since we compute the best color mode on
every frame anyway for wide color capable displays, we can
simply move the sRGB set to the end of the boot animation.

Bug: 63823274
Test: Manual
Change-Id: I11bb6095acb63e66bcf7dff9e3f7b36588e371c1
parent 349abaf5
Loading
Loading
Loading
Loading
+18 −10
Original line number Original line Diff line number Diff line
@@ -354,7 +354,6 @@ void SurfaceFlinger::bootFinished()
    const nsecs_t now = systemTime();
    const nsecs_t now = systemTime();
    const nsecs_t duration = now - mBootTime;
    const nsecs_t duration = now - mBootTime;
    ALOGI("Boot is finished (%ld ms)", long(ns2ms(duration)) );
    ALOGI("Boot is finished (%ld ms)", long(ns2ms(duration)) );
    mBootFinished = true;


    // wait patiently for the window manager death
    // wait patiently for the window manager death
    const String16 name("window");
    const String16 name("window");
@@ -376,10 +375,19 @@ void SurfaceFlinger::bootFinished()
    LOG_EVENT_LONG(LOGTAG_SF_STOP_BOOTANIM,
    LOG_EVENT_LONG(LOGTAG_SF_STOP_BOOTANIM,
                   ns2ms(systemTime(SYSTEM_TIME_MONOTONIC)));
                   ns2ms(systemTime(SYSTEM_TIME_MONOTONIC)));


    sp<LambdaMessage> readProperties = new LambdaMessage([&]() {
    sp<LambdaMessage> bootFinished = new LambdaMessage([&]() {
        mBootFinished = true;

        readPersistentProperties();
        readPersistentProperties();

#ifdef USE_HWC2
        sp<DisplayDevice> hw(getDisplayDevice(mBuiltinDisplays[DisplayDevice::DISPLAY_PRIMARY]));
        if (hw->getWideColorSupport()) {
            setActiveColorModeInternal(hw, HAL_COLOR_MODE_SRGB);
        }
#endif
    });
    });
    postMessageAsync(readProperties);
    postMessageAsync(bootFinished);
}
}


void SurfaceFlinger::deleteTextureAsync(uint32_t texture) {
void SurfaceFlinger::deleteTextureAsync(uint32_t texture) {
@@ -544,7 +552,7 @@ void SurfaceFlinger::init() {
    ALOGI(  "SurfaceFlinger's main thread ready to run. "
    ALOGI(  "SurfaceFlinger's main thread ready to run. "
            "Initializing graphics H/W...");
            "Initializing graphics H/W...");


    ALOGI("Phase offest NS: %" PRId64 "", vsyncPhaseOffsetNs);
    ALOGI("Phase offset NS: %" PRId64 "", vsyncPhaseOffsetNs);


    { // Autolock scope
    { // Autolock scope
        Mutex::Autolock _l(mStateLock);
        Mutex::Autolock _l(mStateLock);
@@ -1213,11 +1221,7 @@ void SurfaceFlinger::createDefaultDisplayDevice() {
                                             token, fbs, producer, mRenderEngine->getEGLConfig(),
                                             token, fbs, producer, mRenderEngine->getEGLConfig(),
                                             hasWideColorModes && hasWideColorDisplay);
                                             hasWideColorModes && hasWideColorDisplay);
    mDisplays.add(token, hw);
    mDisplays.add(token, hw);
    android_color_mode defaultColorMode = HAL_COLOR_MODE_NATIVE;
    setActiveColorModeInternal(hw, HAL_COLOR_MODE_NATIVE);
    if (hasWideColorModes && hasWideColorDisplay) {
        defaultColorMode = HAL_COLOR_MODE_SRGB;
    }
    setActiveColorModeInternal(hw, defaultColorMode);
}
}


void SurfaceFlinger::onHotplugReceived(HWComposer* composer, int32_t disp, bool connected) {
void SurfaceFlinger::onHotplugReceived(HWComposer* composer, int32_t disp, bool connected) {
@@ -1863,9 +1867,13 @@ void SurfaceFlinger::setUpHWComposer() {
            }
            }
            newColorMode = pickColorMode(newDataSpace);
            newColorMode = pickColorMode(newDataSpace);


            // We want the color mode of the boot animation to match that of the bootloader
            // To achieve this we suppress color mode changes until after the boot animation
            if (mBootFinished) {
                setActiveColorModeInternal(displayDevice, newColorMode);
                setActiveColorModeInternal(displayDevice, newColorMode);
            }
            }
        }
        }
    }


    mPreviousColorMatrix = colorMatrix;
    mPreviousColorMatrix = colorMatrix;