Pass fps data to flattener
Use this extra data in determining if a layer should be considered inactive for flattening.
The effect is that sub 1 fps layers are cached immediately upon updating.
Test: Unit tests added, and confirmation of the intended effect on R6 during camera recording using
dumpsys surfaceflinger (expected all CameraLauncher layers to be device composited)
Bug: b/192271493
Change-Id: I06f2dd0b3256da5699ffca7347285dc8cf52713c
diff --git a/services/surfaceflinger/Scheduler/LayerInfo.cpp b/services/surfaceflinger/Scheduler/LayerInfo.cpp
index ae61eeb..943615c 100644
--- a/services/surfaceflinger/Scheduler/LayerInfo.cpp
+++ b/services/surfaceflinger/Scheduler/LayerInfo.cpp
@@ -75,12 +75,16 @@
}
bool LayerInfo::isFrequent(nsecs_t now) const {
+ using fps_approx_ops::operator>=;
// If we know nothing about this layer we consider it as frequent as it might be the start
// of an animation.
if (mFrameTimes.size() < kFrequentLayerWindowSize) {
return true;
}
+ return getFps(now) >= kMinFpsForFrequentLayer;
+}
+Fps LayerInfo::getFps(nsecs_t now) const {
// Find the first active frame
auto it = mFrameTimes.begin();
for (; it != mFrameTimes.end(); ++it) {
@@ -91,14 +95,12 @@
const auto numFrames = std::distance(it, mFrameTimes.end());
if (numFrames < kFrequentLayerWindowSize) {
- return false;
+ return Fps();
}
- using fps_approx_ops::operator>=;
-
// Layer is considered frequent if the average frame rate is higher than the threshold
const auto totalTime = mFrameTimes.back().queueTime - it->queueTime;
- return Fps::fromPeriodNsecs(totalTime / (numFrames - 1)) >= kMinFpsForFrequentLayer;
+ return Fps::fromPeriodNsecs(totalTime / (numFrames - 1));
}
bool LayerInfo::isAnimating(nsecs_t now) const {
@@ -236,7 +238,7 @@
if (!isFrequent(now)) {
ALOGV("%s is infrequent", mName.c_str());
mLastRefreshRate.animatingOrInfrequent = true;
- // Infrequent layers vote for minimal refresh rate for
+ // Infrequent layers vote for mininal refresh rate for
// battery saving purposes and also to prevent b/135718869.
return {LayerHistory::LayerVoteType::Min, Fps()};
}