SurfaceFlinger: enhance refresh rate selection
Enhance the refresh rate selection algorithm to allow having multiple
refresh rate. The new process attaches scores to each one of the available
refresh rate and chooses the refresh rate with the highest score.
This behavior is currently controlled by the sysprop flag
'debug.sf.use_content_detection_v2' and currently turned off.
This algorithm stills needs some tunings which will be done in
layer CLs.
Test: adb shell /data/nativetest64/SurfaceFlinger_test/SurfaceFlinger_test
Test: adb shell /data/nativetest64/libsurfaceflinger_unittest/libsurfaceflinger_unittest
Test: go/90hzscenarios manual tests
Bug: 147516364
Fixes: 146068419
Change-Id: I06e07459e469482799ff80fa54fa8dd311325e0e
diff --git a/services/surfaceflinger/tests/unittests/TestableScheduler.h b/services/surfaceflinger/tests/unittests/TestableScheduler.h
index a67c24c..52da34b 100644
--- a/services/surfaceflinger/tests/unittests/TestableScheduler.h
+++ b/services/surfaceflinger/tests/unittests/TestableScheduler.h
@@ -28,16 +28,25 @@
class TestableScheduler : public Scheduler, private ISchedulerCallback {
public:
- explicit TestableScheduler(const scheduler::RefreshRateConfigs& configs)
- : Scheduler([](bool) {}, configs, *this) {
- mLayerHistory = std::make_unique<scheduler::impl::LayerHistory>();
+ TestableScheduler(const scheduler::RefreshRateConfigs& configs, bool useContentDetectionV2)
+ : Scheduler([](bool) {}, configs, *this, useContentDetectionV2) {
+ if (mUseContentDetectionV2) {
+ mLayerHistory = std::make_unique<scheduler::impl::LayerHistoryV2>();
+ } else {
+ mLayerHistory = std::make_unique<scheduler::impl::LayerHistory>();
+ }
}
TestableScheduler(std::unique_ptr<DispSync> primaryDispSync,
std::unique_ptr<EventControlThread> eventControlThread,
- const scheduler::RefreshRateConfigs& configs)
- : Scheduler(std::move(primaryDispSync), std::move(eventControlThread), configs, *this) {
- mLayerHistory = std::make_unique<scheduler::impl::LayerHistory>();
+ const scheduler::RefreshRateConfigs& configs, bool useContentDetectionV2)
+ : Scheduler(std::move(primaryDispSync), std::move(eventControlThread), configs, *this,
+ useContentDetectionV2) {
+ if (mUseContentDetectionV2) {
+ mLayerHistory = std::make_unique<scheduler::impl::LayerHistoryV2>();
+ } else {
+ mLayerHistory = std::make_unique<scheduler::impl::LayerHistory>();
+ }
}
// Used to inject mock event thread.
@@ -46,7 +55,13 @@
}
size_t layerHistorySize() const NO_THREAD_SAFETY_ANALYSIS {
- return static_cast<scheduler::impl::LayerHistory*>(mLayerHistory.get())->mLayerInfos.size();
+ if (mUseContentDetectionV2) {
+ return static_cast<scheduler::impl::LayerHistoryV2*>(mLayerHistory.get())
+ ->mLayerInfos.size();
+ } else {
+ return static_cast<scheduler::impl::LayerHistory*>(mLayerHistory.get())
+ ->mLayerInfos.size();
+ }
}
/* ------------------------------------------------------------------------
@@ -60,6 +75,9 @@
auto mutableLayerHistory() {
return static_cast<scheduler::impl::LayerHistory*>(mLayerHistory.get());
}
+ auto mutableLayerHistoryV2() {
+ return static_cast<scheduler::impl::LayerHistoryV2*>(mLayerHistory.get());
+ }
~TestableScheduler() {
// All these pointer and container clears help ensure that GMock does