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

Commit b0054a26 authored by Dominik Laskowski's avatar Dominik Laskowski
Browse files

SF: Unify data types for display modes

Remove the RefreshRateConfigs::RefreshRate wrapper around DisplayMode.
Store DisplayModes as a SmallMap, so that RefreshRateConfigs uses the
same data structure for lookup by ID. Use iterators into that map for
all bookkeeping in RefreshRateConfigs.

Bug: 182939859
Bug: 185535769
Test: libsurfaceflinger_unittest
Change-Id: I7708fa997089802c45d906b17b7a073f5c82105e
parent 6c7b36e8
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -404,7 +404,7 @@ void BufferLayer::onPostComposition(const DisplayDevice* display,
    }
    }


    if (display) {
    if (display) {
        const Fps refreshRate = display->refreshRateConfigs().getCurrentRefreshRate().getFps();
        const Fps refreshRate = display->refreshRateConfigs().getActiveMode()->getFps();
        const std::optional<Fps> renderRate =
        const std::optional<Fps> renderRate =
                mFlinger->mScheduler->getFrameRateOverride(getOwnerUid());
                mFlinger->mScheduler->getFrameRateOverride(getOwnerUid());


+9 −14
Original line number Original line Diff line number Diff line
@@ -196,7 +196,7 @@ void DisplayDevice::setActiveMode(DisplayModeId id) {
    ATRACE_INT(mActiveModeFPSTrace.c_str(), mode->getFps().getIntValue());
    ATRACE_INT(mActiveModeFPSTrace.c_str(), mode->getFps().getIntValue());
    mActiveMode = mode;
    mActiveMode = mode;
    if (mRefreshRateConfigs) {
    if (mRefreshRateConfigs) {
        mRefreshRateConfigs->setCurrentModeId(mActiveMode->getId());
        mRefreshRateConfigs->setActiveModeId(mActiveMode->getId());
    }
    }
    if (mRefreshRateOverlay) {
    if (mRefreshRateOverlay) {
        mRefreshRateOverlay->changeRefreshRate(mActiveMode->getFps());
        mRefreshRateOverlay->changeRefreshRate(mActiveMode->getFps());
@@ -227,21 +227,16 @@ const DisplayModes& DisplayDevice::getSupportedModes() const {
}
}


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


std::optional<DisplayModeId> DisplayDevice::translateModeId(hal::HWConfigId hwcId) const {
std::optional<DisplayModeId> DisplayDevice::translateModeId(hal::HWConfigId hwcId) const {
    const auto it =
    const auto it =
            std::find_if(mSupportedModes.begin(), mSupportedModes.end(),
            std::find_if(mSupportedModes.begin(), mSupportedModes.end(),
                         [&](const DisplayModePtr& mode) { return mode->getHwcId() == hwcId; });
                         [hwcId](const auto& pair) { return pair.second->getHwcId() == hwcId; });
    if (it != mSupportedModes.end()) {
    if (it != mSupportedModes.end()) {
        return (*it)->getId();
        return it->second->getId();
    }
    }
    return {};
    return {};
}
}
@@ -366,12 +361,12 @@ void DisplayDevice::dump(std::string& result) const {
                  activeMode ? to_string(*activeMode).c_str() : "none");
                  activeMode ? to_string(*activeMode).c_str() : "none");


    result.append("   supportedModes=\n");
    result.append("   supportedModes=\n");

    for (const auto& [id, mode] : mSupportedModes) {
    for (const auto& mode : mSupportedModes) {
        result.append("      ");
        result.append("      ");
        result.append(to_string(*mode));
        result.append(to_string(*mode));
        result.append("\n");
        result.push_back('\n');
    }
    }

    StringAppendF(&result, "   deviceProductInfo=");
    StringAppendF(&result, "   deviceProductInfo=");
    if (mDeviceProductInfo) {
    if (mDeviceProductInfo) {
        mDeviceProductInfo->dump(result);
        mDeviceProductInfo->dump(result);
+58 −37
Original line number Original line Diff line number Diff line
@@ -18,10 +18,10 @@


#include <cstddef>
#include <cstddef>
#include <memory>
#include <memory>
#include <vector>


#include <android-base/stringprintf.h>
#include <android-base/stringprintf.h>
#include <android/configuration.h>
#include <android/configuration.h>
#include <ftl/small_map.h>
#include <ui/DisplayId.h>
#include <ui/DisplayId.h>
#include <ui/DisplayMode.h>
#include <ui/DisplayMode.h>
#include <ui/Size.h>
#include <ui/Size.h>
@@ -38,8 +38,17 @@ namespace hal = android::hardware::graphics::composer::hal;


class DisplayMode;
class DisplayMode;
using DisplayModePtr = std::shared_ptr<const DisplayMode>;
using DisplayModePtr = std::shared_ptr<const DisplayMode>;
using DisplayModes = std::vector<DisplayModePtr>;

using DisplayModeId = StrongTyping<ui::DisplayModeId, struct DisplayModeIdTag, Compare, Hash>;
// Prevent confusion with fps_approx_ops on the underlying Fps.
bool operator<(const DisplayModePtr&, const DisplayModePtr&) = delete;
bool operator>(const DisplayModePtr&, const DisplayModePtr&) = delete;
bool operator<=(const DisplayModePtr&, const DisplayModePtr&) = delete;
bool operator>=(const DisplayModePtr&, const DisplayModePtr&) = delete;

using DisplayModeId = StrongTyping<ui::DisplayModeId, struct DisplayModeIdTag, Compare>;

using DisplayModes = ftl::SmallMap<DisplayModeId, DisplayModePtr, 3>;
using DisplayModeIterator = DisplayModes::const_iterator;


class DisplayMode {
class DisplayMode {
public:
public:
@@ -61,35 +70,30 @@ public:
            return *this;
            return *this;
        }
        }


        Builder& setWidth(int32_t width) {
        Builder& setResolution(ui::Size resolution) {
            mDisplayMode->mWidth = width;
            mDisplayMode->mResolution = resolution;
            return *this;
        }

        Builder& setHeight(int32_t height) {
            mDisplayMode->mHeight = height;
            return *this;
            return *this;
        }
        }


        Builder& setVsyncPeriod(int32_t vsyncPeriod) {
        Builder& setVsyncPeriod(nsecs_t vsyncPeriod) {
            mDisplayMode->mFps = Fps::fromPeriodNsecs(vsyncPeriod);
            mDisplayMode->mFps = Fps::fromPeriodNsecs(vsyncPeriod);
            return *this;
            return *this;
        }
        }


        Builder& setDpiX(int32_t dpiX) {
        Builder& setDpiX(int32_t dpiX) {
            if (dpiX == -1) {
            if (dpiX == -1) {
                mDisplayMode->mDpiX = getDefaultDensity();
                mDisplayMode->mDpi.x = getDefaultDensity();
            } else {
            } else {
                mDisplayMode->mDpiX = dpiX / 1000.0f;
                mDisplayMode->mDpi.x = dpiX / 1000.f;
            }
            }
            return *this;
            return *this;
        }
        }


        Builder& setDpiY(int32_t dpiY) {
        Builder& setDpiY(int32_t dpiY) {
            if (dpiY == -1) {
            if (dpiY == -1) {
                mDisplayMode->mDpiY = getDefaultDensity();
                mDisplayMode->mDpi.y = getDefaultDensity();
            } else {
            } else {
                mDisplayMode->mDpiY = dpiY / 1000.0f;
                mDisplayMode->mDpi.y = dpiY / 1000.f;
            }
            }
            return *this;
            return *this;
        }
        }
@@ -107,59 +111,76 @@ public:
            // information to begin with. This is also used for virtual displays and
            // information to begin with. This is also used for virtual displays and
            // older HWC implementations, so be careful about orientation.
            // older HWC implementations, so be careful about orientation.


            auto longDimension = std::max(mDisplayMode->mWidth, mDisplayMode->mHeight);
            if (std::max(mDisplayMode->getWidth(), mDisplayMode->getHeight()) >= 1080) {
            if (longDimension >= 1080) {
                return ACONFIGURATION_DENSITY_XHIGH;
                return ACONFIGURATION_DENSITY_XHIGH;
            } else {
            } else {
                return ACONFIGURATION_DENSITY_TV;
                return ACONFIGURATION_DENSITY_TV;
            }
            }
        }
        }

        std::shared_ptr<DisplayMode> mDisplayMode;
        std::shared_ptr<DisplayMode> mDisplayMode;
    };
    };


    DisplayModeId getId() const { return mId; }
    DisplayModeId getId() const { return mId; }

    hal::HWConfigId getHwcId() const { return mHwcId; }
    hal::HWConfigId getHwcId() const { return mHwcId; }
    PhysicalDisplayId getPhysicalDisplayId() const { return mPhysicalDisplayId; }
    PhysicalDisplayId getPhysicalDisplayId() const { return mPhysicalDisplayId; }


    int32_t getWidth() const { return mWidth; }
    ui::Size getResolution() const { return mResolution; }
    int32_t getHeight() const { return mHeight; }
    int32_t getWidth() const { return mResolution.getWidth(); }
    ui::Size getSize() const { return {mWidth, mHeight}; }
    int32_t getHeight() const { return mResolution.getHeight(); }

    Fps getFps() const { return mFps; }
    Fps getFps() const { return mFps; }
    nsecs_t getVsyncPeriod() const { return mFps.getPeriodNsecs(); }
    nsecs_t getVsyncPeriod() const { return mFps.getPeriodNsecs(); }
    float getDpiX() const { return mDpiX; }

    float getDpiY() const { return mDpiY; }
    struct Dpi {
        float x = -1;
        float y = -1;

        bool operator==(Dpi other) const { return x == other.x && y == other.y; }
    };

    Dpi getDpi() const { return mDpi; }


    // Switches between modes in the same group are seamless, i.e.
    // Switches between modes in the same group are seamless, i.e.
    // without visual interruptions such as a black screen.
    // without visual interruptions such as a black screen.
    int32_t getGroup() const { return mGroup; }
    int32_t getGroup() const { return mGroup; }


    bool equalsExceptDisplayModeId(const DisplayModePtr& other) const {
        return mHwcId == other->mHwcId && mWidth == other->mWidth && mHeight == other->mHeight &&
                getVsyncPeriod() == other->getVsyncPeriod() && mDpiX == other->mDpiX &&
                mDpiY == other->mDpiY && mGroup == other->mGroup;
    }

private:
private:
    explicit DisplayMode(hal::HWConfigId id) : mHwcId(id) {}
    explicit DisplayMode(hal::HWConfigId id) : mHwcId(id) {}


    hal::HWConfigId mHwcId;
    const hal::HWConfigId mHwcId;
    DisplayModeId mId;
    DisplayModeId mId;

    PhysicalDisplayId mPhysicalDisplayId;
    PhysicalDisplayId mPhysicalDisplayId;


    int32_t mWidth = -1;
    ui::Size mResolution;
    int32_t mHeight = -1;
    Fps mFps;
    Fps mFps;
    float mDpiX = -1;
    Dpi mDpi;
    float mDpiY = -1;
    int32_t mGroup = -1;
    int32_t mGroup = -1;
};
};


inline bool equalsExceptDisplayModeId(const DisplayMode& lhs, const DisplayMode& rhs) {
    return lhs.getHwcId() == rhs.getHwcId() && lhs.getResolution() == rhs.getResolution() &&
            lhs.getVsyncPeriod() == rhs.getVsyncPeriod() && lhs.getDpi() == rhs.getDpi() &&
            lhs.getGroup() == rhs.getGroup();
}

inline std::string to_string(const DisplayMode& mode) {
inline std::string to_string(const DisplayMode& mode) {
    return base::StringPrintf("{id=%d, hwcId=%d, width=%d, height=%d, refreshRate=%s, "
    return base::StringPrintf("{id=%d, hwcId=%d, resolution=%dx%d, refreshRate=%s, "
                              "dpiX=%.2f, dpiY=%.2f, group=%d}",
                              "dpi=%.2fx%.2f, group=%d}",
                              mode.getId().value(), mode.getHwcId(), mode.getWidth(),
                              mode.getId().value(), mode.getHwcId(), mode.getWidth(),
                              mode.getHeight(), to_string(mode.getFps()).c_str(), mode.getDpiX(),
                              mode.getHeight(), to_string(mode.getFps()).c_str(), mode.getDpi().x,
                              mode.getDpiY(), mode.getGroup());
                              mode.getDpi().y, mode.getGroup());
}

template <typename... DisplayModePtrs>
inline DisplayModes makeModes(const DisplayModePtrs&... modePtrs) {
    DisplayModes modes;
    // Note: The omission of std::move(modePtrs) is intentional, because order of evaluation for
    // arguments is unspecified.
    (modes.try_emplace(modePtrs->getId(), modePtrs), ...);
    return modes;
}
}


} // namespace android
} // namespace android
+281 −299

File changed.

Preview size limit exceeded, changes collapsed.

+31 −115
Original line number Original line Diff line number Diff line
@@ -56,50 +56,6 @@ public:
    static constexpr nsecs_t MARGIN_FOR_PERIOD_CALCULATION =
    static constexpr nsecs_t MARGIN_FOR_PERIOD_CALCULATION =
            std::chrono::nanoseconds(800us).count();
            std::chrono::nanoseconds(800us).count();


    class RefreshRate {
    private:
        // Effectively making the constructor private while allowing
        // std::make_unique to create the object
        struct ConstructorTag {
            explicit ConstructorTag(int) {}
        };

    public:
        RefreshRate(DisplayModePtr mode, ConstructorTag) : mode(mode) {}

        DisplayModeId getModeId() const { return mode->getId(); }
        nsecs_t getVsyncPeriod() const { return mode->getVsyncPeriod(); }
        int32_t getModeGroup() const { return mode->getGroup(); }
        std::string getName() const { return to_string(getFps()); }
        Fps getFps() const { return mode->getFps(); }
        DisplayModePtr getMode() const { return mode; }

        // Checks whether the fps of this RefreshRate struct is within a given min and max refresh
        // rate passed in. Margin of error is applied to the boundaries for approximation.
        bool inPolicy(Fps minRefreshRate, Fps maxRefreshRate) const;

        bool operator==(const RefreshRate& other) const { return mode == other.mode; }
        bool operator!=(const RefreshRate& other) const { return !operator==(other); }

        bool operator<(const RefreshRate& other) const {
            return isStrictlyLess(getFps(), other.getFps());
        }

        std::string toString() const;
        friend std::ostream& operator<<(std::ostream& os, const RefreshRate& refreshRate) {
            return os << refreshRate.toString();
        }

    private:
        friend RefreshRateConfigs;
        friend class RefreshRateConfigsTest;

        DisplayModePtr mode;
    };

    using AllRefreshRatesMapType =
            std::unordered_map<DisplayModeId, std::unique_ptr<const RefreshRate>>;

    struct Policy {
    struct Policy {
    private:
    private:
        static constexpr int kAllowGroupSwitchingDefault = false;
        static constexpr int kAllowGroupSwitchingDefault = false;
@@ -236,12 +192,12 @@ public:


    // Returns the refresh rate that best fits the given layers, and whether the refresh rate was
    // Returns the refresh rate that best fits the given layers, and whether the refresh rate was
    // chosen based on touch boost and/or idle timer.
    // chosen based on touch boost and/or idle timer.
    std::pair<RefreshRate, GlobalSignals> getBestRefreshRate(const std::vector<LayerRequirement>&,
    std::pair<DisplayModePtr, GlobalSignals> getBestRefreshRate(
                                                             GlobalSignals) const EXCLUDES(mLock);
            const std::vector<LayerRequirement>&, GlobalSignals) const EXCLUDES(mLock);


    FpsRange getSupportedRefreshRateRange() const EXCLUDES(mLock) {
    FpsRange getSupportedRefreshRateRange() const EXCLUDES(mLock) {
        std::lock_guard lock(mLock);
        std::lock_guard lock(mLock);
        return {mMinSupportedRefreshRate->getFps(), mMaxSupportedRefreshRate->getFps()};
        return {mMinRefreshRateModeIt->second->getFps(), mMaxRefreshRateModeIt->second->getFps()};
    }
    }


    std::optional<Fps> onKernelTimerChanged(std::optional<DisplayModeId> desiredActiveModeId,
    std::optional<Fps> onKernelTimerChanged(std::optional<DisplayModeId> desiredActiveModeId,
@@ -249,30 +205,15 @@ public:


    // Returns the highest refresh rate according to the current policy. May change at runtime. Only
    // Returns the highest refresh rate according to the current policy. May change at runtime. Only
    // uses the primary range, not the app request range.
    // uses the primary range, not the app request range.
    RefreshRate getMaxRefreshRateByPolicy() const EXCLUDES(mLock);
    DisplayModePtr getMaxRefreshRateByPolicy() const EXCLUDES(mLock);

    // Returns the current refresh rate
    RefreshRate getCurrentRefreshRate() const EXCLUDES(mLock);

    // Returns the current refresh rate, if allowed. Otherwise the default that is allowed by
    // the policy.
    RefreshRate getCurrentRefreshRateByPolicy() const;

    // Returns the refresh rate that corresponds to a DisplayModeId. This may change at
    // runtime.
    // TODO(b/159590486) An invalid mode id may be given here if the dipslay modes have changed.
    RefreshRate getRefreshRateFromModeId(DisplayModeId modeId) const EXCLUDES(mLock) {
        std::lock_guard lock(mLock);
        return *mRefreshRates.at(modeId);
    };


    // Stores the current modeId the device operates at
    void setActiveModeId(DisplayModeId) EXCLUDES(mLock);
    void setCurrentModeId(DisplayModeId) EXCLUDES(mLock);
    DisplayModePtr getActiveMode() const EXCLUDES(mLock);


    // Returns a known frame rate that is the closest to frameRate
    // Returns a known frame rate that is the closest to frameRate
    Fps findClosestKnownFrameRate(Fps frameRate) const;
    Fps findClosestKnownFrameRate(Fps frameRate) const;


    enum class KernelIdleTimerController { Sysprop, HwcApi };
    enum class KernelIdleTimerController { Sysprop, HwcApi, ftl_last = HwcApi };


    // Configuration flags.
    // Configuration flags.
    struct Config {
    struct Config {
@@ -291,7 +232,7 @@ public:
        std::optional<KernelIdleTimerController> kernelIdleTimerController;
        std::optional<KernelIdleTimerController> kernelIdleTimerController;
    };
    };


    RefreshRateConfigs(const DisplayModes&, DisplayModeId,
    RefreshRateConfigs(DisplayModes, DisplayModeId activeModeId,
                       Config config = {.enableFrameRateOverride = false,
                       Config config = {.enableFrameRateOverride = false,
                                        .frameRateMultipleThreshold = 0,
                                        .frameRateMultipleThreshold = 0,
                                        .idleTimerTimeout = 0ms,
                                        .idleTimerTimeout = 0ms,
@@ -305,7 +246,7 @@ public:
    // differ in resolution.
    // differ in resolution.
    bool canSwitch() const EXCLUDES(mLock) {
    bool canSwitch() const EXCLUDES(mLock) {
        std::lock_guard lock(mLock);
        std::lock_guard lock(mLock);
        return mRefreshRates.size() > 1;
        return mDisplayModes.size() > 1;
    }
    }


    // Class to enumerate options around toggling the kernel timer on and off.
    // Class to enumerate options around toggling the kernel timer on and off.
@@ -323,7 +264,7 @@ public:
    // Return the display refresh rate divisor to match the layer
    // Return the display refresh rate divisor to match the layer
    // frame rate, or 0 if the display refresh rate is not a multiple of the
    // frame rate, or 0 if the display refresh rate is not a multiple of the
    // layer refresh rate.
    // layer refresh rate.
    static int getFrameRateDivisor(Fps displayFrameRate, Fps layerFrameRate);
    static int getFrameRateDivisor(Fps displayRefreshRate, Fps layerFrameRate);


    // Returns if the provided frame rates have a ratio t*1000/1001 or t*1001/1000
    // Returns if the provided frame rates have a ratio t*1000/1001 or t*1001/1000
    // for an integer t.
    // for an integer t.
@@ -391,54 +332,39 @@ private:


    void constructAvailableRefreshRates() REQUIRES(mLock);
    void constructAvailableRefreshRates() REQUIRES(mLock);


    void getSortedRefreshRateListLocked(
    std::pair<DisplayModePtr, GlobalSignals> getBestRefreshRateLocked(
            const std::function<bool(const RefreshRate&)>& shouldAddRefreshRate,
            std::vector<const RefreshRate*>* outRefreshRates) REQUIRES(mLock);

    std::pair<RefreshRate, GlobalSignals> getBestRefreshRateLocked(
            const std::vector<LayerRequirement>&, GlobalSignals) const REQUIRES(mLock);
            const std::vector<LayerRequirement>&, GlobalSignals) const REQUIRES(mLock);


    // Returns the refresh rate with the highest score in the collection specified from begin
    // to end. If there are more than one with the same highest refresh rate, the first one is
    // returned.
    template <typename Iter>
    const RefreshRate* getBestRefreshRate(Iter begin, Iter end) const;

    // Returns number of display frames and remainder when dividing the layer refresh period by
    // Returns number of display frames and remainder when dividing the layer refresh period by
    // display refresh period.
    // display refresh period.
    std::pair<nsecs_t, nsecs_t> getDisplayFrames(nsecs_t layerPeriod, nsecs_t displayPeriod) const;
    std::pair<nsecs_t, nsecs_t> getDisplayFrames(nsecs_t layerPeriod, nsecs_t displayPeriod) const;


    // Returns the lowest refresh rate according to the current policy. May change at runtime. Only
    // Returns the lowest refresh rate according to the current policy. May change at runtime. Only
    // uses the primary range, not the app request range.
    // uses the primary range, not the app request range.
    const RefreshRate& getMinRefreshRateByPolicyLocked() const REQUIRES(mLock);
    const DisplayModePtr& getMinRefreshRateByPolicyLocked() const REQUIRES(mLock);


    // Returns the highest refresh rate according to the current policy. May change at runtime. Only
    // Returns the highest refresh rate according to the current policy. May change at runtime. Only
    // uses the primary range, not the app request range.
    // uses the primary range, not the app request range.
    const RefreshRate& getMaxRefreshRateByPolicyLocked() const REQUIRES(mLock) {
    const DisplayModePtr& getMaxRefreshRateByPolicyLocked(int anchorGroup) const REQUIRES(mLock);
        return getMaxRefreshRateByPolicyLocked(mCurrentRefreshRate->getModeGroup());
    const DisplayModePtr& getMaxRefreshRateByPolicyLocked() const REQUIRES(mLock) {
        return getMaxRefreshRateByPolicyLocked(mActiveModeIt->second->getGroup());
    }
    }


    const RefreshRate& getMaxRefreshRateByPolicyLocked(int anchorGroup) const REQUIRES(mLock);

    // Returns the current refresh rate, if allowed. Otherwise the default that is allowed by
    // the policy.
    const RefreshRate& getCurrentRefreshRateByPolicyLocked() const REQUIRES(mLock);

    const Policy* getCurrentPolicyLocked() const REQUIRES(mLock);
    const Policy* getCurrentPolicyLocked() const REQUIRES(mLock);
    bool isPolicyValidLocked(const Policy& policy) const REQUIRES(mLock);
    bool isPolicyValidLocked(const Policy& policy) const REQUIRES(mLock);


    // Returns whether the layer is allowed to vote for the given refresh rate.
    // Returns whether the layer is allowed to vote for the given refresh rate.
    bool isVoteAllowed(const LayerRequirement&, const RefreshRate&) const;
    bool isVoteAllowed(const LayerRequirement&, Fps) const;


    // calculates a score for a layer. Used to determine the display refresh rate
    // calculates a score for a layer. Used to determine the display refresh rate
    // and the frame rate override for certains applications.
    // and the frame rate override for certains applications.
    float calculateLayerScoreLocked(const LayerRequirement&, const RefreshRate&,
    float calculateLayerScoreLocked(const LayerRequirement&, Fps refreshRate,
                                    bool isSeamlessSwitch) const REQUIRES(mLock);
                                    bool isSeamlessSwitch) const REQUIRES(mLock);


    float calculateNonExactMatchingLayerScoreLocked(const LayerRequirement&,
    float calculateNonExactMatchingLayerScoreLocked(const LayerRequirement&, Fps refreshRate) const
                                                    const RefreshRate&) const REQUIRES(mLock);
            REQUIRES(mLock);


    void updateDisplayModes(const DisplayModes& mode, DisplayModeId currentModeId) EXCLUDES(mLock);
    void updateDisplayModes(DisplayModes, DisplayModeId activeModeId) EXCLUDES(mLock);


    void initializeIdleTimer();
    void initializeIdleTimer();


@@ -449,32 +375,22 @@ private:
                                                             : mIdleTimerCallbacks->platform;
                                                             : mIdleTimerCallbacks->platform;
    }
    }


    // The list of refresh rates, indexed by display modes ID. This may change after this
    // The display modes of the active display. The DisplayModeIterators below are pointers into
    // object is initialized.
    // this container, so must be invalidated whenever the DisplayModes change. The Policy below
    AllRefreshRatesMapType mRefreshRates GUARDED_BY(mLock);
    // is also dependent, so must be reset as well.

    DisplayModes mDisplayModes GUARDED_BY(mLock);
    // The list of refresh rates in the primary range of the current policy, ordered by vsyncPeriod
    // (the first element is the lowest refresh rate).
    std::vector<const RefreshRate*> mPrimaryRefreshRates GUARDED_BY(mLock);


    // The list of refresh rates in the app request range of the current policy, ordered by
    DisplayModeIterator mActiveModeIt GUARDED_BY(mLock);
    // vsyncPeriod (the first element is the lowest refresh rate).
    DisplayModeIterator mMinRefreshRateModeIt GUARDED_BY(mLock);
    std::vector<const RefreshRate*> mAppRequestRefreshRates GUARDED_BY(mLock);
    DisplayModeIterator mMaxRefreshRateModeIt GUARDED_BY(mLock);


    // The current display mode. This will change at runtime. This is set by SurfaceFlinger on
    // Display modes that satisfy the Policy's ranges, filtered and sorted by refresh rate.
    // the main thread, and read by the Scheduler (and other objects) on other threads.
    std::vector<DisplayModeIterator> mPrimaryRefreshRates GUARDED_BY(mLock);
    const RefreshRate* mCurrentRefreshRate GUARDED_BY(mLock);
    std::vector<DisplayModeIterator> mAppRequestRefreshRates GUARDED_BY(mLock);


    // The policy values will change at runtime. They're set by SurfaceFlinger on the main thread,
    // and read by the Scheduler (and other objects) on other threads.
    Policy mDisplayManagerPolicy GUARDED_BY(mLock);
    Policy mDisplayManagerPolicy GUARDED_BY(mLock);
    std::optional<Policy> mOverridePolicy GUARDED_BY(mLock);
    std::optional<Policy> mOverridePolicy GUARDED_BY(mLock);


    // The min and max refresh rates supported by the device.
    // This may change at runtime.
    const RefreshRate* mMinSupportedRefreshRate GUARDED_BY(mLock);
    const RefreshRate* mMaxSupportedRefreshRate GUARDED_BY(mLock);

    mutable std::mutex mLock;
    mutable std::mutex mLock;


    // A sorted list of known frame rates that a Heuristic layer will choose
    // A sorted list of known frame rates that a Heuristic layer will choose
@@ -486,7 +402,7 @@ private:


    struct GetBestRefreshRateCache {
    struct GetBestRefreshRateCache {
        std::pair<std::vector<LayerRequirement>, GlobalSignals> arguments;
        std::pair<std::vector<LayerRequirement>, GlobalSignals> arguments;
        std::pair<RefreshRate, GlobalSignals> result;
        std::pair<DisplayModePtr, GlobalSignals> result;
    };
    };
    mutable std::optional<GetBestRefreshRateCache> mGetBestRefreshRateCache GUARDED_BY(mLock);
    mutable std::optional<GetBestRefreshRateCache> mGetBestRefreshRateCache GUARDED_BY(mLock);


Loading