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

Commit 480f445e authored by Ady Abraham's avatar Ady Abraham Committed by Ana Krulec
Browse files

SurfaceFlinger: store fps instead of duration in LayerInfo

To get a better average of the content fps, we switch to store the
momentarily fps rate instead of the refresh duration.
For example:

Frame#0 at 0ms
Frame#1 at 100ms
Frame#2 at 111ms
Frame#3 at 122ms
Average based on duration is AVERAGE(100, 11, 11) = 40.6ms (25fps)
Average based on fps is AVERAGE(10, 90, 90) = 63fps

Test: app launch
Bug: 136558136
Change-Id: Icab848dd1f312498590f9735b8881ecdf0d24113
(cherry picked from commit 187d2d81)
Merged-In: Icab848dd1f312498590f9735b8881ecdf0d24113
parent b38c1e0c
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -43,7 +43,8 @@ void LayerInfo::setLastPresentTime(nsecs_t lastPresentTime) {
    // Ignore time diff that are too high - those are stale values
    // Ignore time diff that are too high - those are stale values
    if (timeDiff > TIME_EPSILON_NS.count()) return;
    if (timeDiff > TIME_EPSILON_NS.count()) return;
    const nsecs_t refreshDuration = (timeDiff > 0) ? timeDiff : mMinRefreshDuration;
    const nsecs_t refreshDuration = (timeDiff > 0) ? timeDiff : mMinRefreshDuration;
    mRefreshRateHistory.insertRefreshRate(refreshDuration);
    const int fps = 1e9f / refreshDuration;
    mRefreshRateHistory.insertRefreshRate(fps);
}
}


} // namespace scheduler
} // namespace scheduler
+5 −5
Original line number Original line Diff line number Diff line
@@ -46,7 +46,7 @@ class LayerInfo {
    public:
    public:
        explicit RefreshRateHistory(nsecs_t minRefreshDuration)
        explicit RefreshRateHistory(nsecs_t minRefreshDuration)
              : mMinRefreshDuration(minRefreshDuration) {}
              : mMinRefreshDuration(minRefreshDuration) {}
        void insertRefreshRate(nsecs_t refreshRate) {
        void insertRefreshRate(int refreshRate) {
            mElements.push_back(refreshRate);
            mElements.push_back(refreshRate);
            if (mElements.size() > HISTORY_SIZE) {
            if (mElements.size() > HISTORY_SIZE) {
                mElements.pop_front();
                mElements.pop_front();
@@ -54,13 +54,13 @@ class LayerInfo {
        }
        }


        float getRefreshRateAvg() const {
        float getRefreshRateAvg() const {
            nsecs_t refreshDuration = mMinRefreshDuration;
            if (mElements.empty()) {
            if (mElements.size() == HISTORY_SIZE) {
                return 1e9f / mMinRefreshDuration;
                refreshDuration = scheduler::calculate_mean(mElements);
            }
            }


            return 1e9f / refreshDuration;
            return scheduler::calculate_mean(mElements);
        }
        }

        void clearHistory() { mElements.clear(); }
        void clearHistory() { mElements.clear(); }


    private:
    private: