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

Commit 3008021e authored by Ady Abraham's avatar Ady Abraham Committed by Android (Google) Code Review
Browse files

Merge changes Iec9cde3b,I63916801 into main

* changes:
  SF: omit vsync callbacks when screen is OFF
  SF: add a new flag for omiting vsync on screen is OFF
parents 27e2f43f 8e3e2ea8
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -201,6 +201,10 @@ bool DisplayDevice::isPoweredOn() const {
    return mPowerMode != hal::PowerMode::OFF;
}

bool DisplayDevice::isRefreshable() const {
    return mPowerMode == hal::PowerMode::DOZE || mPowerMode == hal::PowerMode::ON;
}

ui::Dataspace DisplayDevice::getCompositionDataSpace() const {
    return mCompositionDisplay->getState().dataspace;
}
+1 −0
Original line number Diff line number Diff line
@@ -173,6 +173,7 @@ public:
    hardware::graphics::composer::hal::PowerMode getPowerMode() const;
    void setPowerMode(hardware::graphics::composer::hal::PowerMode);
    bool isPoweredOn() const;
    bool isRefreshable() const;
    void tracePowerMode();

    // Enables layer caching on this DisplayDevice
+21 −1
Original line number Diff line number Diff line
@@ -420,6 +420,16 @@ void EventThread::enableSyntheticVsync(bool enable) {
    mCondition.notify_all();
}

void EventThread::omitVsyncDispatching(bool omitted) {
    std::lock_guard<std::mutex> lock(mMutex);
    if (!mVSyncState || mVSyncState->omitted == omitted) {
        return;
    }

    mVSyncState->omitted = omitted;
    mCondition.notify_all();
}

void EventThread::onVsync(nsecs_t vsyncTime, nsecs_t wakeupTime, nsecs_t readyTime) {
    std::lock_guard<std::mutex> lock(mMutex);
    mLastVsyncCallbackTime = TimePoint::fromNs(vsyncTime);
@@ -521,7 +531,17 @@ void EventThread::threadMain(std::unique_lock<std::mutex>& lock) {
        }

        if (mVSyncState && vsyncRequested) {
            const bool vsyncOmitted =
                    FlagManager::getInstance().no_vsyncs_on_screen_off() && mVSyncState->omitted;
            if (vsyncOmitted) {
                mState = State::Idle;
                SFTRACE_INT("VsyncPendingScreenOn", 1);
            } else {
                mState = mVSyncState->synthetic ? State::SyntheticVSync : State::VSync;
                if (FlagManager::getInstance().no_vsyncs_on_screen_off()) {
                    SFTRACE_INT("VsyncPendingScreenOn", 0);
                }
            }
        } else {
            ALOGW_IF(!mVSyncState, "Ignoring VSYNC request while display is disconnected");
            mState = State::Idle;
+7 −0
Original line number Diff line number Diff line
@@ -106,6 +106,8 @@ public:
    // Feed clients with fake VSYNC, e.g. while the display is off.
    virtual void enableSyntheticVsync(bool) = 0;

    virtual void omitVsyncDispatching(bool) = 0;

    virtual void onHotplugReceived(PhysicalDisplayId displayId, bool connected) = 0;

    virtual void onHotplugConnectionError(int32_t connectionError) = 0;
@@ -165,6 +167,8 @@ public:

    void enableSyntheticVsync(bool) override;

    void omitVsyncDispatching(bool) override;

    void onHotplugReceived(PhysicalDisplayId displayId, bool connected) override;

    void onHotplugConnectionError(int32_t connectionError) override;
@@ -240,6 +244,9 @@ private:

        // True if VSYNC should be faked, e.g. when display is off.
        bool synthetic = false;

        // True if VSYNC should not be delivered to apps. Used when the display is off.
        bool omitted = false;
    };

    // TODO(b/74619554): Create per-display threads waiting on respective VSYNC signals,
+8 −0
Original line number Diff line number Diff line
@@ -405,6 +405,14 @@ void Scheduler::enableSyntheticVsync(bool enable) {
    eventThreadFor(Cycle::Render).enableSyntheticVsync(enable);
}

void Scheduler::omitVsyncDispatching(bool omitted) {
    eventThreadFor(Cycle::Render).omitVsyncDispatching(omitted);
    // Note: If we don't couple Cycle::LastComposite event thread, there is a black screen
    // after boot. This is most likely sysui or system_server dependency on sf instance
    // Choreographer
    eventThreadFor(Cycle::LastComposite).omitVsyncDispatching(omitted);
}

void Scheduler::onFrameRateOverridesChanged() {
    const auto [pacesetterId, supportsFrameRateOverrideByContent] = [this] {
        std::scoped_lock lock(mDisplayLock);
Loading