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

Commit 557778ef authored by Ben Widawsky's avatar Ben Widawsky
Browse files

SF: Fix FrameTimeline based FrameStats test

This doesn't fix real world usages (which were fine). It only fixes a
bug exercised by a corner case in a unit test.

Bug: 382769837
Test: LayerTypeTransactionTests/LayerTypeTransactionTest.RefreshRateIsInitialized
Flag: com.android.graphics.surfaceflinger.flags.deprecate_frame_tracker
Change-Id: I145bebf6cdaac2e89d2f76e5bb8e1d2c21cdff81
parent aee588c2
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -644,9 +644,16 @@ void Layer::clearFrameStats() {
void Layer::getFrameStats(FrameStats* outStats) const {
    if (FlagManager::getInstance().deprecate_frame_tracker()) {
        if (auto ftl = getTimeline()) {
            float fps = ftl->get().computeFps({getSequence()});
            nsecs_t refreshPeriod =
                    Fps::fromValue(ftl->get().computeFps({getSequence()})).getPeriodNsecs();
            // FPS computation requires some number of layer updates before the calculation can be
            // made. If not enough frames are available return the projected FPS based on the
            // pacesetter display's native refresh rate.
            if (!refreshPeriod) {
                refreshPeriod = mFlinger->mScheduler->getPacesetterVsyncPeriod().ns();
            }
            ftl->get().generateFrameStats(getSequence(), mFrameStatsHistorySize, outStats);
            outStats->refreshPeriodNano = Fps::fromValue(fps).getPeriodNsecs();
            outStats->refreshPeriodNano = refreshPeriod;
        }
    } else {
        mDeprecatedFrameTracker.getStats(outStats);