summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Steven Thomas <steventhomas@google.com> 2020-05-19 17:47:14 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-05-19 17:47:14 +0000
commit98b789db15c11b1d2ed43f4098784a316d9dfcc9 (patch)
treea6f80bd3da2486183876fe604a2ecf1b9dd398a1
parent63da46c3ec1c4cd8b1cc38d1ae6c5d8ad03ad679 (diff)
parentdebafed2c70484484fa694bd4da53826a6c8168a (diff)
Merge "With content detection off, prefer default frame rate" into rvc-dev
-rw-r--r--services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp4
-rw-r--r--services/surfaceflinger/Scheduler/Scheduler.cpp45
-rw-r--r--services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp9
3 files changed, 26 insertions, 32 deletions
diff --git a/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp b/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp
index 69b1a3c261..4a4f9c8111 100644
--- a/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp
+++ b/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp
@@ -140,8 +140,8 @@ const RefreshRate& RefreshRateConfigs::getBestRefreshRate(
return getMinRefreshRateByPolicyLocked();
}
- if (layers.empty()) {
- return getCurrentRefreshRateByPolicyLocked();
+ if (layers.empty() || noVoteLayers == layers.size()) {
+ return getMaxRefreshRateByPolicyLocked();
}
// Only if all layers want Min we should return Min
diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp
index 00f87bbf59..4eef81d113 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -385,38 +385,33 @@ nsecs_t Scheduler::getDispSyncExpectedPresentTime(nsecs_t now) {
void Scheduler::registerLayer(Layer* layer) {
if (!mLayerHistory) return;
- // If the content detection feature is off, all layers are registered at NoVote. We still
- // keep the layer history, since we use it for other features (like Frame Rate API), so layers
- // still need to be registered.
- if (!mUseContentDetection) {
- mLayerHistory->registerLayer(layer, mRefreshRateConfigs.getMinRefreshRate().getFps(),
- mRefreshRateConfigs.getMaxRefreshRate().getFps(),
- scheduler::LayerHistory::LayerVoteType::NoVote);
- return;
- }
+ const auto minFps = mRefreshRateConfigs.getMinRefreshRate().getFps();
+ const auto maxFps = mRefreshRateConfigs.getMaxRefreshRate().getFps();
- // In V1 of content detection, all layers are registered as Heuristic (unless it's wallpaper).
- if (!mUseContentDetectionV2) {
- const auto lowFps = mRefreshRateConfigs.getMinRefreshRate().getFps();
- const auto highFps = layer->getWindowType() == InputWindowInfo::TYPE_WALLPAPER
- ? lowFps
- : mRefreshRateConfigs.getMaxRefreshRate().getFps();
-
- mLayerHistory->registerLayer(layer, lowFps, highFps,
+ if (layer->getWindowType() == InputWindowInfo::TYPE_STATUS_BAR) {
+ mLayerHistory->registerLayer(layer, minFps, maxFps,
+ scheduler::LayerHistory::LayerVoteType::NoVote);
+ } else if (!mUseContentDetection) {
+ // If the content detection feature is off, all layers are registered at Max. We still keep
+ // the layer history, since we use it for other features (like Frame Rate API), so layers
+ // still need to be registered.
+ mLayerHistory->registerLayer(layer, minFps, maxFps,
+ scheduler::LayerHistory::LayerVoteType::Max);
+ } else if (!mUseContentDetectionV2) {
+ // In V1 of content detection, all layers are registered as Heuristic (unless it's
+ // wallpaper).
+ const auto highFps =
+ layer->getWindowType() == InputWindowInfo::TYPE_WALLPAPER ? minFps : maxFps;
+
+ mLayerHistory->registerLayer(layer, minFps, highFps,
scheduler::LayerHistory::LayerVoteType::Heuristic);
} else {
if (layer->getWindowType() == InputWindowInfo::TYPE_WALLPAPER) {
// Running Wallpaper at Min is considered as part of content detection.
- mLayerHistory->registerLayer(layer, mRefreshRateConfigs.getMinRefreshRate().getFps(),
- mRefreshRateConfigs.getMaxRefreshRate().getFps(),
+ mLayerHistory->registerLayer(layer, minFps, maxFps,
scheduler::LayerHistory::LayerVoteType::Min);
- } else if (layer->getWindowType() == InputWindowInfo::TYPE_STATUS_BAR) {
- mLayerHistory->registerLayer(layer, mRefreshRateConfigs.getMinRefreshRate().getFps(),
- mRefreshRateConfigs.getMaxRefreshRate().getFps(),
- scheduler::LayerHistory::LayerVoteType::NoVote);
} else {
- mLayerHistory->registerLayer(layer, mRefreshRateConfigs.getMinRefreshRate().getFps(),
- mRefreshRateConfigs.getMaxRefreshRate().getFps(),
+ mLayerHistory->registerLayer(layer, minFps, maxFps,
scheduler::LayerHistory::LayerVoteType::Heuristic);
}
}
diff --git a/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp b/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp
index 2b168b2cf2..692f71f8d3 100644
--- a/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp
+++ b/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp
@@ -340,15 +340,14 @@ TEST_F(RefreshRateConfigsTest, getBestRefreshRate_noLayers) {
std::make_unique<RefreshRateConfigs>(m60_72_90Device, /*currentConfigId=*/
HWC_CONFIG_ID_72);
- // If there are not layers, there is not content detection, so return the current
- // refresh rate.
+ // If there are no layers we select the default frame rate, which is the max of the primary
+ // range.
auto layers = std::vector<LayerRequirement>{};
- EXPECT_EQ(mExpected72Config,
+ EXPECT_EQ(mExpected90Config,
refreshRateConfigs->getBestRefreshRate(layers, /*touchActive*/
false, /*idle*/ false, &ignored));
- // Current refresh rate can always be changed.
- refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_60);
+ ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_60, {60, 60}}), 0);
EXPECT_EQ(mExpected60Config,
refreshRateConfigs->getBestRefreshRate(layers, /*touchActive*/
false, /*idle*/ false, &ignored));