SurfaceFlinger: handle wallpaper scenario in Scheduler
Use the fact that a layer contains wallpaper in Scheduler's
algorithm when picking a refresh rate. Wallpaper should be presented
in the lowest active refresh rate to preserve power.
Test: systrace during wallpaper
Bug: 124065567
Change-Id: Ibb18e62eaf1a6b9b3ab1ec18a3135fb17c8f57fc
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index de05f74..b47497a 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -70,7 +70,10 @@
std::atomic<int32_t> Layer::sSequence{1};
Layer::Layer(const LayerCreationArgs& args)
- : mFlinger(args.flinger), mName(args.name), mClientRef(args.client) {
+ : mFlinger(args.flinger),
+ mName(args.name),
+ mClientRef(args.client),
+ mWindowType(args.metadata.getInt32(METADATA_WINDOW_TYPE, 0)) {
mCurrentCrop.makeInvalid();
uint32_t layerFlags = 0;
@@ -115,7 +118,7 @@
mFrameEventHistory.initializeCompositorTiming(compositorTiming);
mFrameTracker.setDisplayRefreshPeriod(compositorTiming.interval);
- mSchedulerLayerHandle = mFlinger->mScheduler->registerLayer(mName.c_str());
+ mSchedulerLayerHandle = mFlinger->mScheduler->registerLayer(mName.c_str(), mWindowType);
mFlinger->onLayerCreated();
}
@@ -1300,6 +1303,7 @@
result.append("-----------------------------\n");
result.append(" Layer name\n");
result.append(" Z | ");
+ result.append(" Window Type | ");
result.append(" Comp Type | ");
result.append(" Transform | ");
result.append(" Disp Frame (LTRB) | ");
@@ -1336,6 +1340,7 @@
} else {
StringAppendF(&result, " %10d | ", layerState.z);
}
+ StringAppendF(&result, " %10d | ", mWindowType);
StringAppendF(&result, "%10s | ", toString(getCompositionType(displayDevice)).c_str());
StringAppendF(&result, "%10s | ",
toString(getCompositionLayer() ? compositionState.bufferTransform
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 66e35b6..f4545e0 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -885,6 +885,9 @@
// Can only be accessed with the SF state lock held.
bool mChildrenChanged{false};
+ // Window types from WindowManager.LayoutParams
+ const int mWindowType;
+
// This is populated if the layer is registered with Scheduler for tracking purposes.
std::unique_ptr<scheduler::LayerHistory::LayerHandle> mSchedulerLayerHandle;
diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp
index 9f92d92..073a2db 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -28,6 +28,7 @@
#include <android/hardware/configstore/1.1/ISurfaceFlingerConfigs.h>
#include <configstore/Utils.h>
#include <cutils/properties.h>
+#include <input/InputWindow.h>
#include <system/window.h>
#include <ui/DisplayStatInfo.h>
#include <utils/Timers.h>
@@ -301,8 +302,10 @@
}
std::unique_ptr<scheduler::LayerHistory::LayerHandle> Scheduler::registerLayer(
- const std::string name) {
- RefreshRateType refreshRateType = RefreshRateType::PERFORMANCE;
+ std::string const& name, int windowType) {
+ RefreshRateType refreshRateType = (windowType == InputWindowInfo::TYPE_WALLPAPER)
+ ? RefreshRateType::DEFAULT
+ : RefreshRateType::PERFORMANCE;
const auto refreshRate = mRefreshRateConfigs.getRefreshRate(refreshRateType);
const uint32_t fps = (refreshRate) ? refreshRate->fps : 0;
diff --git a/services/surfaceflinger/Scheduler/Scheduler.h b/services/surfaceflinger/Scheduler/Scheduler.h
index 1d53252..1318fbb 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.h
+++ b/services/surfaceflinger/Scheduler/Scheduler.h
@@ -147,7 +147,9 @@
void setIgnorePresentFences(bool ignore);
nsecs_t expectedPresentTime();
// Registers the layer in the scheduler, and returns the handle for future references.
- std::unique_ptr<scheduler::LayerHistory::LayerHandle> registerLayer(const std::string name);
+ std::unique_ptr<scheduler::LayerHistory::LayerHandle> registerLayer(std::string const& name,
+ int windowType);
+
// Stores present time for a layer.
void addLayerPresentTime(
const std::unique_ptr<scheduler::LayerHistory::LayerHandle>& layerHandle,
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 7c88cd8..9f32ff7 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -4030,7 +4030,7 @@
if (metadata.has(METADATA_WINDOW_TYPE)) {
int32_t windowType = metadata.getInt32(METADATA_WINDOW_TYPE, 0);
if (windowType == 441731) {
- metadata.setInt32(METADATA_WINDOW_TYPE, 2024); // TYPE_NAVIGATION_BAR_PANEL
+ metadata.setInt32(METADATA_WINDOW_TYPE, InputWindowInfo::TYPE_NAVIGATION_BAR_PANEL);
primaryDisplayOnly = true;
}
}