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

Commit 733a6bcd authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5616560 from 113db105 to qt-c2f2-release

Change-Id: I18f10333cf017dcb851d83e9972668b93b4edbf1
parents 47d387bc 113db105
Loading
Loading
Loading
Loading
+23 −16
Original line number Diff line number Diff line
@@ -261,22 +261,6 @@ Display::Display(android::Hwc2::Composer& composer,
        mId(id),
        mIsConnected(false),
        mType(type) {
    std::vector<Hwc2::DisplayCapability> tmpCapabilities;
    auto error = static_cast<Error>(mComposer.getDisplayCapabilities(mId, &tmpCapabilities));
    if (error == Error::None) {
        for (auto capability : tmpCapabilities) {
            mDisplayCapabilities.emplace(static_cast<DisplayCapability>(capability));
        }
    } else if (error == Error::Unsupported) {
        if (capabilities.count(Capability::SkipClientColorTransform)) {
            mDisplayCapabilities.emplace(DisplayCapability::SkipClientColorTransform);
        }
        bool dozeSupport = false;
        error = static_cast<Error>(mComposer.getDozeSupport(mId, &dozeSupport));
        if (error == Error::None && dozeSupport) {
            mDisplayCapabilities.emplace(DisplayCapability::Doze);
        }
    }
    ALOGV("Created display %" PRIu64, id);
}

@@ -660,6 +644,29 @@ Error Display::setPowerMode(PowerMode mode)
{
    auto intMode = static_cast<Hwc2::IComposerClient::PowerMode>(mode);
    auto intError = mComposer.setPowerMode(mId, intMode);

    if (mode == PowerMode::On) {
        std::call_once(mDisplayCapabilityQueryFlag, [this]() {
            std::vector<Hwc2::DisplayCapability> tmpCapabilities;
            auto error =
                    static_cast<Error>(mComposer.getDisplayCapabilities(mId, &tmpCapabilities));
            if (error == Error::None) {
                for (auto capability : tmpCapabilities) {
                    mDisplayCapabilities.emplace(static_cast<DisplayCapability>(capability));
                }
            } else if (error == Error::Unsupported) {
                if (mCapabilities.count(Capability::SkipClientColorTransform)) {
                    mDisplayCapabilities.emplace(DisplayCapability::SkipClientColorTransform);
                }
                bool dozeSupport = false;
                error = static_cast<Error>(mComposer.getDozeSupport(mId, &dozeSupport));
                if (error == Error::None && dozeSupport) {
                    mDisplayCapabilities.emplace(DisplayCapability::Doze);
                }
            }
        });
    }

    return static_cast<Error>(intError);
}

+1 −0
Original line number Diff line number Diff line
@@ -356,6 +356,7 @@ private:
    DisplayType mType;
    std::unordered_map<hwc2_layer_t, std::unique_ptr<Layer>> mLayers;
    std::unordered_map<hwc2_config_t, std::shared_ptr<const Config>> mConfigs;
    std::once_flag mDisplayCapabilityQueryFlag;
    std::unordered_set<DisplayCapability> mDisplayCapabilities;
};
} // namespace impl
+17 −24
Original line number Diff line number Diff line
@@ -935,12 +935,9 @@ void SurfaceFlinger::setDesiredActiveConfig(const ActiveConfigInfo& info) {
        // Start receiving vsync samples now, so that we can detect a period
        // switch.
        mScheduler->resyncToHardwareVsync(true, getVsyncPeriod());
        // We should only move to early offsets when we know that the refresh
        // rate will change. Otherwise, we may be stuck in early offsets
        // forever, as onRefreshRateChangeDetected will not be called.
        if (mDesiredActiveConfig.event == Scheduler::ConfigEvent::Changed) {
        // As we called to set period, we will call to onRefreshRateChangeCompleted once
        // DispSync model is locked.
        mVsyncModulator.onRefreshRateChangeInitiated();
        }
        mPhaseOffsets->setRefreshRateType(info.type);
        const auto [early, gl, late] = mPhaseOffsets->getCurrentOffsets();
        mVsyncModulator.setPhaseOffsets(early, gl, late);
@@ -975,7 +972,6 @@ void SurfaceFlinger::setActiveConfigInternal() {

    display->setActiveConfig(mUpcomingActiveConfig.configId);

    mScheduler->resyncToHardwareVsync(true, getVsyncPeriod());
    mPhaseOffsets->setRefreshRateType(mUpcomingActiveConfig.type);
    const auto [early, gl, late] = mPhaseOffsets->getCurrentOffsets();
    mVsyncModulator.setPhaseOffsets(early, gl, late);
@@ -987,6 +983,18 @@ void SurfaceFlinger::setActiveConfigInternal() {
    }
}

void SurfaceFlinger::desiredActiveConfigChangeDone() {
    std::lock_guard<std::mutex> lock(mActiveConfigLock);
    mDesiredActiveConfig.event = Scheduler::ConfigEvent::None;
    mDesiredActiveConfigChanged = false;
    ATRACE_INT("DesiredActiveConfigChanged", mDesiredActiveConfigChanged);

    mScheduler->resyncToHardwareVsync(true, getVsyncPeriod());
    mPhaseOffsets->setRefreshRateType(mUpcomingActiveConfig.type);
    const auto [early, gl, late] = mPhaseOffsets->getCurrentOffsets();
    mVsyncModulator.setPhaseOffsets(early, gl, late);
}

bool SurfaceFlinger::performSetActiveConfig() {
    ATRACE_CALL();
    if (mCheckPendingFence) {
@@ -1016,14 +1024,7 @@ bool SurfaceFlinger::performSetActiveConfig() {
    if (!display || display->getActiveConfig() == desiredActiveConfig.configId) {
        // display is not valid or we are already in the requested mode
        // on both cases there is nothing left to do
        std::lock_guard<std::mutex> lock(mActiveConfigLock);
        mDesiredActiveConfig.event = Scheduler::ConfigEvent::None;
        mDesiredActiveConfigChanged = false;
        // Update scheduler with the correct vsync period as a no-op.
        // Otherwise, there exists a race condition where we get stuck in the
        // incorrect vsync period.
        mScheduler->resyncToHardwareVsync(false, getVsyncPeriod());
        ATRACE_INT("DesiredActiveConfigChanged", mDesiredActiveConfigChanged);
        desiredActiveConfigChangeDone();
        return false;
    }

@@ -1031,15 +1032,7 @@ bool SurfaceFlinger::performSetActiveConfig() {
    // allowed configs might have change by the time we process the refresh.
    // Make sure the desired config is still allowed
    if (!isDisplayConfigAllowed(desiredActiveConfig.configId)) {
        std::lock_guard<std::mutex> lock(mActiveConfigLock);
        mDesiredActiveConfig.event = Scheduler::ConfigEvent::None;
        mDesiredActiveConfig.configId = display->getActiveConfig();
        mDesiredActiveConfigChanged = false;
        // Update scheduler with the current vsync period as a no-op.
        // Otherwise, there exists a race condition where we get stuck in the
        // incorrect vsync period.
        mScheduler->resyncToHardwareVsync(false, getVsyncPeriod());
        ATRACE_INT("DesiredActiveConfigChanged", mDesiredActiveConfigChanged);
        desiredActiveConfigChangeDone();
        return false;
    }
    mUpcomingActiveConfig = desiredActiveConfig;
+3 −1
Original line number Diff line number Diff line
@@ -508,13 +508,15 @@ private:
    // Sets the desired active config bit. It obtains the lock, and sets mDesiredActiveConfig.
    void setDesiredActiveConfig(const ActiveConfigInfo& info) REQUIRES(mStateLock);
    // Once HWC has returned the present fence, this sets the active config and a new refresh
    // rate in SF. It also triggers HWC vsync.
    // rate in SF.
    void setActiveConfigInternal() REQUIRES(mStateLock);
    // Active config is updated on INVALIDATE call in a state machine-like manner. When the
    // desired config was set, HWC needs to update the panel on the next refresh, and when
    // we receive the fence back, we know that the process was complete. It returns whether
    // we need to wait for the next invalidate
    bool performSetActiveConfig() REQUIRES(mStateLock);
    // Called when active config is no longer is progress
    void desiredActiveConfigChangeDone() REQUIRES(mStateLock);
    // called on the main thread in response to setPowerMode()
    void setPowerModeInternal(const sp<DisplayDevice>& display, int mode) REQUIRES(mStateLock);

+17 −3
Original line number Diff line number Diff line
@@ -253,13 +253,16 @@ struct BaseDisplayVariant {
    static constexpr int INIT_POWER_MODE = HWC_POWER_MODE_NORMAL;

    static void setupPreconditions(CompositionTest* test) {
        EXPECT_CALL(*test->mComposer, getDisplayCapabilities(HWC_DISPLAY, _))
                .WillOnce(DoAll(SetArgPointee<1>(std::vector<Hwc2::DisplayCapability>({})),
                                Return(Error::NONE)));
        EXPECT_CALL(*test->mComposer,
                    setPowerMode(HWC_DISPLAY,
                                 static_cast<Hwc2::IComposerClient::PowerMode>(
                                         Derived::INIT_POWER_MODE)))
                .WillOnce(Return(Error::NONE));

        FakeHwcDisplayInjector(DEFAULT_DISPLAY_ID, HWC2::DisplayType::Physical,
                               true /* isPrimary */)
                .setCapabilities(&test->mDefaultCapabilities)
                .setPowerMode(Derived::INIT_POWER_MODE)
                .inject(&test->mFlinger, test->mComposer);
        Mock::VerifyAndClear(test->mComposer);

@@ -281,6 +284,13 @@ struct BaseDisplayVariant {
        test->mDisplay->setLayerStack(DEFAULT_LAYER_STACK);
    }

    template <typename Case>
    static void setupPreconditionCallExpectations(CompositionTest* test) {
        EXPECT_CALL(*test->mComposer, getDisplayCapabilities(HWC_DISPLAY, _))
                .WillOnce(DoAll(SetArgPointee<1>(std::vector<Hwc2::DisplayCapability>({})),
                                Return(Error::NONE)));
    }

    template <typename Case>
    static void setupCommonCompositionCallExpectations(CompositionTest* test) {
        EXPECT_CALL(*test->mComposer,
@@ -392,6 +402,9 @@ struct InsecureDisplaySetupVariant : public BaseDisplayVariant<InsecureDisplaySe
struct PoweredOffDisplaySetupVariant : public BaseDisplayVariant<PoweredOffDisplaySetupVariant> {
    static constexpr int INIT_POWER_MODE = HWC_POWER_MODE_OFF;

    template <typename Case>
    static void setupPreconditionCallExpectations(CompositionTest*) {}

    template <typename Case>
    static void setupCommonCompositionCallExpectations(CompositionTest* test) {
        EXPECT_CALL(*test->mRenderEngine, useNativeFenceSync()).WillRepeatedly(Return(true));
@@ -1022,6 +1035,7 @@ struct CompositionCase {
    using CompositionResult = CompositionResultCase;

    static void setupCommon(CompositionTest* test) {
        Display::template setupPreconditionCallExpectations<ThisCase>(test);
        Display::setupPreconditions(test);

        auto layer = Layer::createLayer(test);
Loading