SurfaceFlinger: return DisplayStatInfo from getDisplayStatInfo
Code cleanup - return the class instead of passing it as an
output parameter.
Test: SF unit tests
Change-Id: I7a995415a81f3944d93a1cb573c8e3108464bd07
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 89442ac..fd2e20e 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -963,7 +963,7 @@
return BAD_VALUE;
}
- mScheduler->getDisplayStatInfo(stats, systemTime());
+ *stats = mScheduler->getDisplayStatInfo(systemTime());
return NO_ERROR;
}
@@ -1440,8 +1440,7 @@
status_t SurfaceFlinger::injectVSync(nsecs_t when) {
Mutex::Autolock lock(mStateLock);
- DisplayStatInfo stats;
- mScheduler->getDisplayStatInfo(&stats, when);
+ const DisplayStatInfo stats = mScheduler->getDisplayStatInfo(when);
const auto expectedPresent = calculateExpectedPresentTime(stats);
return mScheduler->injectVSync(when, /*expectedVSyncTime=*/expectedPresent,
/*deadlineTimestamp=*/expectedPresent)
@@ -1769,8 +1768,7 @@
// Add some slop to correct for drift. This should generally be
// smaller than a typical frame duration, but should not be so small
// that it reports reasonable drift as a missed frame.
- DisplayStatInfo stats;
- mScheduler->getDisplayStatInfo(&stats, systemTime());
+ const DisplayStatInfo stats = mScheduler->getDisplayStatInfo(systemTime());
const nsecs_t frameMissedSlop = stats.vsyncPeriod / 2;
const nsecs_t previousPresentTime = previousFramePresentTime();
const TracedOrdinal<bool> frameMissed = {"PrevFrameMissed",
@@ -2147,8 +2145,7 @@
auto presentFenceTime = std::make_shared<FenceTime>(mPreviousPresentFences[0]);
getBE().mDisplayTimeline.push(presentFenceTime);
- DisplayStatInfo stats;
- mScheduler->getDisplayStatInfo(&stats, systemTime());
+ const DisplayStatInfo stats = mScheduler->getDisplayStatInfo(systemTime());
// We use the CompositionEngine::getLastFrameRefreshTimestamp() which might
// be sampled a little later than when we started doing work for this frame,
@@ -3364,8 +3361,7 @@
if (!pendingTransactions) {
const auto now = systemTime();
const bool nextVsyncPending = now < mExpectedPresentTime.load();
- DisplayStatInfo stats;
- mScheduler->getDisplayStatInfo(&stats, now);
+ const DisplayStatInfo stats = mScheduler->getDisplayStatInfo(now);
mExpectedPresentTime = calculateExpectedPresentTime(stats);
// The transaction might arrive just before the next vsync but after
// invalidate was called. In that case we need to get the next vsync