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

Commit 6c7b36e8 authored by Dominik Laskowski's avatar Dominik Laskowski
Browse files

SF: Clean up plumbing for boot display mode

Avoid CE round trip, and validate API against virtual displays.

Bug: 182939859
Test: Boot
Change-Id: Ic4e14dcc06218097c65f9374f2962a345d347820
parent 32d9f66b
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -56,9 +56,6 @@ public:
    // similar requests if needed.
    virtual void createClientCompositionCache(uint32_t cacheSize) = 0;

    // Returns the boot display mode preferred by HWC.
    virtual int32_t getPreferredBootHwcConfigId() const = 0;

protected:
    ~Display() = default;
};
+0 −2
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@ public:
    bool isSecure() const override;
    bool isVirtual() const override;
    void disconnect() override;
    int32_t getPreferredBootHwcConfigId() const override;
    void createDisplayColorProfile(
            const compositionengine::DisplayColorProfileCreationArgs&) override;
    void createRenderSurface(const compositionengine::RenderSurfaceCreationArgs&) override;
@@ -88,7 +87,6 @@ private:
    DisplayId mId;
    bool mIsDisconnected = false;
    Hwc2::PowerAdvisor* mPowerAdvisor = nullptr;
    int32_t mPreferredBootHwcConfigId = -1;
};

// This template factory function standardizes the implementation details of the
+0 −14
Original line number Diff line number Diff line
@@ -58,16 +58,6 @@ void Display::setConfiguration(const compositionengine::DisplayCreationArgs& arg
    editState().isSecure = args.isSecure;
    editState().displaySpace.setBounds(args.pixels);
    setName(args.name);
    bool isBootModeSupported = getCompositionEngine().getHwComposer().getBootDisplayModeSupport();
    const auto physicalId = PhysicalDisplayId::tryCast(mId);
    if (!physicalId || !isBootModeSupported) {
        return;
    }
    std::optional<hal::HWConfigId> preferredBootModeId =
            getCompositionEngine().getHwComposer().getPreferredBootDisplayMode(*physicalId);
    if (preferredBootModeId.has_value()) {
        mPreferredBootHwcConfigId = static_cast<int32_t>(preferredBootModeId.value());
    }
}

bool Display::isValid() const {
@@ -90,10 +80,6 @@ std::optional<DisplayId> Display::getDisplayId() const {
    return mId;
}

int32_t Display::getPreferredBootHwcConfigId() const {
    return mPreferredBootHwcConfigId;
}

void Display::disconnect() {
    if (mIsDisconnected) {
        return;
+2 −2
Original line number Diff line number Diff line
@@ -112,8 +112,8 @@ public:
    MOCK_METHOD1(getPreferredBootDisplayMode, std::optional<hal::HWConfigId>(PhysicalDisplayId));
    MOCK_METHOD0(getBootDisplayModeSupport, bool());
    MOCK_METHOD2(setAutoLowLatencyMode, status_t(PhysicalDisplayId, bool));
    MOCK_METHOD2(getSupportedContentTypes,
                 status_t(PhysicalDisplayId, std::vector<hal::ContentType>*));
    MOCK_METHOD(status_t, getSupportedContentTypes,
                (PhysicalDisplayId, std::vector<hal::ContentType>*), (const, override));
    MOCK_METHOD2(setContentType, status_t(PhysicalDisplayId, hal::ContentType));
    MOCK_CONST_METHOD0(getSupportedLayerGenericMetadata,
                       const std::unordered_map<std::string, bool>&());
+9 −17
Original line number Diff line number Diff line
@@ -227,21 +227,23 @@ const DisplayModes& DisplayDevice::getSupportedModes() const {
}

DisplayModePtr DisplayDevice::getMode(DisplayModeId modeId) const {
    const auto it = std::find_if(mSupportedModes.begin(), mSupportedModes.end(),
                                 [&](DisplayModePtr mode) { return mode->getId() == modeId; });
    const auto it =
            std::find_if(mSupportedModes.begin(), mSupportedModes.end(),
                         [&](const DisplayModePtr& mode) { return mode->getId() == modeId; });
    if (it != mSupportedModes.end()) {
        return *it;
    }
    return nullptr;
}

DisplayModePtr DisplayDevice::getModefromHwcId(uint32_t hwcId) const {
    const auto it = std::find_if(mSupportedModes.begin(), mSupportedModes.end(),
                                 [&](DisplayModePtr mode) { return mode->getHwcId() == hwcId; });
std::optional<DisplayModeId> DisplayDevice::translateModeId(hal::HWConfigId hwcId) const {
    const auto it =
            std::find_if(mSupportedModes.begin(), mSupportedModes.end(),
                         [&](const DisplayModePtr& mode) { return mode->getHwcId() == hwcId; });
    if (it != mSupportedModes.end()) {
        return *it;
        return (*it)->getId();
    }
    return nullptr;
    return {};
}

nsecs_t DisplayDevice::getVsyncPeriodFromHWC() const {
@@ -468,16 +470,6 @@ HdrCapabilities DisplayDevice::getHdrCapabilities() const {
                           capabilities.getDesiredMinLuminance());
}

ui::DisplayModeId DisplayDevice::getPreferredBootModeId() const {
    const auto preferredBootHwcModeId = mCompositionDisplay->getPreferredBootHwcConfigId();
    const auto mode = getModefromHwcId(preferredBootHwcModeId);
    if (mode == nullptr) {
        ALOGE("%s: invalid display mode (%d)", __FUNCTION__, preferredBootHwcModeId);
        return BAD_VALUE;
    }
    return mode->getId().value();
}

void DisplayDevice::enableRefreshRateOverlay(bool enable, bool showSpinnner) {
    if (!enable) {
        mRefreshRateOverlay.reset();
Loading